1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
19 AT_SETUP([basic zip - unzip test])
20 AT_KEYWORDS([compression])
27 # Generate files of differing sizes with random data in them
30 while test $s -le 8192 ; do
32 dd if=/dev/urandom of="$name" count=1 bs=$s 2> /dev/null
34 bn=`basename "$name"`;
38 AT_CHECK([cd "$dir1" && zip-test w foo.zip $names])
40 # If zipinfo is installed, make sure it can read the zipfile.
41 if (zipinfo -v) >/dev/null 2>&1; then
42 AT_CHECK([zipinfo "$dir1/foo.zip"], [0], [ignore])
46 cp "$dir1/foo.zip" "$dir2"
49 AT_CHECK([zip-test r foo.zip $names])
52 # Compare the files to their originals
54 diff "$dir1/$f" "$dir2/$f";
55 if test $? -ne 0 ; then exit 1; fi;
60 AT_SETUP([zip - detect corruption on unzip])
61 AT_KEYWORDS([compression])
64 AT_DATA([data.txt], [xyzzy
66 AT_CHECK([zip-test w ../foo.zip data.txt])
71 AT_CHECK([zip-test r ../foo.zip data.txt])
72 AT_CHECK([cat data.txt], [0], [xyzzy
78 sed 's/xyzzy/XYZZY/' < ../foo.zip > ../corrupted.zip
79 AT_CHECK([zip-test r ../corrupted.zip data.txt], [1], [], [dnl
80 Unzip failed: ../corrupted.zip: corrupt archive reading member "data.txt": bad CRC 0x2a2bcd20 (expected e1bd2a6e)
84 AT_SETUP([zip to pipe])
85 AT_KEYWORDS([compression])
92 # Generate files of differing sizes with random data in them
95 while test $s -le 8192 ; do
97 dd if=/dev/urandom of="$name" count=1 bs=$s 2> /dev/null
99 bn=`basename "$name"`;
103 # The pipe through "cat" below is essential because it makes the
104 # output file un-seekable.
105 AT_CHECK([cd "$dir1" && zip-test w - $names | cat > foo.zip])
107 # If zipinfo is installed, make sure it can read the zipfile.
108 if (zipinfo -v) >/dev/null 2>&1; then
109 AT_CHECK([zipinfo "$dir1/foo.zip"], [0], [ignore])
113 cp "$dir1/foo.zip" "$dir2"
116 AT_CHECK([zip-test r foo.zip $names])
119 # Compare the files to their originals
121 diff "$dir1/$f" "$dir2/$f";
122 if test $? -ne 0 ; then exit 1; fi;