Rewrite PSPP output engine.
[pspp-builds.git] / tests / bugs / crosstabs-crash2.sh
1 #!/bin/sh
2
3 # This program tests for bug #22037, which caused CROSSTABS to crash.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
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="create program"
62 cat > $TESTFILE <<EOF
63 data list list /x * y (a18).
64
65 begin data.
66
67    1. 'zero none'
68
69 1 'one unity'
70 2 'two duality'
71 3 'three lots'
72 end data.
73
74 CROSSTABS /TABLES = x BY y.
75 EOF
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 $SUPERVISOR $PSPP --testing-mode $TESTFILE > /dev/null
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81 diff -c $TEMPDIR/pspp.csv - << EOF
82 Table: Reading free-form data from INLINE.
83 Variable,Format
84 x,F8.0
85 y,A18
86
87 "$TEMPDIR/crosstabs-crash2.sh.sps:4: warning: BEGIN DATA: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
88
89 "$TEMPDIR/crosstabs-crash2.sh.sps:6: warning: BEGIN DATA: Missing value(s) for all variables from x onward.  These will be filled with the system-missing value or blanks, as appropriate."
90
91 Table: Summary.
92 ,Cases,,,,,
93 ,Valid,,Missing,,Total,
94 ,N,Percent,N,Percent,N,Percent
95 x * y,4,66.7%,2,33.3%,6,100.0%
96
97 Table: x * y [count].
98 ,y,,,,
99 x,one unity         ,three lots        ,two duality       ,zero none         ,Total
100 1.00,1.0,.0,.0,1.0,2.0
101 2.00,.0,.0,1.0,.0,1.0
102 3.00,.0,1.0,.0,.0,1.0
103 Total,1.0,1.0,1.0,1.0,4.0
104 EOF
105 if [ $? -ne 0 ] ; then fail ; fi
106
107 pass;