Update scripts that invoke Perl to invoke it as simply "perl" if
[pspp-builds.git] / tests / formats / ib-in.sh
1 #! /bin/sh
2
3 TEMPDIR=/tmp/pspp-tst-$$
4
5 # ensure that top_builddir  are absolute
6 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
7 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
8 top_builddir=`cd $top_builddir; pwd`
9 PSPP=$top_builddir/src/ui/terminal/pspp
10 : ${PERL:=perl}
11
12 # ensure that top_srcdir is absolute
13 top_srcdir=`cd $top_srcdir; pwd`
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
21      cd /
22      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50
51 cd $TEMPDIR
52
53 activity="generate data input file"
54 $PERL -e 'print pack "n", $_ foreach 0...65535' > ib-in.data
55
56 activity="write pspp syntax"
57 cat > ib-in.pspp <<'EOF'
58 SET RIB=MSBFIRST.
59 SET ERRORS=NONE.
60 SET MXWARNS=10000000.
61 SET MXERRS=10000000.
62 FILE HANDLE data/NAME='ib-in.data'/MODE=IMAGE/LRECL=2.
63 DATA LIST FILE=data/ib 1-2 (IB) pib 1-2 (PIB) pibhex 1-2 (PIBHEX).
64 COMPUTE x=$CASENUM - 1.
65 PRINT OUTFILE='ib-in.out'/x (PIBHEX4) ' ' ib pib pibhex.
66 EXECUTE.
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 activity="run program"
71 $SUPERVISOR $PSPP --testing-mode ib-in.pspp
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 activity="gunzip expected results"
75 gzip -cd < $top_srcdir/tests/formats/ib-in.expected.cmp.gz > ib-in.expected.cmp
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="decompress expected results"
79 $PERL -pe "printf ' %04X ', $.-1" < ib-in.expected.cmp > ib-in.expected
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82 activity="compare output"
83 diff -u ib-in.expected ib-in.out
84 if [ $? -ne 0 ] ; then fail ; fi
85
86 pass