LIST: Remove WEIGHT subcommand.
[pspp-builds.git] / 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 # ensure that top_builddir  are absolute
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
12 top_builddir=`cd $top_builddir; pwd`
13 PSPP=$top_builddir/src/ui/terminal/pspp
14
15 # ensure that top_srcdir is absolute
16 top_srcdir=`cd $top_srcdir; pwd`
17
18 STAT_CONFIG_PATH=$top_srcdir/config
19 export STAT_CONFIG_PATH
20
21 LANG=C
22 export LANG
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR" 
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 activity="create program"
63 cat > $TESTFILE <<EOF
64 DATA LIST LIST /A * B * X * Y * .
65 BEGIN DATA.
66 2 3 4 5
67 END DATA.
68
69 CROSSTABS VARIABLES X (1,7) Y (1,7) /TABLES X BY Y.
70 EOF
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 $SUPERVISOR $PSPP --testing-mode $TESTFILE
74 if [ $? -ne 0 ] ; then no_result ; fi
75
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 |A       |F8.0  |
84 |B       |F8.0  |
85 |X       |F8.0  |
86 |Y       |F8.0  |
87 +--------+------+
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          #       1|  100.0%|       0|    0.0%|       1|  100.0%#
97 #===============#========#========#========#========#========#========#
98 2.2 CROSSTABS.  X * Y [count].
99 #===============#==============================================================#========#
100 #               #                               Y                              |        #
101 #               #--------+--------+--------+--------+--------+--------+--------+        #
102 #              X#    1.00|    2.00|    3.00|    4.00|    5.00|    6.00|    7.00|  Total #
103 #---------------#--------+--------+--------+--------+--------+--------+--------+--------#
104 #           1.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
105 #           2.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
106 #           3.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
107 #           4.00#      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
108 #           5.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
109 #           6.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
110 #           7.00#      .0|      .0|      .0|      .0|      .0|      .0|      .0|      .0#
111 #Total          #      .0|      .0|      .0|      .0|     1.0|      .0|      .0|     1.0#
112 #===============#========#========#========#========#========#========#========#========#
113 EOF
114 if [ $? -ne 0 ] ; then fail ; fi
115
116 pass;