86cb7f10b6f00ae0c2d00fe2fa3831772457f3ea
[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 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 /id * a * .
56 BEGIN DATA.
57 1 3.5
58 2 2.0
59 3 2.0
60 4 3.5
61 5 3.0
62 6 4.0
63 END DATA.
64
65 T-TEST /testval=2.0 .
66 T-TEST /groups=id(3) .
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 #The syntax was invalid.  Therefore pspp must return non zero.
71 activity="run program"
72 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE > /dev/null
73 if [ $? -ne 1 ] ; then fail ; fi
74
75 pass;