Update scripts that invoke Perl to invoke it as simply "perl" if
[pspp-builds.git] / tests / formats / legacy-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' > legacy-in.data
55
56 activity="write pspp syntax"
57 cat > legacy-in.pspp <<'EOF'
58 SET ERRORS=NONE.
59 SET MXWARNS=10000000.
60 SET MXERRS=10000000.
61 FILE HANDLE data/NAME='legacy-in.data'/MODE=IMAGE/LRECL=2.
62 DATA LIST FILE=data/n 1-2 (N) z 1-2 (z).
63 COMPUTE x=$CASENUM - 1.
64 PRINT OUTFILE='legacy-in.out'/x (PIBHEX4) ' ' N Z.
65 EXECUTE.
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69 activity="run program"
70 $SUPERVISOR $PSPP --testing-mode legacy-in.pspp
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 activity="gunzip expected results"
74 gzip -cd < $top_srcdir/tests/formats/legacy-in.expected.cmp.gz > legacy-in.expected.cmp
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="decompress expected results"
78 $PERL -pe "printf ' %04X ', $.-1" < legacy-in.expected.cmp > legacy-in.expected
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 activity="compare output"
82 diff -u legacy-in.expected legacy-in.out
83 if [ $? -ne 0 ] ; then fail ; fi
84
85 pass