2006-06-25 04:25:13 +05:30
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
# Tests for unzip.
|
|
|
|
|
# Copyright 2006 Rob Landley <rob@landley.net>
|
2007-09-21 18:46:32 +05:30
|
|
|
|
# Copyright 2006 Glenn McGrath
|
2010-08-16 23:44:46 +05:30
|
|
|
|
# Licensed under GPLv2, see file LICENSE in this source tree.
|
2006-06-25 04:25:13 +05:30
|
|
|
|
|
2009-11-05 05:11:22 +05:30
|
|
|
|
. ./testing.sh
|
2006-06-25 04:25:13 +05:30
|
|
|
|
|
2015-10-27 00:03:05 +05:30
|
|
|
|
# testing "test name" "commands" "expected result" "file input" "stdin"
|
2006-06-25 04:25:13 +05:30
|
|
|
|
# file input will be file called "input"
|
|
|
|
|
# test can create a file "actual" instead of writing to stdout
|
|
|
|
|
|
|
|
|
|
# Create a scratch directory
|
|
|
|
|
|
|
|
|
|
mkdir temp
|
2018-04-19 22:59:49 +05:30
|
|
|
|
cd temp || exit 90
|
2006-06-25 04:25:13 +05:30
|
|
|
|
|
|
|
|
|
# Create test file to work with.
|
|
|
|
|
|
|
|
|
|
mkdir foo
|
|
|
|
|
touch foo/bar
|
|
|
|
|
zip foo.zip foo foo/bar > /dev/null
|
|
|
|
|
rm -f foo/bar
|
|
|
|
|
rmdir foo
|
|
|
|
|
|
|
|
|
|
# Test that unzipping just foo doesn't create bar.
|
|
|
|
|
testing "unzip (subdir only)" "unzip -q foo.zip foo/ && test -d foo && test ! -f foo/bar && echo yes" "yes\n" "" ""
|
|
|
|
|
|
|
|
|
|
rmdir foo
|
|
|
|
|
rm foo.zip
|
|
|
|
|
|
2015-10-27 00:03:05 +05:30
|
|
|
|
# File containing some damaged encrypted stream
|
2017-01-05 16:13:53 +05:30
|
|
|
|
optional FEATURE_UNZIP_CDF
|
2015-10-27 00:03:05 +05:30
|
|
|
|
testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
|
|
|
|
|
"Archive: bad.zip
|
2017-01-08 18:44:19 +05:30
|
|
|
|
inflating: ]3j½r«IK-%Ix
|
|
|
|
|
unzip: corrupted data
|
|
|
|
|
unzip: inflate error
|
2015-10-27 00:03:05 +05:30
|
|
|
|
1
|
|
|
|
|
" \
|
|
|
|
|
"" "\
|
|
|
|
|
begin-base64 644 bad.zip
|
|
|
|
|
UEsDBBQAAgkIAAAAIQA5AAAANwAAADwAAAAQAAcAXTNqwr1ywqtJGxJLLSVJ
|
|
|
|
|
eCkBD0AdKBk8JzQsIj01JC0/ORJQSwMEFAECCAAAAAAhADoAAAAPAAAANgAA
|
|
|
|
|
AAwAAQASw73Ct1DCokohPXQiNjoUNTUiHRwgLT4WHlBLAQIQABQAAggIAAAA
|
|
|
|
|
oQA5AAAANwAAADwAAAAQQAcADAAAACwAMgCAAAAAAABdM2rCvXLCq0kbEkst
|
|
|
|
|
JUl4KQEPQB0oGSY4Cz4QNgEnJSYIPVBLAQIAABQAAggAAAAAIQAqAAAADwAA
|
|
|
|
|
BDYAAAAMAAEADQAAADIADQAAAEEAAAASw73Ct1DKokohPXQiNzA+FAI1HCcW
|
|
|
|
|
NzITNFBLBQUKAC4JAA04Cw0EOhZQSwUGAQAABAIAAgCZAAAAeQAAAAIALhM=
|
|
|
|
|
====
|
|
|
|
|
"
|
2017-01-05 16:13:53 +05:30
|
|
|
|
SKIP=
|
2015-10-27 00:03:05 +05:30
|
|
|
|
|
2018-04-19 22:59:49 +05:30
|
|
|
|
rm -f *
|
|
|
|
|
|
|
|
|
|
optional CONFIG_FEATURE_UNZIP_LZMA
|
|
|
|
|
testing "unzip (archive with corrupted lzma)" "unzip -p ../unzip_bad_lzma_1.zip 2>&1; echo \$?" \
|
|
|
|
|
"unzip: removing leading '/' from member names
|
|
|
|
|
unzip: inflate error
|
|
|
|
|
1
|
|
|
|
|
" \
|
|
|
|
|
"" ""
|
|
|
|
|
SKIP=
|
|
|
|
|
|
|
|
|
|
rm -f *
|
2015-10-27 00:03:05 +05:30
|
|
|
|
|
2006-06-25 04:25:13 +05:30
|
|
|
|
# Clean up scratch directory.
|
|
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
|
rm -rf temp
|
|
|
|
|
|
|
|
|
|
exit $FAILCOUNT
|