Fix bug #22037.
[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      cd /
26      rm -rf $TEMPDIR
27 }
28
29
30 fail()
31 {
32     echo $activity
33     echo FAILED
34     cleanup;
35     exit 1;
36 }
37
38
39 no_result()
40 {
41     echo $activity
42     echo NO RESULT;
43     cleanup;
44     exit 2;
45 }
46
47 pass()
48 {
49     cleanup;
50     exit 0;
51 }
52
53 mkdir -p $TEMPDIR
54
55 cd $TEMPDIR
56
57 activity="create program"
58 cat > $TESTFILE <<EOF
59 data list list /x * y (a18).
60
61 begin data.
62
63    1. 'zero none'
64
65 1 'one unity'
66 2 'two duality'
67 3 'three lots'
68 end data.
69
70 CROSSTABS /TABLES = x BY y.
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 $SUPERVISOR $PSPP --testing-mode $TESTFILE > /dev/null
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
78 diff -b  -w $TEMPDIR/pspp.list - << EOF
79 1.1 DATA LIST.  Reading free-form data from INLINE.
80 +--------+------+
81 |Variable|Format|
82 #========#======#
83 |x       |F8.0  |
84 |y       |A18   |
85 +--------+------+
86 $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.
87 $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.
88 2.1 CROSSTABS.  Summary.
89 #===============#=====================================================#
90 #               #                        Cases                        #
91 #               #-----------------+-----------------+-----------------#
92 #               #      Valid      |     Missing     |      Total      #
93 #               #--------+--------+--------+--------+--------+--------#
94 #               #       N| Percent|       N| Percent|       N| Percent#
95 #---------------#--------+--------+--------+--------+--------+--------#
96 #x * y          #       4|   66.7%|       2|   33.3%|       6|  100.0%#
97 #===============#========#========#========#========#========#========#
98 2.2 CROSSTABS.  x by y [count].
99 #===============#===================================#========#
100 #               #                 y                 |        #
101 #               #--------+--------+--------+--------+        #
102 #              x#one unit|three lo|two dual|zero non|  Total #
103 #---------------#--------+--------+--------+--------+--------#
104 #           1.00#     1.0|      .0|      .0|     1.0|     2.0#
105 #           2.00#      .0|      .0|     1.0|      .0|     1.0#
106 #           3.00#      .0|     1.0|      .0|      .0|     1.0#
107 #Total          #    1.0%|    1.0%|    1.0%|    1.0%|    4.0%#
108 #===============#========#========#========#========#========#
109 EOF
110 if [ $? -ne 0 ] ; then fail ; fi
111
112 pass;