blob: ca0a4580087b0e8ec5fa1c474d8a772ae86c3f9c [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
17cd temp
18
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
34testing "unzip (bad archive)" "uudecode; unzip bad.zip 2>&1; echo \$?" \
35"Archive: bad.zip
36 inflating: ]3j½r«IK-%Ix
37unzip: inflate error
381
39" \
40"" "\
41begin-base64 644 bad.zip
42UEsDBBQAAgkIAAAAIQA5AAAANwAAADwAAAAQAAcAXTNqwr1ywqtJGxJLLSVJ
43eCkBD0AdKBk8JzQsIj01JC0/ORJQSwMEFAECCAAAAAAhADoAAAAPAAAANgAA
44AAwAAQASw73Ct1DCokohPXQiNjoUNTUiHRwgLT4WHlBLAQIQABQAAggIAAAA
45oQA5AAAANwAAADwAAAAQQAcADAAAACwAMgCAAAAAAABdM2rCvXLCq0kbEkst
46JUl4KQEPQB0oGSY4Cz4QNgEnJSYIPVBLAQIAABQAAggAAAAAIQAqAAAADwAA
47BDYAAAAMAAEADQAAADIADQAAAEEAAAASw73Ct1DKokohPXQiNzA+FAI1HCcW
48NzITNFBLBQUKAC4JAA04Cw0EOhZQSwUGAQAABAIAAgCZAAAAeQAAAAIALhM=
49====
50"
51
52rm *
53
Rob Landley641c3532006-06-24 22:55:13 +000054# Clean up scratch directory.
55
56cd ..
57rm -rf temp
58
59exit $FAILCOUNT