c842b3399e613948104116b0a7f83e0d9f041611
[pspp-builds.git] / tests / command / sysfiles-old.sh
1 #!/bin/sh
2
3 # This program tests that system files can be read and written 
4 # without the long name tables.
5
6
7 TEMPDIR=/tmp/pspp-tst-$$
8 TESTFILE=$TEMPDIR/`basename $0`.sps
9
10 here=`pwd`;
11
12 # ensure that top_srcdir is absolute
13 cd $top_srcdir; top_srcdir=`pwd`
14
15 STAT_CONFIG_PATH=$top_srcdir/config
16 export STAT_CONFIG_PATH
17
18
19 cleanup()
20 {
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="create program"
53 cat > $TESTFILE <<EOF
54 DATA LIST LIST NOTABLE / X * variable001 * variable002 * variable003 * .
55 BEGIN DATA.
56     1.00     1.00    1.0     2.00
57     1.00     1.00    2.0    30.00
58     1.00     2.00    1.0     8.00
59     1.00     2.00    2.0    20.00
60     2.00     1.00    1.0     2.00
61     2.00     1.00    2.0    22.00
62     2.00     2.00    1.0     1.00
63     2.00     2.00    2.0     3.00
64 END DATA.
65
66 SAVE /OUTFILE='$TEMPDIR/foo.sav'
67      /VERSION=3x
68      .
69
70 GET /FILE='$TEMPDIR/foo.sav'.
71
72 LIST.
73
74 EOF
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="run program"
78 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 activity="check file exists"
82 ls -l $TEMPDIR/foo.sav > /dev/null
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85 # Ensure that the written file has no long name table
86 activity="check sysfile type"
87 grep  'X=X' $TEMPDIR/foo.sav
88 if [ $? -eq 0 ] ; then fail ; fi
89
90 activity="compare output"
91 diff -b -B -w $TEMPDIR/pspp.list - << EOF
92        X VARIABLE VARIAB_A VARIAB_B
93 -------- -------- -------- --------
94     1.00     1.00     1.00     2.00 
95     1.00     1.00     2.00    30.00 
96     1.00     2.00     1.00     8.00 
97     1.00     2.00     2.00    20.00 
98     2.00     1.00     1.00     2.00 
99     2.00     1.00     2.00    22.00 
100     2.00     2.00     1.00     1.00 
101     2.00     2.00     2.00     3.00 
102
103 EOF
104 if [ $? -ne 0 ] ; then fail ; fi
105
106 pass;