08f9615f995ef5db0072e1f9d9386430578f6222
[pspp-builds.git] / tests / bugs / print-crash.sh
1 #!/bin/sh
2
3 # This program tests for a bug which crashed when deallocating after a bad 
4 # PRINT command.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_srcdir and top_builddir  are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
14
15 PSPP=$top_builddir/src/ui/terminal/pspp
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20
21 cleanup()
22 {
23      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
24         echo "NOT cleaning $TEMPDIR"
25         return ; 
26      fi
27      rm -rf $TEMPDIR
28 }
29
30
31 fail()
32 {
33     echo $activity
34     echo FAILED
35     cleanup;
36     exit 1;
37 }
38
39
40 no_result()
41 {
42     echo $activity
43     echo NO RESULT;
44     cleanup;
45     exit 2;
46 }
47
48 pass()
49 {
50     cleanup;
51     exit 0;
52 }
53
54 mkdir -p $TEMPDIR
55
56 cd $TEMPDIR
57
58 cat > $TESTFILE << EOF
59 DATA LIST LIST /a * b *.
60 BEGIN DATA.
61 1 2
62 3 4
63 END DATA.
64
65 PRINT F8.2
66 LIST.
67 EOF
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70
71 activity="run program"
72 $SUPERVISOR $PSPP --testing-mode -e /dev/null $TESTFILE 
73 if [ $? -ne 1 ] ; then fail ; fi
74
75
76 pass;