17818161d4dbdd3dd63fc2f9191ea1278697ced2
[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 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 /X (F8.2) Y (a25).
54
55 BEGIN DATA.
56 87.50 foo
57 87.34 bar
58 1 bar
59 END DATA.
60
61
62
63 AGGREGATE OUTFILE=* /BREAK=y /X=MAX(x).
64 LIST /x y.
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 diff -b -B -w $TEMPDIR/pspp.list - << EOF
72 1.1 DATA LIST.  Reading free-form data from the command file.
73 +--------+------+
74 |Variable|Format|
75 #========#======#
76 |X       |F8.2  |
77 |Y       |A25   |
78 +--------+------+
79
80         X                         Y
81 --------- -------------------------
82     87.34 bar                       
83     87.50 foo                       
84 EOF
85 if [ $? -ne 0 ] ; then fail ; fi
86
87 pass;