Fixed numerous memory leaks. Changed many of the test cases to use a canonical
[pspp-builds.git] / tests / command / oneway-missing.sh
1 #!/bin/sh
2
3 # This program tests that the ONEWAY anova command works OK when there is missing data
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
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"
50 cat > $TESTFILE <<EOF
51 DATA LIST LIST /v1 * v2 * dep * vn *.
52 BEGIN DATA
53 . .  1  4
54 3 3  1  2
55 2 2  1  2
56 1 1  1  2
57 1 1  1  2
58 4 4  1  2
59 5 5  2  2
60 2 2  2  2
61 4 4  2  2
62 2 2  2  2
63 3 3  2  2
64 7 7  3  2
65 4 4  3  2
66 5 5  3  2
67 3 3  3  2
68 6 6  3  2
69 END DATA
70
71 ONEWAY
72         v1 v2 BY dep
73         /STATISTICS descriptives homogeneity
74         /MISSING ANALYSIS 
75         .
76 EOF
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79
80 activity="run program"
81 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
82 if [ $? -ne 0 ] ; then no_result ; fi
83
84 activity="copy output"
85 cp $TEMPDIR/pspp.list $TEMPDIR/pspp.list1
86 if [ $? -ne 0 ] ; then no_result ; fi
87
88 activity="create program 2"
89 cat > $TESTFILE <<EOF
90 DATA LIST LIST /v1 * v2 * dep * vn * .
91 BEGIN DATA
92 4 .  1  2 
93 3 3  1  2
94 2 2  1  2
95 1 1  1  2
96 1 1  1  2
97 4 4  1  2
98 5 5  2  2
99 2 2  2  2
100 4 4  2  2
101 2 2  2  2
102 3 3  2  2
103 7 7  3  2
104 4 4  3  2
105 5 5  3  2
106 3 3  3  2
107 6 6  3  2
108 END DATA
109
110 ONEWAY
111         v1 v2 BY dep
112         /STATISTICS descriptives homogeneity
113         /MISSING LISTWISE
114         .
115 EOF
116 if [ $? -ne 0 ] ; then no_result ; fi
117
118 activity="run program 2"
119 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
120 if [ $? -ne 0 ] ; then no_result ; fi
121
122 activity="compare outputs"
123 diff $TEMPDIR/pspp.list $TEMPDIR/pspp.list1
124 if [ $? -ne 0 ] ; then fail ; fi
125
126 # Now try a missing dependent variable
127 # Everything depends upon it, so it should behave as if LISTWISE were set
128 activity="create program 3"
129 cat > $TESTFILE <<EOF
130 DATA LIST LIST /v1 * v2 * dep * vn * .
131 BEGIN DATA
132 4 2  .  2 
133 3 3  1  2
134 2 2  1  2
135 1 1  1  2
136 1 1  1  2
137 4 4  1  2
138 5 5  2  2
139 2 2  2  2
140 4 4  2  2
141 2 2  2  2
142 3 3  2  2
143 7 7  3  2
144 4 4  3  2
145 5 5  3  2
146 3 3  3  2
147 6 6  3  2
148 END DATA
149
150 ONEWAY
151         v1 v2 BY dep
152         /STATISTICS descriptives homogeneity
153         /MISSING ANALYSIS
154         .
155 EOF
156 if [ $? -ne 0 ] ; then no_result ; fi
157
158 activity="run program 3"
159 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
160 if [ $? -ne 0 ] ; then no_result ; fi
161
162 activity="compare outputs"
163 diff $TEMPDIR/pspp.list $TEMPDIR/pspp.list1
164 if [ $? -ne 0 ] ; then fail ; fi
165
166
167 pass