blob: 78d74f22995a218ef1829b2ebdc621d7dce3b765 [file] [log] [blame]
Denis Vlasenkoab9eef22007-03-07 22:02:23 +00001#!/bin/sh
2
3ext=bz2
4
5bb="busybox "
6
7unset LC_ALL
8unset LC_MESSAGES
9unset LANG
10unset LANGUAGE
11
12hello_gz() {
13 # Gzipped "HELLO\n"
14 #_________________________ vvv vvv vvv vvv - mtime
Denis Vlasenkoabe49fa2008-07-11 21:41:14 +000015 $ECHO -ne "\x1f\x8b\x08\x00\x85\x1d\xef\x45\x02\x03\xf3\x70\xf5\xf1\xf1\xe7"
16 $ECHO -ne "\x02\x00\x6e\xd7\xac\xfd\x06\x00\x00\x00"
Denis Vlasenkoab9eef22007-03-07 22:02:23 +000017}
18
19hello_bz2() {
20 # Bzipped "HELLO\n"
Denis Vlasenkoabe49fa2008-07-11 21:41:14 +000021 $ECHO -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x5b\xb8\xe8\xa3\x00\x00"
22 $ECHO -ne "\x01\x44\x00\x00\x10\x02\x44\xa0\x00\x30\xcd\x00\xc3\x46\x29\x97"
23 $ECHO -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3"
Denis Vlasenkoab9eef22007-03-07 22:02:23 +000024}
25
26prep() {
27 rm -f t*
28 hello_$ext >t1.$ext
29 hello_$ext >t2.$ext
30}
31
32check() {
33 eval $2 >t_actual 2>&1
Denis Vlasenkoabe49fa2008-07-11 21:41:14 +000034 if $ECHO -ne "$expected" | cmp - t_actual; then
Denys Vlasenko7aca89a2009-07-18 03:41:29 +020035 echo "PASS: $1"
Denis Vlasenkoab9eef22007-03-07 22:02:23 +000036 else
Denys Vlasenko7aca89a2009-07-18 03:41:29 +020037 echo "FAIL: $1"
Denis Vlasenkoab9eef22007-03-07 22:02:23 +000038 fi
39}
40
41mkdir testdir 2>/dev/null
42(
43cd testdir || { echo "cannot cd testdir!"; exit 1; }
44
45expected="HELLO\nok\n"
46prep; check "bzcat: dont delete src" "${bb}bzcat t2.bz2; test -f t2.bz2 && echo ok"
47
48)
49rm -rf testdir