Sat Jul 30 21:54:23 2005 Ben Pfaff <blp@gnu.org>
[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 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      cd /
22      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50
51 cd $TEMPDIR
52
53 activity="create program"
54 cat > $TESTFILE <<EOF
55 DATA LIST LIST NOTABLE /LOCATION * EDITOR * SHELL * FREQ * .
56 BEGIN DATA.
57     1.00     1.00    1.0     2.00
58     1.00     1.00    2.0    30.00
59     1.00     2.00    1.0     8.00
60     1.00     2.00    2.0    20.00
61     2.00     1.00    1.0     2.00
62     2.00     1.00    2.0    22.00
63     2.00     2.00    1.0     1.00
64     2.00     2.00    2.0     3.00
65 END DATA.
66
67 SAVE /OUTFILE='$TEMPDIR/foo.sav'.
68
69 GET /FILE='$TEMPDIR/foo.sav'.
70
71 * This one's ok
72 LIST.
73
74 * But this one get rubbish
75 LIST.
76
77 EOF
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80
81 activity="run program"
82 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85
86
87
88 activity="compare output"
89 diff -b -B -w $TEMPDIR/pspp.list - << EOF
90 LOCATION   EDITOR    SHELL     FREQ
91  -------- -------- -------- --------
92      1.00     1.00     1.00     2.00 
93      1.00     1.00     2.00    30.00 
94      1.00     2.00     1.00     8.00 
95      1.00     2.00     2.00    20.00 
96      2.00     1.00     1.00     2.00 
97      2.00     1.00     2.00    22.00 
98      2.00     2.00     1.00     1.00 
99      2.00     2.00     2.00     3.00 
100  
101
102 LOCATION   EDITOR    SHELL     FREQ
103  -------- -------- -------- --------
104      1.00     1.00     1.00     2.00 
105      1.00     1.00     2.00    30.00 
106      1.00     2.00     1.00     8.00 
107      1.00     2.00     2.00    20.00 
108      2.00     1.00     1.00     2.00 
109      2.00     1.00     2.00    22.00 
110      2.00     2.00     1.00     1.00 
111      2.00     2.00     2.00     3.00 
112  
113 EOF
114 if [ $? -ne 0 ] ; then fail ; fi
115
116 pass;