Fixed bug which crept in with the recent lexer changes.
[pspp-builds.git] / tests / bugs / signals.sh
1 #!/bin/sh
2
3 # This program tests that signals are properly caught and handled by PSPP
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22
23 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR"
27         return ; 
28      fi
29      rm -rf $TEMPDIR
30
31      # Kill any remaining children of this shell
32      kill `ps h --ppid $$ | awk '{print $1}'` 2> /dev/null
33 }
34
35
36 fail()
37 {
38     echo $activity
39     echo FAILED
40     cleanup;
41     exit 1;
42 }
43
44
45 no_result()
46 {
47     echo $activity
48     echo NO RESULT;
49     cleanup;
50     exit 2;
51 }
52
53 pass()
54 {
55     cleanup;
56     exit 0;
57 }
58
59 mkdir -p $TEMPDIR
60
61 cd $TEMPDIR
62
63
64 activity="run program in interactive mode"
65 cat | $PSPP --testing-mode -o raw-ascii 2> $TEMPDIR/stderr1  > /dev/null & 
66 thepid1=$!
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69 activity="run program in interactive mode 2"
70 cat | $PSPP --testing-mode -o raw-ascii 2> $TEMPDIR/stderr2  > /dev/null & 
71 thepid2=$!
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 # This one is a dummy.  Despite the sleep command,  it may not be enought 
75 # to ensure that the preceeding pspp has actually initialised itself.
76 activity="run program in interactive mode 3"
77 cat | $PSPP --testing-mode -o raw-ascii 2> /dev/null  > /dev/null & sleep 1
78 thepid3=$!
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 activity="sending SIGINT to pspp1"
82 kill -INT $thepid1
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85 activity="sending SIGSEGV to pspp2"
86 kill -SEGV $thepid2
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89
90 # SIGINT should have caused a clean shutdown
91
92 activity="checking for absence of error messages 1"
93 [ ! -s $TEMPDIR/stderr1 ]  
94 if [ $? -ne 0 ] ; then fail ; fi
95
96 # SIGSEGV should have caused an error message
97
98 activity="checking for error messages from pspp 2"
99 head -8 $TEMPDIR/stderr2 > $TEMPDIR/stderr-head
100 if [ $? -ne 0 ] ; then no_result ; fi
101
102 activity="comparing error messages from pspp 2"
103 diff $TEMPDIR/stderr-head  - << EOF
104 ******************************************************
105 You have discovered a bug in PSPP.  Please report this
106 to bug-gnu-pspp@gnu.org.  Please include this entire
107 message, *plus* several lines of output just above it.
108 For the best chance at having the bug fixed, also
109 include the syntax file that triggered it and a sample
110 of any data file used for input.
111 proximate cause:     Segmentation Violation
112 EOF
113 if [ $? -ne 0 ] ; then fail ; fi
114
115
116 pass;