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