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