Merge commit 'origin/stable'
[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 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 cleanup()
24 {
25      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 activity="create program"
62 cat > $TESTFILE <<EOF
63 data list free /V1 W
64 begin data.
65 1  1
66 2  1
67 3  2
68 3  1
69 4  1
70 5  1
71 6  1
72 7  1
73 8  1
74 9  1
75 10 1
76 11 1
77 12 1
78 13 1
79 14 1
80 15 1
81 16 1
82 17 1
83 18 2
84 19 1
85 20 1
86 end data.
87
88 weight by w.
89
90 examine v1 
91  /statistics=extreme(6)
92  .
93 EOF
94 if [ $? -ne 0 ] ; then no_result ; fi
95
96
97 activity="run program"
98 $SUPERVISOR $PSPP --testing-mode $TESTFILE
99 if [ $? -ne 0 ] ; then no_result ; fi
100
101 activity="compare results"
102 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
103 diff -b  $TEMPDIR/pspp.list - << EOF
104 1.1 EXAMINE.  Case Processing Summary
105 #==#=======================================#
106 #  #                 Cases                 #
107 #  #-------------+-----------+-------------#
108 #  #    Valid    |  Missing  |    Total    #
109 #  #-----+-------+---+-------+-----+-------#
110 #  #  N  |Percent| N |Percent|  N  |Percent#
111 #==#=====#=======#===#=======#=====#=======#
112 #V1#23.00|   100%|.00|     0%|23.00|   100%#
113 #==#=====#=======#===#=======#=====#=======#
114 1.2 EXAMINE.  Extreme Values
115 #============#===========#=====#
116 #            #Case Number|Value#
117 #============#===========#=====#
118 #V1 Highest 1#         21|20.00#
119 #           2#         20|19.00#
120 #           3#         19|18.00#
121 #           4#         19|18.00#
122 #           5#         18|17.00#
123 #           6#         17|16.00#
124 #  ----------#-----------+-----#
125 #    Lowest 1#          1| 1.00#
126 #           2#          2| 2.00#
127 #           3#          3| 3.00#
128 #           4#          3| 3.00#
129 #           5#          4| 3.00#
130 #           6#          5| 4.00#
131 #============#===========#=====#
132 EOF
133 if [ $? -ne 0 ] ; then fail ; fi
134
135 pass