[PATCH 1/2] bzcat.tests: Fix to run both gz and bz2 tests.

Thiago Jung Bauermann bauerman at linux.vnet.ibm.com
Thu Apr 23 19:03:06 UTC 2015


Hello,

Note that I'm changing the applet used in the check function
from bzcat to zcat. This allows gz to also be tested in the for loop
without losing the ability to test bz2.

Regards,
Thiago Jung Bauermann
IBM Linux Technology Center




---
 testsuite/bzcat.tests | 56 +++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/testsuite/bzcat.tests b/testsuite/bzcat.tests
index 1c1fd65..6abfa7e 100755
--- a/testsuite/bzcat.tests
+++ b/testsuite/bzcat.tests
@@ -2,8 +2,6 @@
 
 FAILCOUNT=0
 
-ext=bz2
-
 bb="busybox "
 
 unset LC_ALL
@@ -25,32 +23,34 @@ hello_bz2() {
     $ECHO -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3"
 }
 
-prep() {
-    rm -f t*
-    hello_$ext >t1.$ext
-    hello_$ext >t2.$ext
-}
-
-check() {
-    eval $2 >t_actual 2>&1
-    if $ECHO -ne "$expected" | cmp - t_actual; then
-	echo "PASS: $1"
-    else
-	echo "FAIL: $1"
-	FAILCOUNT=$((FAILCOUNT + 1))
-    fi
-}
-
-mkdir testdir 2>/dev/null
-(
-cd testdir || { echo "cannot cd testdir!"; exit 1; }
-
-expected="HELLO\nok\n"
-prep; check "bzcat: dont delete src" "${bb}bzcat t2.bz2; test -f t2.bz2 && echo ok"
-
-)
-rm -rf testdir
-
+for ext in gz bz2
+do
+    prep() {
+	rm -f t1.$ext t2.$ext t_actual
+	hello_$ext >t1.$ext
+	hello_$ext >t2.$ext
+    }
+
+    check() {
+	eval $2 >t_actual 2>&1
+	if $ECHO -ne "$expected" | cmp - t_actual; then
+	    echo "PASS: $1"
+	else
+	    echo "FAIL: $1"
+	    FAILCOUNT=$((FAILCOUNT + 1))
+	fi
+    }
+
+    mkdir testdir 2>/dev/null
+    (
+    cd testdir || { echo "cannot cd testdir!"; exit 1; }
+
+    expected="HELLO\nok\n"
+    prep; check "zcat: dont delete $ext src" "${bb}zcat t2.$ext; test -f t2.$ext && echo ok"
+
+    )
+    rm -rf testdir
+done
 
 
 # Copyright 2011 by Denys Vlasenko
-- 
1.9.1

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20150423/ff83e586/attachment-0001.html>


More information about the busybox mailing list