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