Fix Bug #11955.
[pspp-builds.git] / tests / bugs / agg-crash-2.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused AGGREGATE to crash when
4 # the MAX function was used.
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 export STAT_CONFIG_PATH=$top_srcdir/config
15
16
17 cleanup()
18 {
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create program"
51 cat > $TESTFILE <<EOF
52 DATA LIST LIST /x (F8.2) y (a25).
53
54 BEGIN DATA.
55 87.50 foo
56 87.34 bar
57 1 bar
58 END DATA.
59
60
61
62 AGGREGATE /BREAK=y /x=MAX(x).
63 LIST /x y.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 diff -b -B -w $TEMPDIR/pspp.list - << EOF
71 1.1 DATA LIST.  Reading free-form data from the command file.
72 +--------+------+
73 |Variable|Format|
74 #========#======#
75 |X       |F8.2  |
76 |Y       |A25   |
77 +--------+------+
78
79        X                         Y
80 -------- -------------------------
81    87.34 bar                       
82    87.50 foo                       
83 EOF
84 if [ $? -ne 0 ] ; then fail ; fi
85
86 pass;