f96ba66970cf368b2144ea17a2e868cde0a24695
[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 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19
20 cleanup()
21 {
22      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50
51 cd $TEMPDIR
52
53
54 activity="delete file"
55 rm -f $TEMPDIR/bar.dat
56 if [ $? -ne 0 ] ; then no_result ; fi
57
58 activity="create program"
59 cat > $TEMPDIR/foo.sps <<EOF
60 DATA LIST FILE='$TEMPDIR/bar.dat' /S 1-2 (A) X 3 .
61
62 EXECUTE.
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66 activity="run program"
67 # This must exit with non zero status
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/foo.sps > /dev/null 2> $TEMPDIR/stderr
69 if [ $? -eq 0 ] ; then fail ; fi
70
71 activity="compare stderr"
72 diff $TEMPDIR/stderr - << EOF
73 pspp: Terminating NOW due to a fatal error!
74 EOF
75 if [ $? -ne 0 ] ; then fail ; fi
76
77 pass;