a2787f29c82b1bfa296bc4b77c6a84c5627645bf
[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
32
33 fail()
34 {
35     echo $activity
36     echo FAILED
37     cleanup;
38     exit 1;
39 }
40
41
42 no_result()
43 {
44     echo $activity
45     echo NO RESULT;
46     cleanup;
47     exit 2;
48 }
49
50 pass()
51 {
52     cleanup;
53     exit 0;
54 }
55
56 mkdir -p $TEMPDIR
57
58 cd $TEMPDIR
59
60 activity="sending SIGINT to pspp"
61 echo 'host kill -INT $PPID' | $PSPP --testing-mode > /dev/null 2> $TEMPDIR/stderr1
62 if [ $? -ne 0 ] ; then no_result ; fi
63
64 # SIGINT should have caused a clean shutdown
65 activity="checking for absence of error messages 1"
66 [ ! -s $TEMPDIR/stderr1 ]  
67 if [ $? -ne 0 ] ; then fail ; fi
68
69 activity="sending SIGSEGV to pspp"
70 echo 'host kill -SEGV $PPID' | $PSPP --testing-mode > /dev/null 2> $TEMPDIR/stderr2
71 if [ $? -eq 0 ] ; then no_result ; fi
72
73 # SIGSEGV should have caused an error message
74 activity="checking for error messages from pspp 2"
75 head -8 $TEMPDIR/stderr2 > $TEMPDIR/stderr-head
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="comparing error messages from pspp 2"
79 diff $TEMPDIR/stderr-head  - << EOF
80 ******************************************************
81 You have discovered a bug in PSPP.  Please report this
82 to bug-gnu-pspp@gnu.org.  Please include this entire
83 message, *plus* several lines of output just above it.
84 For the best chance at having the bug fixed, also
85 include the syntax file that triggered it and a sample
86 of any data file used for input.
87 proximate cause:     Segmentation Violation
88 EOF
89 if [ $? -ne 0 ] ; then fail ; fi
90
91
92 pass;