Fixed numerous memory leaks. Changed many of the test cases to use a canonical
[pspp-builds.git] / tests / command / aggregate.sh
1 #!/bin/sh
2
3 # This program tests the aggregate procedure
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8
9 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14
15 export STAT_CONFIG_PATH=$top_srcdir/config
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="program create"
51 cat > $TESTFILE << EOF
52
53 data list notable /x y 1-2.
54 begin data.
55 13
56 27
57 30
58 12
59 26
60 11
61 10
62 28
63 29
64 14
65 15
66 end data.
67 sort cases by x.
68 aggregate /missing=columnwise /document /presorted/break=x(a) /z'label for z'=sum(y)/foo=nu.
69 list.
70 EOF
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 activity="run program"
74 $SUPERVISOR $here/../src/pspp    -o raw-ascii $TESTFILE
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="test result"
78 diff  -b -w -B $TEMPDIR/pspp.list - << EOF
79 X        Z      FOO
80 - -------- --------
81 1    15.00     6.00 
82 2    30.00     4.00 
83 3      .00     1.00 
84 EOF
85 if [ $? -ne 0 ] ; then fail ; fi
86
87 pass;