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