blob: e198dfc4bc149ba336a478a50a6cf2aec3b08b37 [file] [log] [blame]
Rob Landley641c3532006-06-24 22:55:13 +00001#!/bin/sh
2
3# Tests for unzip.
4# Copyright 2006 Rob Landley <rob@landley.net>
Denis Vlasenko0beaff82007-09-21 13:16:32 +00005# Copyright 2006 Glenn McGrath
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02006# Licensed under GPLv2, see file LICENSE in this source tree.
Rob Landley641c3532006-06-24 22:55:13 +00007
Mike Frysingercaa79402009-11-04 18:41:22 -05008. ./testing.sh
Rob Landley641c3532006-06-24 22:55:13 +00009
Denys Vlasenko1de25a62015-10-26 19:33:05 +010010# testing "test name" "commands" "expected result" "file input" "stdin"
Rob Landley641c3532006-06-24 22:55:13 +000011# 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
16mkdir temp
Denys Vlasenkoa36986b2018-05-25 17:03:46 +020017cd temp || exit $?
Rob Landley641c3532006-06-24 22:55:13 +000018
19# Create test file to work with.
20
21mkdir foo
22touch foo/bar
23zip foo.zip foo foo/bar > /dev/null
24rm -f foo/bar
25rmdir foo
26
27# Test that unzipping just foo doesn't create bar.
28testing "unzip (subdir only)" "unzip -q foo.zip foo/ && test -d foo && test ! -f foo/bar && echo yes" "yes\n" "" ""
29
30rmdir foo
31rm foo.zip
32
Denys Vlasenko1de25a62015-10-26 19:33:05 +010033# File containing some damaged encrypted stream
Denys Vlasenko14767602018-12-27 22:52:13 +010034optional FEATURE_UNZIP_CDF CONFIG_UNICODE_SUPPORT
Denys Vlasenko1de25a62015-10-26 19:33:05 +010035testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
36"Archive: bad.zip
Denys Vlasenko14767602018-12-27 22:52:13 +010037 inflating: ]3j½r«I??K-%Ix
Denys Vlasenko0ffac1c2017-01-08 14:14:19 +010038unzip: corrupted data
39unzip: inflate error
Denys Vlasenko1de25a62015-10-26 19:33:05 +0100401
41" \
42"" "\
43begin-base64 644 bad.zip
44UEsDBBQAAgkIAAAAIQA5AAAANwAAADwAAAAQAAcAXTNqwr1ywqtJGxJLLSVJ
45eCkBD0AdKBk8JzQsIj01JC0/ORJQSwMEFAECCAAAAAAhADoAAAAPAAAANgAA
46AAwAAQASw73Ct1DCokohPXQiNjoUNTUiHRwgLT4WHlBLAQIQABQAAggIAAAA
47oQA5AAAANwAAADwAAAAQQAcADAAAACwAMgCAAAAAAABdM2rCvXLCq0kbEkst
48JUl4KQEPQB0oGSY4Cz4QNgEnJSYIPVBLAQIAABQAAggAAAAAIQAqAAAADwAA
49BDYAAAAMAAEADQAAADIADQAAAEEAAAASw73Ct1DKokohPXQiNzA+FAI1HCcW
50NzITNFBLBQUKAC4JAA04Cw0EOhZQSwUGAQAABAIAAgCZAAAAeQAAAAIALhM=
51====
52"
Denys Vlasenkoe3c4db82017-01-05 11:43:53 +010053SKIP=
Denys Vlasenko1de25a62015-10-26 19:33:05 +010054
Denys Vlasenkoe09c4262018-04-19 19:29:49 +020055rm -f *
56
Denys Vlasenkoa36986b2018-05-25 17:03:46 +020057optional FEATURE_UNZIP_LZMA
58testing "unzip (archive with corrupted lzma 1)" "unzip -p ../unzip_bad_lzma_1.zip 2>&1; echo \$?" \
Denys Vlasenkoe09c4262018-04-19 19:29:49 +020059"unzip: removing leading '/' from member names
Denys Vlasenkoa36986b2018-05-25 17:03:46 +020060unzip: corrupted data
61unzip: inflate error
621
63" \
64"" ""
65SKIP=
66
67rm -f *
68
69optional FEATURE_UNZIP_LZMA
70testing "unzip (archive with corrupted lzma 2)" "unzip -p ../unzip_bad_lzma_2.zip 2>&1; echo \$?" \
71"unzip: removing leading '/' from member names
72unzip: corrupted data
Denys Vlasenkoe09c4262018-04-19 19:29:49 +020073unzip: inflate error
741
75" \
76"" ""
77SKIP=
78
79rm -f *
Denys Vlasenko1de25a62015-10-26 19:33:05 +010080
Rob Landley641c3532006-06-24 22:55:13 +000081# Clean up scratch directory.
82
83cd ..
84rm -rf temp
85
86exit $FAILCOUNT