3
0

unzip.tests 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/bin/sh
  2. # Tests for unzip.
  3. # Copyright 2006 Rob Landley <rob@landley.net>
  4. # Copyright 2006 Glenn McGrath
  5. # Licensed under GPLv2, see file LICENSE in this source tree.
  6. . ./testing.sh
  7. # testing "test name" "commands" "expected result" "file input" "stdin"
  8. # file input will be file called "input"
  9. # test can create a file "actual" instead of writing to stdout
  10. # Create a scratch directory
  11. mkdir temp
  12. cd temp || exit $?
  13. # Create test file to work with.
  14. mkdir foo
  15. touch foo/bar
  16. zip foo.zip foo foo/bar > /dev/null
  17. rm -f foo/bar
  18. rmdir foo
  19. # Test that unzipping just foo doesn't create bar.
  20. testing "unzip (subdir only)" "unzip -q foo.zip foo/ && test -d foo && test ! -f foo/bar && echo yes" "yes\n" "" ""
  21. rmdir foo
  22. rm foo.zip
  23. # File containing some damaged encrypted stream
  24. optional FEATURE_UNZIP_CDF CONFIG_UNICODE_SUPPORT
  25. testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
  26. "Archive: bad.zip
  27. inflating: ]3j½r«I??K-%Ix
  28. unzip: corrupted data
  29. unzip: inflate error
  30. 1
  31. " \
  32. "" "\
  33. begin-base64 644 bad.zip
  34. UEsDBBQAAgkIAAAAIQA5AAAANwAAADwAAAAQAAcAXTNqwr1ywqtJGxJLLSVJ
  35. eCkBD0AdKBk8JzQsIj01JC0/ORJQSwMEFAECCAAAAAAhADoAAAAPAAAANgAA
  36. AAwAAQASw73Ct1DCokohPXQiNjoUNTUiHRwgLT4WHlBLAQIQABQAAggIAAAA
  37. oQA5AAAANwAAADwAAAAQQAcADAAAACwAMgCAAAAAAABdM2rCvXLCq0kbEkst
  38. JUl4KQEPQB0oGSY4Cz4QNgEnJSYIPVBLAQIAABQAAggAAAAAIQAqAAAADwAA
  39. BDYAAAAMAAEADQAAADIADQAAAEEAAAASw73Ct1DKokohPXQiNzA+FAI1HCcW
  40. NzITNFBLBQUKAC4JAA04Cw0EOhZQSwUGAQAABAIAAgCZAAAAeQAAAAIALhM=
  41. ====
  42. "
  43. SKIP=
  44. rm -f *
  45. optional FEATURE_UNZIP_LZMA
  46. testing "unzip (archive with corrupted lzma 1)" "unzip -p ../unzip_bad_lzma_1.zip 2>&1; echo \$?" \
  47. "unzip: removing leading '/' from member names
  48. unzip: corrupted data
  49. unzip: inflate error
  50. 1
  51. " \
  52. "" ""
  53. SKIP=
  54. rm -f *
  55. optional FEATURE_UNZIP_LZMA
  56. testing "unzip (archive with corrupted lzma 2)" "unzip -p ../unzip_bad_lzma_2.zip 2>&1; echo \$?" \
  57. "unzip: removing leading '/' from member names
  58. unzip: corrupted data
  59. unzip: inflate error
  60. 1
  61. " \
  62. "" ""
  63. SKIP=
  64. rm -f *
  65. # Clean up scratch directory.
  66. cd ..
  67. rm -rf temp
  68. exit $FAILCOUNT