aboutsummaryrefslogtreecommitdiff
path: root/testsuite/bzcat.tests
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauerman@linux.vnet.ibm.com>2015-05-11 17:18:59 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2015-05-11 17:19:22 +0200
commit17b16223f39c983a5d0eba8d3ab656a8d123b621 (patch)
tree20aec6f66f44748ec70ae7f5ffe96b10581cd839 /testsuite/bzcat.tests
parentbdb540e04f3eb52c4cd790c45c5d8efd6d749c70 (diff)
downloadbusybox-w32-17b16223f39c983a5d0eba8d3ab656a8d123b621.tar.gz
busybox-w32-17b16223f39c983a5d0eba8d3ab656a8d123b621.tar.bz2
busybox-w32-17b16223f39c983a5d0eba8d3ab656a8d123b621.zip
bzcat.tests: Run both .gz and .bz2 tests, and add .Z tests
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rwxr-xr-xtestsuite/bzcat.tests74
1 files changed, 50 insertions, 24 deletions
diff --git a/testsuite/bzcat.tests b/testsuite/bzcat.tests
index 1c1fd6563..9a1c28425 100755
--- a/testsuite/bzcat.tests
+++ b/testsuite/bzcat.tests
@@ -2,8 +2,6 @@
2 2
3FAILCOUNT=0 3FAILCOUNT=0
4 4
5ext=bz2
6
7bb="busybox " 5bb="busybox "
8 6
9unset LC_ALL 7unset LC_ALL
@@ -11,6 +9,11 @@ unset LC_MESSAGES
11unset LANG 9unset LANG
12unset LANGUAGE 10unset LANGUAGE
13 11
12hello_Z() {
13 # Compressed "HELLO\n"
14 $ECHO -ne "\x1f\x9d\x90\x48\x8a\x30\x61\xf2\x44\x01"
15}
16
14hello_gz() { 17hello_gz() {
15 # Gzipped "HELLO\n" 18 # Gzipped "HELLO\n"
16 #_________________________ vvv vvv vvv vvv - mtime 19 #_________________________ vvv vvv vvv vvv - mtime
@@ -25,32 +28,34 @@ hello_bz2() {
25 $ECHO -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3" 28 $ECHO -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3"
26} 29}
27 30
28prep() { 31for ext in gz bz2 Z
29 rm -f t* 32do
30 hello_$ext >t1.$ext 33 prep() {
31 hello_$ext >t2.$ext 34 rm -f t1.$ext t2.$ext t_actual
32} 35 hello_$ext >t1.$ext
36 hello_$ext >t2.$ext
37 }
33 38
34check() { 39 check() {
35 eval $2 >t_actual 2>&1 40 eval $2 >t_actual 2>&1
36 if $ECHO -ne "$expected" | cmp - t_actual; then 41 if $ECHO -ne "$expected" | cmp - t_actual; then
37 echo "PASS: $1" 42 echo "PASS: $1"
38 else 43 else
39 echo "FAIL: $1" 44 echo "FAIL: $1"
40 FAILCOUNT=$((FAILCOUNT + 1)) 45 FAILCOUNT=$((FAILCOUNT + 1))
41 fi 46 fi
42} 47 }
43 48
44mkdir testdir 2>/dev/null 49 mkdir testdir 2>/dev/null
45( 50 (
46cd testdir || { echo "cannot cd testdir!"; exit 1; } 51 cd testdir || { echo "cannot cd testdir!"; exit 1; }
47 52
48expected="HELLO\nok\n" 53 expected="HELLO\nok\n"
49prep; check "bzcat: dont delete src" "${bb}bzcat t2.bz2; test -f t2.bz2 && echo ok" 54 prep; check "zcat: dont delete $ext src" "${bb}zcat t2.$ext; test -f t2.$ext && echo ok"
50
51)
52rm -rf testdir
53 55
56 )
57 rm -rf testdir
58done
54 59
55 60
56# Copyright 2011 by Denys Vlasenko 61# Copyright 2011 by Denys Vlasenko
@@ -60,6 +65,8 @@ rm -rf testdir
60 65
61# testing "test name" "command" "expected result" "file input" "stdin" 66# testing "test name" "command" "expected result" "file input" "stdin"
62 67
68## bzip algorithm
69
63# "input" file is bzipped file with "a\n" data 70# "input" file is bzipped file with "a\n" data
64testing "bzcat can print many files" \ 71testing "bzcat can print many files" \
65"$ECHO -ne '$hexdump' | bzcat input input; echo \$?" \ 72"$ECHO -ne '$hexdump' | bzcat input input; echo \$?" \
@@ -79,6 +86,25 @@ testing "bzcat can handle compressed zero-length bzip2 files" \
79"0\n" \ 86"0\n" \
80"\x42\x5a\x68\x39\x17\x72\x45\x38\x50\x90\x00\x00\x00\x00" "" 87"\x42\x5a\x68\x39\x17\x72\x45\x38\x50\x90\x00\x00\x00\x00" ""
81 88
89## compress algorithm
90
91# "input" file is compressed (.Z) file with "a\n" data
92testing "zcat can print many files" \
93"$ECHO -ne '$hexdump' | zcat input input; echo \$?" \
94"\
95a
96a
970
98" "\
99\x1f\x9d\x90\x61\x14\x00\
100" ""
101
102# "input" file is compressed (.Z) zero byte file
103testing "zcat can handle compressed zero-length compressed (.Z) files" \
104"$ECHO -ne '$hexdump' | zcat input input; echo \$?" \
105"0\n" \
106"\x1f\x9d\x90\x00" ""
107
82 108
83 109
84exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255)) 110exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255))