Fix bug #21280. Thanks to John Darrington for review.
[pspp-builds.git] / tests / bugs / t-test.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused T-TEST to 
4 # crash when given invalid syntax
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 /id * a * .
60 BEGIN DATA.
61 1 3.5
62 2 2.0
63 3 2.0
64 4 3.5
65 5 3.0
66 6 4.0
67 END DATA.
68
69 T-TEST /testval=2.0 .
70 T-TEST /groups=id(3) .
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 #The syntax was invalid.  Therefore pspp must return non zero.
75 activity="run program"
76 $SUPERVISOR $PSPP --testing-mode -e /dev/null $TESTFILE 
77 if [ $? -ne 1 ] ; then fail ; fi
78
79 pass;