More ASAN_OPTIONS
[pspp] / tests / libpspp / zip.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl
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.
8 dnl
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.
13 dnl
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/>.
16 dnl
17 AT_BANNER([zip])
18
19 AT_SETUP([basic zip - unzip test])
20 AT_KEYWORDS([compression])
21 here=`pwd`
22 dir1=$here/original
23 dir2=$here/recovered
24
25 mkdir -p "$dir1"
26
27 # Generate files of differing sizes with random data in them
28 names=""
29 s=1;
30 while test $s -le 8192 ; do
31         name="$dir1/$s"
32         dd if=/dev/urandom of="$name" count=1 bs=$s 2> /dev/null
33         s=$(($s * 2));
34         bn=`basename "$name"`;
35         names="$names $bn";
36 done
37
38 ASAN_OPTIONS="$ASAN_OPTIONS:detect_odr_violation=0";export ASAN_OPTIONS
39 AT_CHECK([cd "$dir1" && zip-test w foo.zip $names])
40
41 # If zipinfo is installed, make sure it can read the zipfile.
42 if (zipinfo -v) >/dev/null 2>&1; then
43     AT_CHECK([zipinfo "$dir1/foo.zip"], [0], [ignore])
44 fi
45
46 mkdir -p "$dir2"
47 cp "$dir1/foo.zip" "$dir2"
48 cd "$dir2"
49
50 AT_CHECK([zip-test r foo.zip $names])
51
52 AT_CHECK([
53     # Compare the files to their originals
54     for f in $names; do
55      diff "$dir1/$f" "$dir2/$f";
56      if test $? -ne 0 ; then exit 1; fi;
57     done
58 ])
59 AT_CLEANUP
60
61
62 AT_SETUP([zip to pipe])
63 AT_KEYWORDS([compression])
64 here=`pwd`
65 dir1=$here/original
66 dir2=$here/recovered
67
68 mkdir -p "$dir1"
69
70 # Generate files of differing sizes with random data in them
71 names=""
72 s=1;
73 while test $s -le 8192 ; do
74         name="$dir1/$s"
75         dd if=/dev/urandom of="$name" count=1 bs=$s 2> /dev/null
76         s=$(($s * 2));
77         bn=`basename "$name"`;
78         names="$names $bn";
79 done
80
81 ASAN_OPTIONS="$ASAN_OPTIONS:detect_odr_violation=0";export ASAN_OPTIONS
82 # The pipe through "cat" below is essential because it makes the
83 # output file un-seekable.
84 AT_CHECK([cd "$dir1" && zip-test w - $names | cat > foo.zip])
85
86 # If zipinfo is installed, make sure it can read the zipfile.
87 if (zipinfo -v) >/dev/null 2>&1; then
88     AT_CHECK([zipinfo "$dir1/foo.zip"], [0], [ignore])
89 fi
90
91 mkdir -p "$dir2"
92 cp "$dir1/foo.zip" "$dir2"
93 cd "$dir2"
94
95 AT_CHECK([zip-test r foo.zip $names])
96
97 AT_CHECK([
98     # Compare the files to their originals
99     for f in $names; do
100      diff "$dir1/$f" "$dir2/$f";
101      if test $? -ne 0 ; then exit 1; fi;
102     done
103 ])
104 AT_CLEANUP