18461c0093971079a6e0d474258cd9d45149216d
[pspp-builds.git] / tests / bugs / input-crash.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused a crash when 
4 # reading invalid INPUT PROGRAM syntax.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 export STAT_CONFIG_PATH=$top_srcdir/config
15
16
17 cleanup()
18 {
19      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
20         echo "NOT cleaning $TEMPDIR"
21         return ; 
22      fi
23      rm -rf $TEMPDIR
24 }
25
26
27 fail()
28 {
29     echo $activity
30     echo FAILED
31     cleanup;
32     exit 1;
33 }
34
35
36 no_result()
37 {
38     echo $activity
39     echo NO RESULT;
40     cleanup;
41     exit 2;
42 }
43
44 pass()
45 {
46     cleanup;
47     exit 0;
48 }
49
50 mkdir -p $TEMPDIR
51
52 cd $TEMPDIR
53
54
55 activity="create test program"
56 cat > $TESTFILE <<EOF 
57 INPUT PROGRAM.
58 DATA LIST /a 1-9.
59 BEGIN DATA
60 123456789
61 END DATA.
62 END INPUT PROGRAM.
63
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67
68 # The above syntax is invalid, so this program should fail to parse
69 activity="run program"
70 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE > /dev/null
71 if [ $? -ne 1 ] ; then fail ; fi
72
73
74
75 pass;