Replace "all-hook" with "all-local".
[pspp-builds.git] / tests / bugs / compression.sh
1 #!/bin/sh
2
3 # This program tests that compressed system files can be read and written
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13 PSPP=$top_builddir/src/ui/terminal/pspp
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
21      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
22         echo "NOT cleaning $TEMPDIR"
23         return ; 
24      fi
25      cd /
26      rm -rf $TEMPDIR
27 }
28
29
30 fail()
31 {
32     echo $activity
33     echo FAILED
34     cleanup;
35     exit 1;
36 }
37
38
39 no_result()
40 {
41     echo $activity
42     echo NO RESULT;
43     cleanup;
44     exit 2;
45 }
46
47 pass()
48 {
49     cleanup;
50     exit 0;
51 }
52
53 mkdir -p $TEMPDIR
54
55 cd $TEMPDIR
56
57 cat > $TESTFILE <<EOF
58 DATA LIST LIST /x * y (a200).
59 BEGIN DATA.
60 1.2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
61 .   yyyyyyyyyyyyyyy
62 0   ddddddddddddddddddddddddddddddd
63 101 z
64 END DATA.
65
66 SAVE OUTFILE='$TEMPDIR/com.sav' /COMPRESS .
67
68 GET FILE='$TEMPDIR/com.sav'.
69
70 LIST.
71
72 EOF
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75
76 activity="run program"
77 $SUPERVISOR $PSPP --testing-mode $TESTFILE
78 if [ $? -ne 0 ] ; then fail ; fi
79
80 # Make sure the file really was compressed
81 activity="inspect system file"
82 dd if=$TEMPDIR/com.sav bs=1 skip=72 count=4 2> /dev/null | od > $TEMPDIR/file
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85 activity="check compression setting"
86 # Big-endian?
87 diff -b $TEMPDIR/file - > /dev/null <<EOF
88 0000000 000000 000001
89 0000004
90 EOF
91 if [ $? -ne 0 ] ; then pass ; fi
92 # Little-endian?
93 diff -b $TEMPDIR/file - > /dev/null <<EOF
94 0000000 000001 000000
95 0000004
96 EOF
97 if [ $? -ne 0 ] ; then pass ; fi
98 # Otherwise error.
99 cat $TEMPDIR/file
100 fail