Rob Landley | 641c353 | 2006-06-24 22:55:13 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Tests for unzip. |
| 4 | # Copyright 2006 Rob Landley <rob@landley.net> |
Denis Vlasenko | 0beaff8 | 2007-09-21 13:16:32 +0000 | [diff] [blame] | 5 | # Copyright 2006 Glenn McGrath |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 6 | # Licensed under GPLv2, see file LICENSE in this source tree. |
Rob Landley | 641c353 | 2006-06-24 22:55:13 +0000 | [diff] [blame] | 7 | |
Mike Frysinger | caa7940 | 2009-11-04 18:41:22 -0500 | [diff] [blame] | 8 | . ./testing.sh |
Rob Landley | 641c353 | 2006-06-24 22:55:13 +0000 | [diff] [blame] | 9 | |
Denys Vlasenko | 1de25a6 | 2015-10-26 19:33:05 +0100 | [diff] [blame] | 10 | # testing "test name" "commands" "expected result" "file input" "stdin" |
Rob Landley | 641c353 | 2006-06-24 22:55:13 +0000 | [diff] [blame] | 11 | # file input will be file called "input" |
| 12 | # test can create a file "actual" instead of writing to stdout |
| 13 | |
| 14 | # Create a scratch directory |
| 15 | |
| 16 | mkdir temp |
Denys Vlasenko | a36986b | 2018-05-25 17:03:46 +0200 | [diff] [blame] | 17 | cd temp || exit $? |
Rob Landley | 641c353 | 2006-06-24 22:55:13 +0000 | [diff] [blame] | 18 | |
| 19 | # Create test file to work with. |
| 20 | |
| 21 | mkdir foo |
| 22 | touch foo/bar |
| 23 | zip foo.zip foo foo/bar > /dev/null |
| 24 | rm -f foo/bar |
| 25 | rmdir foo |
| 26 | |
| 27 | # Test that unzipping just foo doesn't create bar. |
| 28 | testing "unzip (subdir only)" "unzip -q foo.zip foo/ && test -d foo && test ! -f foo/bar && echo yes" "yes\n" "" "" |
| 29 | |
| 30 | rmdir foo |
| 31 | rm foo.zip |
| 32 | |
Denys Vlasenko | 1de25a6 | 2015-10-26 19:33:05 +0100 | [diff] [blame] | 33 | # File containing some damaged encrypted stream |
Denys Vlasenko | 1476760 | 2018-12-27 22:52:13 +0100 | [diff] [blame] | 34 | optional FEATURE_UNZIP_CDF CONFIG_UNICODE_SUPPORT |
Denys Vlasenko | 1de25a6 | 2015-10-26 19:33:05 +0100 | [diff] [blame] | 35 | testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \ |
| 36 | "Archive: bad.zip |
Denys Vlasenko | 1476760 | 2018-12-27 22:52:13 +0100 | [diff] [blame] | 37 | inflating: ]3j½r«I??K-%Ix |
Denys Vlasenko | 0ffac1c | 2017-01-08 14:14:19 +0100 | [diff] [blame] | 38 | unzip: corrupted data |
| 39 | unzip: inflate error |
Denys Vlasenko | 1de25a6 | 2015-10-26 19:33:05 +0100 | [diff] [blame] | 40 | 1 |
| 41 | " \ |
| 42 | "" "\ |
| 43 | begin-base64 644 bad.zip |
| 44 | UEsDBBQAAgkIAAAAIQA5AAAANwAAADwAAAAQAAcAXTNqwr1ywqtJGxJLLSVJ |
| 45 | eCkBD0AdKBk8JzQsIj01JC0/ORJQSwMEFAECCAAAAAAhADoAAAAPAAAANgAA |
| 46 | AAwAAQASw73Ct1DCokohPXQiNjoUNTUiHRwgLT4WHlBLAQIQABQAAggIAAAA |
| 47 | oQA5AAAANwAAADwAAAAQQAcADAAAACwAMgCAAAAAAABdM2rCvXLCq0kbEkst |
| 48 | JUl4KQEPQB0oGSY4Cz4QNgEnJSYIPVBLAQIAABQAAggAAAAAIQAqAAAADwAA |
| 49 | BDYAAAAMAAEADQAAADIADQAAAEEAAAASw73Ct1DKokohPXQiNzA+FAI1HCcW |
| 50 | NzITNFBLBQUKAC4JAA04Cw0EOhZQSwUGAQAABAIAAgCZAAAAeQAAAAIALhM= |
| 51 | ==== |
| 52 | " |
Denys Vlasenko | e3c4db8 | 2017-01-05 11:43:53 +0100 | [diff] [blame] | 53 | SKIP= |
Denys Vlasenko | 1de25a6 | 2015-10-26 19:33:05 +0100 | [diff] [blame] | 54 | |
Denys Vlasenko | e09c426 | 2018-04-19 19:29:49 +0200 | [diff] [blame] | 55 | rm -f * |
| 56 | |
Denys Vlasenko | a36986b | 2018-05-25 17:03:46 +0200 | [diff] [blame] | 57 | optional FEATURE_UNZIP_LZMA |
| 58 | testing "unzip (archive with corrupted lzma 1)" "unzip -p ../unzip_bad_lzma_1.zip 2>&1; echo \$?" \ |
Denys Vlasenko | e09c426 | 2018-04-19 19:29:49 +0200 | [diff] [blame] | 59 | "unzip: removing leading '/' from member names |
Denys Vlasenko | a36986b | 2018-05-25 17:03:46 +0200 | [diff] [blame] | 60 | unzip: corrupted data |
| 61 | unzip: inflate error |
| 62 | 1 |
| 63 | " \ |
| 64 | "" "" |
| 65 | SKIP= |
| 66 | |
| 67 | rm -f * |
| 68 | |
| 69 | optional FEATURE_UNZIP_LZMA |
| 70 | testing "unzip (archive with corrupted lzma 2)" "unzip -p ../unzip_bad_lzma_2.zip 2>&1; echo \$?" \ |
| 71 | "unzip: removing leading '/' from member names |
| 72 | unzip: corrupted data |
Denys Vlasenko | e09c426 | 2018-04-19 19:29:49 +0200 | [diff] [blame] | 73 | unzip: inflate error |
| 74 | 1 |
| 75 | " \ |
| 76 | "" "" |
| 77 | SKIP= |
| 78 | |
| 79 | rm -f * |
Denys Vlasenko | 1de25a6 | 2015-10-26 19:33:05 +0100 | [diff] [blame] | 80 | |
Rob Landley | 641c353 | 2006-06-24 22:55:13 +0000 | [diff] [blame] | 81 | # Clean up scratch directory. |
| 82 | |
| 83 | cd .. |
| 84 | rm -rf temp |
| 85 | |
| 86 | exit $FAILCOUNT |