Fix GCC 4.3 warning about uninitialized structure member.
[pspp] / tests / command / weight.sh
1 #!/bin/sh
2
3 # This program tests the WEIGHT command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR"
28         return ; 
29      fi
30      cd /
31      rm -rf $TEMPDIR
32 }
33
34
35 fail()
36 {
37     echo $activity
38     echo FAILED
39     cleanup;
40     exit 1;
41 }
42
43
44 no_result()
45 {
46     echo $activity
47     echo NO RESULT;
48     cleanup;
49     exit 2;
50 }
51
52 pass()
53 {
54     cleanup;
55     exit 0;
56 }
57
58 mkdir -p $TEMPDIR
59
60 cd $TEMPDIR
61
62 activity="create program"
63 cat > $TESTFILE << EOF
64 data list file='$top_srcdir/tests/weighting.data'/AVAR 1-5 BVAR 6-10.
65 weight by BVAR.
66
67 descriptives AVAR /statistics all /format serial.
68 frequencies AVAR /statistics all /format condense.
69
70 EOF
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73
74 activity="run program"
75 $SUPERVISOR $PSPP --testing-mode $TESTFILE
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 activity="compare results"
79 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
80 diff  -b $TEMPDIR/pspp.list - <<EOF
81 1.1 DATA LIST.  Reading 1 record from "$top_srcdir/tests/weighting.data".
82 +--------+------+-------+------+
83 |Variable|Record|Columns|Format|
84 #========#======#=======#======#
85 |AVAR    |     1|  1-  5|F5.0  |
86 |BVAR    |     1|  6- 10|F5.0  |
87 +--------+------+-------+------+
88 2.1 DESCRIPTIVES.  Valid cases = 730; cases with missing value(s) = 0.
89 +--------#-------+---------+------+--------+-------+--------+--------+--------+--------+--------+------+-------+-------+---------+
90 |Variable#Valid N|Missing N| Mean |S E Mean|Std Dev|Variance|Kurtosis|S E Kurt|Skewness|S E Skew| Range|Minimum|Maximum|   Sum   |
91 #========#=======#=========#======#========#=======#========#========#========#========#========#======#=======#=======#=========#
92 |AVAR    #    730|        0|31.515|    .405| 10.937| 119.608|   2.411|    .181|   1.345|    .090|76.000| 18.000| 94.000|23006.000|
93 +--------#-------+---------+------+--------+-------+--------+--------+--------+--------+--------+------+-------+-------+---------+
94 3.1 FREQUENCIES.  AVAR 
95 +--------+--------+---+---+
96 |        |        |   |Cum|
97 |  Value |  Freq  |Pct|Pct|
98 #========#========#===#===#
99 |      18|       1|  0|  0|
100 |      19|       7|  1|  1|
101 |      20|      26|  4|  5|
102 |      21|      76| 10| 15|
103 |      22|      57|  8| 23|
104 |      23|      58|  8| 31|
105 |      24|      38|  5| 36|
106 |      25|      38|  5| 41|
107 |      26|      30|  4| 45|
108 |      27|      21|  3| 48|
109 |      28|      23|  3| 51|
110 |      29|      24|  3| 55|
111 |      30|      23|  3| 58|
112 |      31|      14|  2| 60|
113 |      32|      21|  3| 63|
114 |      33|      21|  3| 65|
115 |      34|      14|  2| 67|
116 |      35|      14|  2| 69|
117 |      36|      17|  2| 72|
118 |      37|      11|  2| 73|
119 |      38|      16|  2| 75|
120 |      39|      14|  2| 77|
121 |      40|      15|  2| 79|
122 |      41|      14|  2| 81|
123 |      42|      14|  2| 83|
124 |      43|       8|  1| 84|
125 |      44|      15|  2| 86|
126 |      45|      10|  1| 88|
127 |      46|      12|  2| 89|
128 |      47|      13|  2| 91|
129 |      48|      13|  2| 93|
130 |      49|       5|  1| 94|
131 |      50|       5|  1| 94|
132 |      51|       3|  0| 95|
133 |      52|       7|  1| 96|
134 |      53|       6|  1| 96|
135 |      54|       2|  0| 97|
136 |      55|       2|  0| 97|
137 |      56|       2|  0| 97|
138 |      57|       3|  0| 98|
139 |      58|       1|  0| 98|
140 |      59|       3|  0| 98|
141 |      61|       1|  0| 98|
142 |      62|       3|  0| 99|
143 |      63|       1|  0| 99|
144 |      64|       1|  0| 99|
145 |      65|       2|  0| 99|
146 |      70|       1|  0| 99|
147 |      78|       1|  0|100|
148 |      79|       1|  0|100|
149 |      80|       1|  0|100|
150 |      94|       1|  0|100|
151 +--------+--------+---+---+
152 +-----------------------+---------+
153 |N           Valid      |      730|
154 |            Missing    |        0|
155 |Mean                   |   31.515|
156 |S.E. Mean              |     .405|
157 |Mode                   |   21.000|
158 |Std Dev                |   10.937|
159 |Variance               |  119.608|
160 |Kurtosis               |    2.411|
161 |S.E. Kurt              |     .181|
162 |Skewness               |    1.345|
163 |S.E. Skew              |     .090|
164 |Range                  |   76.000|
165 |Minimum                |   18.000|
166 |Maximum                |   94.000|
167 |Sum                    |23006.000|
168 |Percentiles 50 (Median)|   28.500|
169 +-----------------------+---------+
170 EOF
171 if [ $? -ne 0 ] ; then fail ; fi
172
173
174 pass;