unzip.tests 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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
  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. testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
  25. "Archive: bad.zip
  26. inflating: ]3j½r«IK-%Ix
  27. unzip: corrupted data
  28. unzip: inflate error
  29. 1
  30. " \
  31. "" "\
  32. begin-base64 644 bad.zip
  33. UEsDBBQAAgkIAAAAIQA5AAAANwAAADwAAAAQAAcAXTNqwr1ywqtJGxJLLSVJ
  34. eCkBD0AdKBk8JzQsIj01JC0/ORJQSwMEFAECCAAAAAAhADoAAAAPAAAANgAA
  35. AAwAAQASw73Ct1DCokohPXQiNjoUNTUiHRwgLT4WHlBLAQIQABQAAggIAAAA
  36. oQA5AAAANwAAADwAAAAQQAcADAAAACwAMgCAAAAAAABdM2rCvXLCq0kbEkst
  37. JUl4KQEPQB0oGSY4Cz4QNgEnJSYIPVBLAQIAABQAAggAAAAAIQAqAAAADwAA
  38. BDYAAAAMAAEADQAAADIADQAAAEEAAAASw73Ct1DKokohPXQiNzA+FAI1HCcW
  39. NzITNFBLBQUKAC4JAA04Cw0EOhZQSwUGAQAABAIAAgCZAAAAeQAAAAIALhM=
  40. ====
  41. "
  42. rm *
  43. # Clean up scratch directory.
  44. cd ..
  45. rm -rf temp
  46. exit $FAILCOUNT