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