Fix memory leaks.
[pspp-builds.git] / tests / command / t-test-indep-missing-anal.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /GROUPS command works OK
4 # when ANALYSIS missing values are 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 * indep * dep1 * dep2 *.
52 begin data.
53 1  1.0 3.5 6
54 2  1.0 2.0 5
55 3  1.0 2.0 4
56 4  2.0 3.5 3
57 56 2.0 3.0 1
58 end data.
59
60 t-test /group=indep /var=dep1, dep2.
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 cp $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 * indep * dep1 * dep2.
76 begin data.
77 1 1.0 3.5 6
78 2 1.0 2.0 5
79 3 1.0 2.0 4
80 4 2.0 3.5 3
81 5 2.0 3.0 .
82 6 2.0 .   1
83 7  .  3.1 5
84 end data.
85
86 * Note that if the independent variable is missing, then it's implicitly 
87 * listwise missing.
88
89 t-test /missing=analysis /group=indep /var=dep1 dep2.
90 EOF
91 if [ $? -ne 0 ] ; then no_result ; fi
92
93 activity="run program 2"
94 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
95 if [ $? -ne 0 ] ; then no_result ; fi
96
97
98 activity="compare outputs"
99 diff $TEMPDIR/ref.list $TEMPDIR/pspp.list 
100 if [ $? -ne 0 ] ; then fail ; fi
101
102
103 pass