• 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_SETUP=setup
28TST_TESTFUNC=do_test
29TST_NEEDS_TMPDIR=1
30TST_NEEDS_CMDS="unzip"
31. tst_test.sh
32
33setup()
34{
35	cat > unzip_exp.out <<EOF
36Archive:  $TST_DATAROOT/test.zip
37   creating: dir/
38   creating: dir/d1/
39   creating: dir/d2/
40   creating: dir/d3/
41   creating: dir/d4/
42 extracting: dir/d1/f1
43 extracting: dir/d1/f2
44 extracting: dir/d1/f3
45   creating: dir/d2/d1/
46   creating: dir/d2/d2/
47   creating: dir/d2/d3/
48 extracting: dir/d2/f1
49 extracting: dir/d2/f2
50 extracting: dir/d2/f3
51   creating: dir/d3/d1/
52   creating: dir/d3/d2/
53   creating: dir/d3/d3/
54EOF
55}
56
57stable_ls()
58{
59	local i
60
61	for i in $(echo "$1/*" | sort); do
62
63		if ! [ -e "$i" ]; then
64			return
65		fi
66
67		echo "$i"
68
69		if [ -d "$i" ]; then
70			stable_ls "$i"
71		fi
72	done
73}
74
75do_test()
76{
77	EXPECT_PASS unzip "$TST_DATAROOT/test.zip" \> unzip.out
78
79	if diff -w unzip_exp.out unzip.out; then
80		tst_res TPASS "Unzip output is correct"
81	else
82		tst_res TFAIL "Unzip output is incorrect"
83		cat unzip.out
84	fi
85
86	stable_ls "dir" > dir.out
87
88	if diff "$TST_DATAROOT/dir.out" dir.out; then
89		tst_res TPASS "Files unzipped correctly"
90	else
91		tst_res TFAIL "Files unzipped incorrectly"
92		cat dir.out
93	fi
94
95	ROD rm -rf "dir/"
96}
97
98tst_run
99