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