bzcat.tests 1002 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. ext=bz2
  3. bb="busybox "
  4. unset LC_ALL
  5. unset LC_MESSAGES
  6. unset LANG
  7. unset LANGUAGE
  8. hello_gz() {
  9. # Gzipped "HELLO\n"
  10. #_________________________ vvv vvv vvv vvv - mtime
  11. echo -ne "\x1f\x8b\x08\x00\x85\x1d\xef\x45\x02\x03\xf3\x70\xf5\xf1\xf1\xe7"
  12. echo -ne "\x02\x00\x6e\xd7\xac\xfd\x06\x00\x00\x00"
  13. }
  14. hello_bz2() {
  15. # Bzipped "HELLO\n"
  16. echo -ne "\x42\x5a\x68\x39\x31\x41\x59\x26\x53\x59\x5b\xb8\xe8\xa3\x00\x00"
  17. echo -ne "\x01\x44\x00\x00\x10\x02\x44\xa0\x00\x30\xcd\x00\xc3\x46\x29\x97"
  18. echo -ne "\x17\x72\x45\x38\x50\x90\x5b\xb8\xe8\xa3"
  19. }
  20. prep() {
  21. rm -f t*
  22. hello_$ext >t1.$ext
  23. hello_$ext >t2.$ext
  24. }
  25. check() {
  26. eval $2 >t_actual 2>&1
  27. if echo -ne "$expected" | cmp - t_actual; then
  28. echo "$1: PASS"
  29. else
  30. echo "$1: FAIL"
  31. fi
  32. }
  33. mkdir testdir 2>/dev/null
  34. (
  35. cd testdir || { echo "cannot cd testdir!"; exit 1; }
  36. expected="HELLO\nok\n"
  37. prep; check "bzcat: dont delete src" "${bb}bzcat t2.bz2; test -f t2.bz2 && echo ok"
  38. )
  39. rm -rf testdir