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