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