2 ################################################################################
4 ## Copyright (c) International Business Machines Corp., 2001 ##
6 ## This program is free software; you can redistribute it and#or modify ##
7 ## it under the terms of the GNU General Public License as published by ##
8 ## the Free Software Foundation; either version 2 of the License, or ##
9 ## (at your option) any later version. ##
11 ## This program is distributed in the hope that it will be useful, but ##
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
13 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
14 ## for more details. ##
16 ## You should have received a copy of the GNU General Public License ##
17 ## along with this program; if not, write to the Free Software ##
18 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ##
20 ################################################################################
22 # File : unzip_tests.sh
24 # Description: Test Basic functionality of unzip command. Pass in the zip
27 # Author: Manoj Iyer, manjo@mail.utexas.edu
29 # History: Mar 03 2003 - Created - Manoj Iyer.
34 LTPBIN
=${LTPROOT:-$PWD}/testcases
/bin
36 # Function: chk_ifexists
38 # Description: - Check if command required for this test exits.
40 # Input: - $1 - calling test case.
41 # - $2 - command that needs to be checked.
43 # Return: - zero on success.
44 # - non-zero on failure.
49 which $2 > "$PWD/tst_unzip.err" || RC
=$?
52 tst_brkm TBROK NULL
"$1: command $2 not found."
60 # Description: - remove temporaty files and directories.
62 # Return: - zero on success.
63 # - non-zero on failure.
66 # remove all the temporary files created by this test.
67 tst_resm TINFO
"CLEAN: removing \"$LTPTMP\""
74 # Description: - Check if command required for this test exits.
75 # - Create temporary directories required for this test.
76 # - Initialize global variables.
78 # Return: - zero on success.
79 # - non-zero on failure.
82 # Initialize global variables.
88 # Inititalize cleanup function.
90 # create the temporary directory used by this testcase
91 LTPTMP
=`mktemp -d -t $$.XXXXXX` || tst_resm TBROK
"Unable to create temporary directory with: mktemp -d $$.XXXXXX"
94 # check if commands tst_*, unzip, awk, etc exists.
95 chk_ifexists INIT tst_resm ||
return $RC
96 chk_ifexists INIT
unzip ||
return $RC
97 chk_ifexists INIT mkdir ||
return $RC
98 chk_ifexists INIT
awk ||
return $RC
100 # create expected output files. tst_unzip.exp
101 cat > $LTPTMP/tst_unzip.out.exp
<<-EOF
102 Archive: $LTPBIN/tst_unzip_file.zip
103 creating: tmp/tst_unzip.dir/
104 creating: tmp/tst_unzip.dir/d.0/
105 extracting: tmp/tst_unzip.dir/d.0/f.0
106 extracting: tmp/tst_unzip.dir/d.0/f.1
107 extracting: tmp/tst_unzip.dir/d.0/f.2
108 creating: tmp/tst_unzip.dir/d.0/d.1/
109 extracting: tmp/tst_unzip.dir/d.0/d.1/f.0
110 extracting: tmp/tst_unzip.dir/d.0/d.1/f.1
111 extracting: tmp/tst_unzip.dir/d.0/d.1/f.2
112 creating: tmp/tst_unzip.dir/d.0/d.1/d.2/
113 extracting: tmp/tst_unzip.dir/d.0/d.1/d.2/f.0
114 extracting: tmp/tst_unzip.dir/d.0/d.1/d.2/f.1
115 extracting: tmp/tst_unzip.dir/d.0/d.1/d.2/f.2
124 # Description: - Test that unzip can uncompress .zip file correctly.
125 # - Execute unzip command on a .zip file, save output to file.
126 # - If unzip exits with a non-zero value or, the expected output
127 # is different from actual output, test fails.
129 # Return: - zero on success.
130 # - non-zero on failure.
141 tst_resm TINFO
"Test #1: unzip command un-compresses a .zip file."
143 ( cd $LTPTMP; unzip "$zipfile" > "$LTPTMP/tst_unzip.out") || RC
=$?
146 tst_res TFAIL
"$PWD/tst_unzip.out" \
147 "Test #1: unzip command failed. Return value = $RC. Details:"
150 sort -o "$PWD/tst_unzip.out" "$PWD/tst_unzip.out"
151 sort -o "$PWD/tst_unzip.out.exp" "$PWD/tst_unzip.out.exp"
153 diff -iwB "$PWD/tst_unzip.out" "$PWD/tst_unzip.out.exp" >\
154 "$PWD/tst_unzip.out.err" || RC
=$?
158 tst_res TFAIL
"$PWD/tst_unzip.out.err" \
159 "Test #1: unzip output differs from expected output. Details"
161 tst_resm TINFO
"Test #1: check if $LTPTMP/tmp/tst_unzip.dir exits."
162 if ! [ -d $LTPTMP/tmp
/tst_unzip.dir
]
165 "Test #1: unzip did not uncompress the .zip file"
169 "Test #1: $LTPTMP/tmp/tst_unzip.dir was created by unzip"
171 "Test #1: unzip can uncompress .zip file correctly."
181 # Description: - Execute all tests and report results.
183 # Exit: - zero on success
184 # - non-zero on failure.