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