diff options
author | Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> | 2015-05-11 17:18:59 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-05-11 17:19:22 +0200 |
commit | 17b16223f39c983a5d0eba8d3ab656a8d123b621 (patch) | |
tree | 20aec6f66f44748ec70ae7f5ffe96b10581cd839 /testsuite/bzcat.tests | |
parent | bdb540e04f3eb52c4cd790c45c5d8efd6d749c70 (diff) | |
download | busybox-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-x | testsuite/bzcat.tests | 74 |
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 | ||
3 | FAILCOUNT=0 | 3 | FAILCOUNT=0 |
4 | 4 | ||
5 | ext=bz2 | ||
6 | |||
7 | bb="busybox " | 5 | bb="busybox " |
8 | 6 | ||
9 | unset LC_ALL | 7 | unset LC_ALL |
@@ -11,6 +9,11 @@ unset LC_MESSAGES | |||
11 | unset LANG | 9 | unset LANG |
12 | unset LANGUAGE | 10 | unset LANGUAGE |
13 | 11 | ||
12 | hello_Z() { | ||
13 | # Compressed "HELLO\n" | ||
14 | $ECHO -ne "\x1f\x9d\x90\x48\x8a\x30\x61\xf2\x44\x01" | ||
15 | } | ||
16 | |||
14 | hello_gz() { | 17 | hello_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 | ||
28 | prep() { | 31 | for ext in gz bz2 Z |
29 | rm -f t* | 32 | do |
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 | ||
34 | check() { | 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 | ||
44 | mkdir testdir 2>/dev/null | 49 | mkdir testdir 2>/dev/null |
45 | ( | 50 | ( |
46 | cd testdir || { echo "cannot cd testdir!"; exit 1; } | 51 | cd testdir || { echo "cannot cd testdir!"; exit 1; } |
47 | 52 | ||
48 | expected="HELLO\nok\n" | 53 | expected="HELLO\nok\n" |
49 | prep; 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 | ) | ||
52 | rm -rf testdir | ||
53 | 55 | ||
56 | ) | ||
57 | rm -rf testdir | ||
58 | done | ||
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 |
64 | testing "bzcat can print many files" \ | 71 | testing "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 | ||
92 | testing "zcat can print many files" \ | ||
93 | "$ECHO -ne '$hexdump' | zcat input input; echo \$?" \ | ||
94 | "\ | ||
95 | a | ||
96 | a | ||
97 | 0 | ||
98 | " "\ | ||
99 | \x1f\x9d\x90\x61\x14\x00\ | ||
100 | " "" | ||
101 | |||
102 | # "input" file is compressed (.Z) zero byte file | ||
103 | testing "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 | ||
84 | exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255)) | 110 | exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255)) |