Fixed some memory leaks.
[pspp-builds.git] / tests / command / examine-extremes.sh
1 #!/bin/sh
2
3 # This program tests  the EXTREME subcommand of the EXAMINE command.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18 }
19
20
21 fail()
22 {
23     echo $activity
24     echo FAILED
25     cleanup;
26     exit 1;
27 }
28
29
30 no_result()
31 {
32     echo $activity
33     echo NO RESULT;
34     cleanup;
35     exit 2;
36 }
37
38 pass()
39 {
40     cleanup;
41     exit 0;
42 }
43
44 mkdir -p $TEMPDIR
45
46 cd $TEMPDIR
47
48 activity="create program"
49 cat > $TEMPDIR/out.stat <<EOF
50 data list free /v1 w
51 begin data.
52 1  1
53 2  1
54 3  2
55 3  1
56 4  1
57 5  1
58 6  1
59 7  1
60 8  1
61 9  1
62 10 1
63 11 1
64 12 1
65 13 1
66 14 1
67 15 1
68 16 1
69 17 1
70 18 2
71 19 1
72 20 1
73 end data.
74
75 weight by w.
76
77 examine v1 
78  /statistics=extreme(6)
79  .
80 EOF
81 if [ $? -ne 0 ] ; then no_result ; fi
82
83
84 activity="run program"
85 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/out.stat
86 if [ $? -ne 0 ] ; then no_result ; fi
87
88 activity="compare results"
89 diff $TEMPDIR/pspp.list - << EOF
90 1.1 EXAMINE.  Case Processing Summary
91 #==#===============================#
92 #  #             Cases             #
93 #  #----------+---------+----------#
94 #  #   Valid  | Missing |   Total  #
95 #  #--+-------+-+-------+--+-------#
96 #  # N|Percent|N|Percent| N|Percent#
97 #==#==#=======#=#=======#==#=======#
98 #V1#23|   100%|0|     0%|23|   100%#
99 #==#==#=======#=#=======#==#=======#
100
101 1.2 EXAMINE.  Extreme Values
102 #==========#===========#=====#
103 #          #Case Number|Value#
104 #==========#===========#=====#
105 #V1Highest1#         21|20.00#
106 #         2#         20|19.00#
107 #         3#         19|18.00#
108 #         4#         19|18.00#
109 #         5#         18|17.00#
110 #         6#         17|16.00#
111 #  --------#-----------+-----#
112 #   Lowest1#          1| 1.00#
113 #         2#          2| 2.00#
114 #         3#          4| 3.00#
115 #         4#          3| 3.00#
116 #         5#          3| 3.00#
117 #         6#          5| 4.00#
118 #==========#===========#=====#
119
120 EOF
121 if [ $? -ne 0 ] ; then fail ; fi
122
123 pass