* bugs/compression.sh: Don't fail on big-endian system. Partial
[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 export STAT_CONFIG_PATH=$top_srcdir/config
16
17
18 cleanup()
19 {
20      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
21         echo "NOT cleaning $TEMPDIR"
22         return ; 
23      fi
24      rm -rf $TEMPDIR
25 }
26
27
28 fail()
29 {
30     echo $activity
31     echo FAILED
32     cleanup;
33     exit 1;
34 }
35
36
37 no_result()
38 {
39     echo $activity
40     echo NO RESULT;
41     cleanup;
42     exit 2;
43 }
44
45 pass()
46 {
47     cleanup;
48     exit 0;
49 }
50
51 mkdir -p $TEMPDIR
52
53 cd $TEMPDIR
54
55 cat > $TESTFILE <<EOF
56 DATA LIST LIST /x * y (a200).
57 BEGIN DATA.
58 1.2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
59 .   yyyyyyyyyyyyyyy
60 0   ddddddddddddddddddddddddddddddd
61 101 z
62 END DATA.
63
64 SAVE OUTFILE='$TEMPDIR/com.sav' /COMPRESS .
65
66 GET FILE='$TEMPDIR/com.sav'.
67
68 LIST.
69
70 EOF
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73
74 activity="run program"
75 $SUPERVISOR $PSPP --testing-mode $TESTFILE
76 if [ $? -ne 0 ] ; then fail ; fi
77
78 # Make sure the file really was compressed
79 activity="inspect system file"
80 dd if=$TEMPDIR/com.sav bs=1 skip=72 count=4 2> /dev/null | od > $TEMPDIR/file
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83 activity="check compression setting"
84 # Big-endian?
85 diff -b $TEMPDIR/file - > /dev/null <<EOF
86 0000000 000000 000001
87 0000004
88 EOF
89 if [ $? -ne 0 ] ; then pass ; fi
90 # Little-endian?
91 diff -b $TEMPDIR/file - > /dev/null <<EOF
92 0000000 000001 000000
93 0000004
94 EOF
95 if [ $? -ne 0 ] ; then pass ; fi
96 # Otherwise error.
97 cat $TEMPDIR/file
98 fail