mirror of
https://github.com/sheumann/hush.git
synced 2024-12-24 12:29:47 +00:00
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>
This commit is contained in:
parent
bdb540e04f
commit
17b16223f3
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
FAILCOUNT=0
|
FAILCOUNT=0
|
||||||
|
|
||||||
ext=bz2
|
|
||||||
|
|
||||||
bb="busybox "
|
bb="busybox "
|
||||||
|
|
||||||
unset LC_ALL
|
unset LC_ALL
|
||||||
@ -11,6 +9,11 @@ unset LC_MESSAGES
|
|||||||
unset LANG
|
unset LANG
|
||||||
unset LANGUAGE
|
unset LANGUAGE
|
||||||
|
|
||||||
|
hello_Z() {
|
||||||
|
# Compressed "HELLO\n"
|
||||||
|
$ECHO -ne "\x1f\x9d\x90\x48\x8a\x30\x61\xf2\x44\x01"
|
||||||
|
}
|
||||||
|
|
||||||
hello_gz() {
|
hello_gz() {
|
||||||
# Gzipped "HELLO\n"
|
# Gzipped "HELLO\n"
|
||||||
#_________________________ vvv vvv vvv vvv - mtime
|
#_________________________ vvv vvv vvv vvv - mtime
|
||||||
@ -25,8 +28,10 @@ hello_bz2() {
|
|||||||
$ECHO -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3"
|
$ECHO -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ext in gz bz2 Z
|
||||||
|
do
|
||||||
prep() {
|
prep() {
|
||||||
rm -f t*
|
rm -f t1.$ext t2.$ext t_actual
|
||||||
hello_$ext >t1.$ext
|
hello_$ext >t1.$ext
|
||||||
hello_$ext >t2.$ext
|
hello_$ext >t2.$ext
|
||||||
}
|
}
|
||||||
@ -46,11 +51,11 @@ mkdir testdir 2>/dev/null
|
|||||||
cd testdir || { echo "cannot cd testdir!"; exit 1; }
|
cd testdir || { echo "cannot cd testdir!"; exit 1; }
|
||||||
|
|
||||||
expected="HELLO\nok\n"
|
expected="HELLO\nok\n"
|
||||||
prep; check "bzcat: dont delete src" "${bb}bzcat t2.bz2; test -f t2.bz2 && echo ok"
|
prep; check "zcat: dont delete $ext src" "${bb}zcat t2.$ext; test -f t2.$ext && echo ok"
|
||||||
|
|
||||||
)
|
)
|
||||||
rm -rf testdir
|
rm -rf testdir
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
# Copyright 2011 by Denys Vlasenko
|
# Copyright 2011 by Denys Vlasenko
|
||||||
@ -60,6 +65,8 @@ rm -rf testdir
|
|||||||
|
|
||||||
# testing "test name" "command" "expected result" "file input" "stdin"
|
# testing "test name" "command" "expected result" "file input" "stdin"
|
||||||
|
|
||||||
|
## bzip algorithm
|
||||||
|
|
||||||
# "input" file is bzipped file with "a\n" data
|
# "input" file is bzipped file with "a\n" data
|
||||||
testing "bzcat can print many files" \
|
testing "bzcat can print many files" \
|
||||||
"$ECHO -ne '$hexdump' | bzcat input input; echo \$?" \
|
"$ECHO -ne '$hexdump' | bzcat input input; echo \$?" \
|
||||||
@ -79,6 +86,25 @@ testing "bzcat can handle compressed zero-length bzip2 files" \
|
|||||||
"0\n" \
|
"0\n" \
|
||||||
"\x42\x5a\x68\x39\x17\x72\x45\x38\x50\x90\x00\x00\x00\x00" ""
|
"\x42\x5a\x68\x39\x17\x72\x45\x38\x50\x90\x00\x00\x00\x00" ""
|
||||||
|
|
||||||
|
## compress algorithm
|
||||||
|
|
||||||
|
# "input" file is compressed (.Z) file with "a\n" data
|
||||||
|
testing "zcat can print many files" \
|
||||||
|
"$ECHO -ne '$hexdump' | zcat input input; echo \$?" \
|
||||||
|
"\
|
||||||
|
a
|
||||||
|
a
|
||||||
|
0
|
||||||
|
" "\
|
||||||
|
\x1f\x9d\x90\x61\x14\x00\
|
||||||
|
" ""
|
||||||
|
|
||||||
|
# "input" file is compressed (.Z) zero byte file
|
||||||
|
testing "zcat can handle compressed zero-length compressed (.Z) files" \
|
||||||
|
"$ECHO -ne '$hexdump' | zcat input input; echo \$?" \
|
||||||
|
"0\n" \
|
||||||
|
"\x1f\x9d\x90\x00" ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255))
|
exit $((FAILCOUNT <= 255 ? FAILCOUNT : 255))
|
||||||
|
Loading…
Reference in New Issue
Block a user