3fd6d5624de03ba355f5a2fe96c9c9cf25eacf83
[pspp-builds.git] / tests / bugs / get.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused
4 # the second procedure after GET FILE to corrupt its output
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$EXEEXT
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      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create program"
62 cat > $TESTFILE <<EOF
63 DATA LIST LIST NOTABLE /LOCATION * EDITOR * SHELL * FREQ * .
64 BEGIN DATA.
65     1.00     1.00    1.0     2.00
66     1.00     1.00    2.0    30.00
67     1.00     2.00    1.0     8.00
68     1.00     2.00    2.0    20.00
69     2.00     1.00    1.0     2.00
70     2.00     1.00    2.0    22.00
71     2.00     2.00    1.0     1.00
72     2.00     2.00    2.0     3.00
73 END DATA.
74
75 SAVE /OUTFILE='$TEMPDIR/foo.sav'.
76
77 GET /FILE='$TEMPDIR/foo.sav'.
78
79 * This one's ok
80 LIST.
81
82 * But this one get rubbish
83 LIST.
84
85 EOF
86 if [ $? -ne 0 ] ; then no_result ; fi
87
88
89 activity="run program"
90 $SUPERVISOR $PSPP -o pspp.csv $TESTFILE
91 if [ $? -ne 0 ] ; then no_result ; fi
92
93
94
95
96 activity="compare output"
97 diff -c $TEMPDIR/pspp.csv - << EOF
98 Table: Data List
99 LOCATION,EDITOR,SHELL,FREQ
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
109 Table: Data List
110 LOCATION,EDITOR,SHELL,FREQ
111 1.00,1.00,1.00,2.00
112 1.00,1.00,2.00,30.00
113 1.00,2.00,1.00,8.00
114 1.00,2.00,2.00,20.00
115 2.00,1.00,1.00,2.00
116 2.00,1.00,2.00,22.00
117 2.00,2.00,1.00,1.00
118 2.00,2.00,2.00,3.00
119 EOF
120 if [ $? -ne 0 ] ; then fail ; fi
121
122 pass;