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