d6c3f7936a360fc29677624eecd5735e1b1ff5c4
[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 it's output
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 > $TEMPDIR/prog.sps <<EOF
53 DATA LIST LIST NOTABLE /location * editor * shell * freq * .
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
67 GET /FILE='$TEMPDIR/foo.sav'.
68
69 * This one's ok
70 LIST.
71
72 * But this one get rubbish
73 LIST.
74
75 EOF
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="run program"
79 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
80 if [ $? -ne 0 ] ; then no_result ; fi
81
82
83 activity="compare output"
84 diff -b -B -w $TEMPDIR/pspp.list - << EOF
85 LOCATION   EDITOR    SHELL     FREQ
86  -------- -------- -------- --------
87      1.00     1.00     1.00     2.00 
88      1.00     1.00     2.00    30.00 
89      1.00     2.00     1.00     8.00 
90      1.00     2.00     2.00    20.00 
91      2.00     1.00     1.00     2.00 
92      2.00     1.00     2.00    22.00 
93      2.00     2.00     1.00     1.00 
94      2.00     2.00     2.00     3.00 
95  
96
97 LOCATION   EDITOR    SHELL     FREQ
98  -------- -------- -------- --------
99      1.00     1.00     1.00     2.00 
100      1.00     1.00     2.00    30.00 
101      1.00     2.00     1.00     8.00 
102      1.00     2.00     2.00    20.00 
103      2.00     1.00     1.00     2.00 
104      2.00     1.00     2.00    22.00 
105      2.00     2.00     1.00     1.00 
106      2.00     2.00     2.00     3.00 
107  
108 EOF
109 if [ $? -ne 0 ] ; then fail ; fi
110
111 pass;