18902db1b237e0ab8070cd8170019e3286247384
[pspp] / tests / bugs / crosstabs-crash.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused CROSSTABS to crash in
4 # integer mode.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 STAT_CONFIG_PATH=$top_srcdir/config
15 export STAT_CONFIG_PATH
16
17
18 cleanup()
19 {
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create program"
52 cat > $TESTFILE <<EOF
53 DATA LIST LIST /A * B * X * Y * .
54 BEGIN DATA.
55 2 3 4 5
56 END DATA.
57
58 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
59 EOF
60 if [ $? -ne 0 ] ; then no_result ; fi
61
62 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
63 if [ $? -ne 0 ] ; then no_result ; fi
64
65
66 diff -b -B -w $TEMPDIR/pspp.list - << EOF
67 1.1 DATA LIST.  Reading free-form data from the command file.
68 +--------+------+
69 |Variable|Format|
70 #========#======#
71 |A       |F8.0  |
72 |B       |F8.0  |
73 |X       |F8.0  |
74 |Y       |F8.0  |
75 +--------+------+
76
77 2.1 CROSSTABS.  Summary.
78 #===============#=====================================================#
79 #               #                        Cases                        #
80 #               #-----------------+-----------------+-----------------#
81 #               #      Valid      |     Missing     |      Total      #
82 #               #--------+--------+--------+--------+--------+--------#
83 #               #       N| Percent|       N| Percent|       N| Percent#
84 #---------------#--------+--------+--------+--------+--------+--------#
85 #X * Y          #       1|  100.0%|       0|    0.0%|       1|  100.0%#
86 #===============#========#========#========#========#========#========#
87
88 2.2 CROSSTABS.  X by Y [count].
89 #===============#==============================================================#========#
90 #               #                               Y                              |        #
91 #               #--------+--------+--------+--------+--------+--------+--------+        #
92 #              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
93 #---------------#--------+--------+--------+--------+--------+--------+--------+--------#
94 #           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
95 #           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
96 #           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
97 #           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
98 #           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
99 #           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
100 #           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
101 #Total          #     .0%|     .0%|     .0%|     .0%|    1.0%|     .0%|     .0%|    1.0%#
102 #===============#========#========#========#========#========#========#========#========#
103
104 EOF
105 if [ $? -ne 0 ] ; then fail ; fi
106
107 pass;