Fix memory leaks.
[pspp-builds.git] / tests / command / t-test-paired-missing-list.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /PAIRS command works OK
4 # when there is listwise missing data involved.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49 activity="create program 1"
50 cat > $TEMPDIR/out.stat <<EOF
51 data list list /id * a * b * c * d *.
52 begin data.
53 1 2.0 3.0 4.0 4.0
54 2 1.0 2.0 5.1 3.9
55 3 2.0 4.5 5.2 3.8
56 4 2.0 4.5 5.3 3.7
57 5 3.0 6.0 5.9 3.6
58 end data.
59
60 t-test /PAIRS a b with c d (PAIRED). 
61 EOF
62 if [ $? -ne 0 ] ; then no_result ; fi
63
64
65 activity="run program 1"
66 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69 activity="copy output"
70 mv $TEMPDIR/pspp.list $TEMPDIR/ref.list
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73 activity="create program 2"
74 cat > $TEMPDIR/out.stat <<EOF
75 data list list /id * a * b * c * d *.
76 begin data.
77 1 2.0 3.0 4.0 4.0 
78 2 1.0 2.0 5.1 3.9
79 3 2.0 4.5 5.2 3.8
80 4 2.0 4.5 5.3 3.7
81 5 3.0 6.0 5.9 3.6
82 6 3.0 6.0 5.9  .
83 end data.
84
85
86 t-test /MISSING=listwise /PAIRS a b with c d (PAIRED). 
87 EOF
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90
91 activity="run program 2"
92 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
93 if [ $? -ne 0 ] ; then no_result ; fi
94
95
96 activity="compare outputs"
97 diff $TEMPDIR/ref.list $TEMPDIR/pspp.list
98 if [ $? -ne 0 ] ; then fail ; fi
99
100
101 pass