Fix memory leaks.
[pspp-builds.git] / tests / command / t-test-1-sample-missing-list.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /TESTVAL command works OK
4 # when there are listwise missing values 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 * x1 * x2.
52 begin data.
53 1 3.5 34
54 2 2.0 10
55 3 2.0 23
56 4 3.5 98
57 5 3.0 23
58 end data.
59
60 t-test /testval=3.0 /var=x1 x2.
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
74 activity="create program 2"
75 cat > $TEMPDIR/out.stat <<EOF
76 data list list /id * x1 * x2.
77 begin data.
78 1 3.5 34
79 2 2.0 10
80 3 2.0 23
81 4 3.5 98
82 5 3.0 23
83 6 4.0 99
84 end data.
85
86 MISSING VALUES x2(99).
87
88 t-test /missing=listwise /testval=3.0 /var=x1 x2.
89 EOF
90 if [ $? -ne 0 ] ; then no_result ; fi
91
92 activity="run program 2"
93 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
94 if [ $? -ne 0 ] ; then no_result ; fi
95
96 activity="compare outputs"
97 diff $TEMPDIR/ref.list $TEMPDIR/pspp.list
98 if [ $? -ne 0 ] ; then fail ; fi
99
100
101 pass