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