f91915b2fdca235fdb2600565dae642fb6398267
[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$EXEEXT
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      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 activity="generate data input file"
58 $PERL -e 'print pack "n", $_ foreach 0...65535' > ib-in.data
59
60 activity="write pspp syntax"
61 cat > ib-in.pspp <<'EOF'
62 SET RIB=MSBFIRST.
63 SET ERRORS=NONE.
64 SET MXWARNS=10000000.
65 SET MXERRS=10000000.
66 FILE HANDLE data/NAME='ib-in.data'/MODE=IMAGE/LRECL=2.
67 DATA LIST FILE=data/ib 1-2 (IB) pib 1-2 (PIB) pibhex 1-2 (PIBHEX).
68 COMPUTE x=$CASENUM - 1.
69 PRINT OUTFILE='ib-in.out'/x (PIBHEX4) ' ' ib pib pibhex.
70 EXECUTE.
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 activity="run program"
75 $SUPERVISOR $PSPP -o pspp.csv ib-in.pspp
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="gunzip expected results"
79 gzip -cd < $top_srcdir/tests/formats/ib-in.expected.cmp.gz > ib-in.expected.cmp
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82 activity="decompress expected results"
83 $PERL -pe "printf ' %04X ', $.-1" < ib-in.expected.cmp > ib-in.expected
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="compare output"
87 diff -u ib-in.expected ib-in.out
88 if [ $? -ne 0 ] ; then fail ; fi
89
90 pass