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