2f7d79196f702d36bbff83fda38f35f0a1a18619
[pspp-builds.git] / tests / bugs / terminate.sh
1 #!/bin/sh
2
3 # This  tests checks that when a fatal error occurs,
4 # and appropriate notice is printed and the program exits with a 
5 # non zero status
6
7
8 TEMPDIR=/tmp/pspp-tst-$$
9 TESTFILE=$TEMPDIR/`basename $0`.sps
10
11 here=`pwd`;
12
13 # ensure that top_srcdir is absolute
14 cd $top_srcdir; top_srcdir=`pwd`
15
16 export STAT_CONFIG_PATH=$top_srcdir/config
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
53 activity="delete file"
54 rm -f $TEMPDIR/bar.dat
55 if [ $? -ne 0 ] ; then no_result ; fi
56
57 activity="create program"
58 cat > $TEMPDIR/foo.sps <<EOF
59 DATA LIST FILE='$TEMPDIR/bar.dat' /S 1-2 (A) X 3 .
60
61 EXECUTE.
62 EOF
63 if [ $? -ne 0 ] ; then no_result ; fi
64
65 activity="run program"
66 # This must exit with non zero status
67 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/foo.sps > /dev/null 2> $TEMPDIR/stderr
68 if [ $? -eq 0 ] ; then fail ; fi
69
70 activity="compare stderr"
71 diff $TEMPDIR/stderr - << EOF
72 pspp: Terminating NOW due to a fatal error!
73 EOF
74 if [ $? -ne 0 ] ; then fail ; fi
75
76 pass;