• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/sh
2################################################################################
3##                                                                            ##
4## Copyright (c) International Business Machines  Corp., 2001                 ##
5##  Author:        Manoj Iyer, manjo@mail.utexas.edu                          ##
6## Copyright (c) Cyril Hrubis <chrubis@suse.cz>                               ##
7##                                                                            ##
8## This program is free software;  you can redistribute it and#or modify      ##
9## it under the terms of the GNU General Public License as published by       ##
10## the Free Software Foundation; either version 2 of the License, or          ##
11## (at your option) any later version.                                        ##
12##                                                                            ##
13## This program is distributed in the hope that it will be useful, but        ##
14## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
15## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
16## for more details.                                                          ##
17##                                                                            ##
18## You should have received a copy of the GNU General Public License          ##
19## along with this program;  if not, write to the Free Software Foundation,   ##
20## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
21##                                                                            ##
22################################################################################
23#
24# Tests basic functionality of unzip command.
25#
26
27TST_ID="unzip01"
28TST_SETUP=setup
29TST_TESTFUNC=do_test
30TST_NEEDS_TMPDIR=1
31TST_NEEDS_CMDS="unzip"
32. tst_test.sh
33
34setup()
35{
36	cat > unzip_exp.out <<EOF
37Archive:  $TST_DATAROOT/test.zip
38   creating: dir/
39   creating: dir/d1/
40   creating: dir/d2/
41   creating: dir/d3/
42   creating: dir/d4/
43 extracting: dir/d1/f1
44 extracting: dir/d1/f2
45 extracting: dir/d1/f3
46   creating: dir/d2/d1/
47   creating: dir/d2/d2/
48   creating: dir/d2/d3/
49 extracting: dir/d2/f1
50 extracting: dir/d2/f2
51 extracting: dir/d2/f3
52   creating: dir/d3/d1/
53   creating: dir/d3/d2/
54   creating: dir/d3/d3/
55EOF
56}
57
58stable_ls()
59{
60	local i
61
62	for i in $(echo "$1/*" | sort); do
63
64		if ! [ -e "$i" ]; then
65			return
66		fi
67
68		echo "$i"
69
70		if [ -d "$i" ]; then
71			stable_ls "$i"
72		fi
73	done
74}
75
76do_test()
77{
78	EXPECT_PASS unzip "$TST_DATAROOT/test.zip" \> unzip.out
79
80	if diff -w unzip_exp.out unzip.out; then
81		tst_res TPASS "Unzip output is correct"
82	else
83		tst_res TFAIL "Unzip output is incorrect"
84		cat unzip.out
85	fi
86
87	stable_ls "dir" > dir.out
88
89	if diff "$TST_DATAROOT/dir.out" dir.out; then
90		tst_res TPASS "Files unzipped correctly"
91	else
92		tst_res TFAIL "Files unzipped incorrectly"
93		cat dir.out
94	fi
95
96	ROD rm -rf "dir/"
97}
98
99tst_run
100