Debian Codegraph @

tests/Tester

raw
1 #! /bin/sh
2 # Copyright (C) 2011 Mikolaj Izdebski
3
4 set -e -C
5 IFS=' '' ''
6 '
7
8 test -r "$1"
9
10 # Try limiting virtual memory usage to 1 GiB. This can save users of systems
11 # with memory overcommit enabled and no ulimit set.
12 ulimit -v $(expr 1024 \* 1024) || :
13
14 # Unset variables that may affect behavior of lbzip2.
15 # (Some shells don't like unsetting variables that are not set.)
16 LBZIP2= unset LBZIP2
17 BZIP2= unset BZIP2
18 BZIP= unset BZIP
19
20 # Create temp files in current working directory.
21 bn=$(echo "$1" | sed 's@^\(.*/\)*\([^/.][^/.]*\)\.[^/]*$@\2@')
22 r1=tmp.$bn.1.$$
23 r2=tmp.$bn.2.$$
24
25 # Run decompressors, temporarly disabling error checking.
26 set +e
27 ./timeout ./minbzcat <"$1" >$r1 2>/dev/null; rc1=$?
28 ./timeout ../src/lbzip2 -dcqn4 <"$1" >$r2 2>/dev/null; rc2=$?
29 set -e
30
31 # Make sure none of decompressors crashed (exit code >= 128)
32 test $rc1 -lt 128 -a $rc2 -lt 128
33
34 # bad - bad bz2 file according to lbzip2
35 # xbad - bad bz2 file according to minbzcat (expected bad)
36 test $rc1 = 0 && xbad= || xbad=1
37 test $rc2 = 0 && bad= || bad=1
38
39 # pdksh needs whitespace between the two left parentheses.
40 # dash builtin test needs this redundand quoting before $bad and $xbad,
41 # see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598238
42 ( (test $xbad && test $bad) || (test ! ''$xbad && test ! ''$bad &&
43 cmp $r1 $r2 2>/dev/null)) && rc= || rc=1
44
45 rm -f $r1 $r2
46 exit $rc