unzip.tests 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. optional FEATURE_UNZIP_CDF
  25. testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
  26. "Archive: bad.zip
  27. inflating: ]3j½r«IK-%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 *
  45. # Clean up scratch directory.
  46. cd ..
  47. rm -rf temp
  48. exit $FAILCOUNT