bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] [PATCH] testsuite: fix RE_CHECK macro and fix two tests


From: Pavel Raiskup
Subject: [Bug-tar] [PATCH] testsuite: fix RE_CHECK macro and fix two tests
Date: Fri, 14 Mar 2014 09:49:55 +0100

IIRC, RE_CHECK from testsuite.at has never worked as expected
(never performed any checking until now).  So wrapping its
contents by AT_CHECK and double-quote right argument of AT_DATA to
not eat special regex symbols.  Avoid awk & join.

* tests/testsuite.at (RE_CHECK):  Change logic a little.
* tests/sparse03.at: Ignore umask value.
* tests/sparse01.at: Likewise.  Fix expected size.
---
 tests/sparse01.at  |  6 +++---
 tests/sparse03.at  |  2 +-
 tests/testsuite.at | 22 +++++++++++++++-------
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/tests/sparse01.at b/tests/sparse01.at
index ccd54da..e837adf 100644
--- a/tests/sparse01.at
+++ b/tests/sparse01.at
@@ -25,7 +25,7 @@ AT_TAR_CHECK([
 genfile --length 1000 -f begin
 genfile --length 1000 -f end
 genfile --sparse --file sparsefile --block-size 512 0 ABCD 1M EFGH 2000K IJKL 
|| AT_SKIP_TEST
-tar -c -f archive --sparse begin sparsefile end || exit 1
+tar -c -f archive --sparse begin sparsefile end --mode='u=rw,go=r' || exit 1
 echo separator
 
 tar tfv archive
@@ -42,10 +42,10 @@ cmp sparsefile directory/sparsefile
 RE_CHECK([stdout],
 [separator
 -rw-r--r-- [^ ][^ ]*  *1000 [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 
[0-9][0-9]:[0-9][0-9] begin
--rw-r--r-- [^ ][^ ]*  *10344448 [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 
[0-9][0-9]:[0-9][0-9] sparsefile
+-rw-r--r-- [^ ][^ ]*  *3102720 [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 
[0-9][0-9]:[0-9][0-9] sparsefile
 -rw-r--r-- [^ ][^ ]*  *1000 [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] 
[0-9][0-9]:[0-9][0-9] end
 separator
-sparsefile 10344448
+sparsefile 3102720
 ])
 
 AT_CLEANUP
diff --git a/tests/sparse03.at b/tests/sparse03.at
index 3521eab..639a21f 100644
--- a/tests/sparse03.at
+++ b/tests/sparse03.at
@@ -30,7 +30,7 @@ AT_TAR_CHECK([
 genfile --length 1000 --file begin
 genfile --length 1000 --file end
 genfile --sparse --file sparsefile --block-size 512 8G A || AT_SKIP_TEST
-tar -c -f archive --sparse begin sparsefile end || exit 1
+tar -c -f archive --sparse begin sparsefile end --mode='u=rw,go=r' || exit 1
 echo separator
 
 tar tfv archive
diff --git a/tests/testsuite.at b/tests/testsuite.at
index c52890b..d1d08d9 100644
--- a/tests/testsuite.at
+++ b/tests/testsuite.at
@@ -49,13 +49,21 @@ m4_define([TAR_IGNREC_HOOK],[
 ])
 
 m4_define([RE_CHECK],[
-AT_DATA([$1.re],[$2])
-awk '{print NR " " $[]0}' $1 > $[]$.1
-awk '{print NR " " $[]0}' $1.re | join - $[]$.1 |
-while read NUM RE LINE
-do
-  echo "$LINE" | grep -- "$RE" >/dev/null || exit 1
-done
+AT_CHECK([
+AT_DATA([$1.re],[[$2]])
+
+while read LINE <&3 && read RE <&4; do
+    if test -n "$__AT_TAR_RE_DEBUG"; then
+        echo "RE: $RE"
+        echo "LINE: $LINE"
+    fi
+    echo "$LINE" | grep -- "$RE" >/dev/null || \
+        {
+            echo "'$RE'" does not match "'$LINE'"
+            exit 1
+        }
+done 3<$1 4<$1.re
+])
 ])
 
 m4_define([AT_SKIP_TEST],[exit 77])
-- 
1.8.5.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]