16d15a00208b11c3684d5e5c9e6449299b7241a1
[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 STAT_CONFIG_PATH=$top_srcdir/config
15 export STAT_CONFIG_PATH
16
17
18 cleanup()
19 {
20      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
21         echo "NOT cleaning $TEMPDIR"
22         return ; 
23      fi
24      cd /
25      rm -rf $TEMPDIR
26 }
27
28
29 fail()
30 {
31     echo $activity
32     echo FAILED
33     cleanup;
34     exit 1;
35 }
36
37
38 no_result()
39 {
40     echo $activity
41     echo NO RESULT;
42     cleanup;
43     exit 2;
44 }
45
46 pass()
47 {
48     cleanup;
49     exit 0;
50 }
51
52 mkdir -p $TEMPDIR
53
54 cd $TEMPDIR
55
56
57 activity="create test program"
58 cat > $TESTFILE <<EOF 
59 INPUT PROGRAM.
60 DATA LIST /a 1-9.
61 BEGIN DATA
62 123456789
63 END DATA.
64 END INPUT PROGRAM.
65
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69
70 # The above syntax is invalid, so this program should fail to parse
71 activity="run program"
72 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE > /dev/null
73 if [ $? -ne 1 ] ; then fail ; fi
74
75
76
77 pass;