4b2c8cd40db5f3babe4b110b134210a9b88fa4c8
[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 # ensure that top_builddir  are absolute
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
13 top_builddir=`cd $top_builddir; pwd`
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 # ensure that top_srcdir is absolute
17 top_srcdir=`cd $top_srcdir; pwd`
18
19 STAT_CONFIG_PATH=$top_srcdir/config
20 export STAT_CONFIG_PATH
21
22
23 cleanup()
24 {
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="create program"
58 cat > $TESTFILE <<EOF
59 DATA LIST LIST NOTABLE / X * variable001 * variable002 * variable003 * .
60 BEGIN DATA.
61     1.00     1.00    1.0     2.00
62     1.00     1.00    2.0    30.00
63     1.00     2.00    1.0     8.00
64     1.00     2.00    2.0    20.00
65     2.00     1.00    1.0     2.00
66     2.00     1.00    2.0    22.00
67     2.00     2.00    1.0     1.00
68     2.00     2.00    2.0     3.00
69 END DATA.
70
71 SAVE /OUTFILE='$TEMPDIR/foo.sav'
72      /VERSION=2
73      .
74
75 GET /FILE='$TEMPDIR/foo.sav'.
76
77 LIST.
78
79 EOF
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82 activity="run program"
83 $SUPERVISOR $PSPP --testing-mode $TESTFILE
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="check file exists"
87 ls -l $TEMPDIR/foo.sav > /dev/null
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90 # Ensure that the written file has no long name table
91 activity="check sysfile type"
92 grep  'X=X' $TEMPDIR/foo.sav
93 if [ $? -eq 0 ] ; then fail ; fi
94
95 activity="compare output"
96 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
97 diff -b  -w $TEMPDIR/pspp.list - << EOF
98        x variable variab_a variab_b
99 -------- -------- -------- --------
100     1.00     1.00     1.00     2.00 
101     1.00     1.00     2.00    30.00 
102     1.00     2.00     1.00     8.00 
103     1.00     2.00     2.00    20.00 
104     2.00     1.00     1.00     2.00 
105     2.00     1.00     2.00    22.00 
106     2.00     2.00     1.00     1.00 
107     2.00     2.00     2.00     3.00 
108 EOF
109 if [ $? -ne 0 ] ; then fail ; fi
110
111 pass;