Change "union value" to dynamically allocate long strings.
[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 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
82 diff -b  -w $TEMPDIR/pspp.list - << EOF
83 1.1 DATA LIST.  Reading free-form data from INLINE.
84 +--------+------+
85 |Variable|Format|
86 #========#======#
87 |x       |F8.0  |
88 |y       |A18   |
89 +--------+------+
90 $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.
91 $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.
92 2.1 CROSSTABS.  Summary.
93 #===============#=====================================================#
94 #               #                        Cases                        #
95 #               #-----------------+-----------------+-----------------#
96 #               #      Valid      |     Missing     |      Total      #
97 #               #--------+--------+--------+--------+--------+--------#
98 #               #       N| Percent|       N| Percent|       N| Percent#
99 #---------------#--------+--------+--------+--------+--------+--------#
100 #x * y          #       4|   66.7%|       2|   33.3%|       6|  100.0%#
101 #===============#========#========#========#========#========#========#
102 2.2 CROSSTABS.  x * y [count].
103 #===============#===================================#========#
104 #               #                 y                 |        #
105 #               #--------+--------+--------+--------+        #
106 #              x#     one|   three|     two|    zero|  Total #
107 #               #unity   |lots    |duality |none    |        #
108 #               #        |        |        |        |        #
109 #---------------#--------+--------+--------+--------+--------#
110 #           1.00#     1.0|      .0|      .0|     1.0|     2.0#
111 #           2.00#      .0|      .0|     1.0|      .0|     1.0#
112 #           3.00#      .0|     1.0|      .0|      .0|     1.0#
113 #Total          #     1.0|     1.0|     1.0|     1.0|     4.0#
114 #===============#========#========#========#========#========#
115 EOF
116 if [ $? -ne 0 ] ; then fail ; fi
117
118 pass;