246fc0924f7ff8d07147c68f2a9c253cb634fae1
[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 export STAT_CONFIG_PATH=$top_srcdir/config
16
17
18 cleanup()
19 {
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create program"
52 cat > $TESTFILE <<EOF
53 DATA LIST LIST NOTABLE / X * variable001 * variable002 * variable003 * .
54 BEGIN DATA.
55     1.00     1.00    1.0     2.00
56     1.00     1.00    2.0    30.00
57     1.00     2.00    1.0     8.00
58     1.00     2.00    2.0    20.00
59     2.00     1.00    1.0     2.00
60     2.00     1.00    2.0    22.00
61     2.00     2.00    1.0     1.00
62     2.00     2.00    2.0     3.00
63 END DATA.
64
65 SAVE /OUTFILE='$TEMPDIR/foo.sav'
66      /VERSION=3x
67      .
68
69 GET /FILE='$TEMPDIR/foo.sav'.
70
71 LIST.
72
73 EOF
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76 activity="run program"
77 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 activity="check file exists"
81 ls -l $TEMPDIR/foo.sav > /dev/null
82 if [ $? -ne 0 ] ; then no_result ; fi
83
84 # Ensure that the written file has no long name table
85 activity="check sysfile type"
86 grep  'X=X' $TEMPDIR/foo.sav
87 if [ $? -eq 0 ] ; then fail ; fi
88
89 activity="compare output"
90 diff -b -B -w $TEMPDIR/pspp.list - << EOF
91        X VARIABLE VARIAB_A VARIAB_B
92 -------- -------- -------- --------
93     1.00     1.00     1.00     2.00 
94     1.00     1.00     2.00    30.00 
95     1.00     2.00     1.00     8.00 
96     1.00     2.00     2.00    20.00 
97     2.00     1.00     1.00     2.00 
98     2.00     1.00     2.00    22.00 
99     2.00     2.00     1.00     1.00 
100     2.00     2.00     2.00     3.00 
101
102 EOF
103 if [ $? -ne 0 ] ; then fail ; fi
104
105 pass;