Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / stats / percentiles-compatible.sh
1 #! /bin/sh
2
3 # Tests calculation of percentiles with the 
4 # COMPATIBLE algorithm set.
5
6 TEMPDIR=/tmp/pspp-tst-$$
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
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51
52 i=1;
53
54 activity="create program $i"
55 cat > $TEMPDIR/prog.sps <<EOF
56 DATA LIST LIST notable /X * .
57 BEGIN DATA.
58
59
60
61
62 5
63 END DATA.
64
65 FREQUENCIES 
66         VAR=x
67         /ALGORITHM=COMPATIBLE
68         /PERCENTILES = 0 25 50 75 100
69
70 EOF
71 if [ $? -ne 0 ] ; then no_result; fi
72
73 activity="run program $i"
74 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 activity="compare output $i"
78 diff -B -b $TEMPDIR/pspp.list - <<EOF
79 1.1 FREQUENCIES.  X: 
80 +-----------+--------+---------+--------+--------+--------+
81 |           |        |         |        |  Valid |   Cum  |
82 |Value Label|  Value |Frequency| Percent| Percent| Percent|
83 #===========#========#=========#========#========#========#
84 |           |    1.00|        1|    20.0|    20.0|    20.0|
85 |           |    2.00|        1|    20.0|    20.0|    40.0|
86 |           |    3.00|        1|    20.0|    20.0|    60.0|
87 |           |    4.00|        1|    20.0|    20.0|    80.0|
88 |           |    5.00|        1|    20.0|    20.0|   100.0|
89 #===========#========#=========#========#========#========#
90 |               Total|        5|   100.0|   100.0|        |
91 +--------------------+---------+--------+--------+--------+
92
93 +-------------------+-----+
94 |N           Valid  |    5|
95 |            Missing|    0|
96 |Mean               |3.000|
97 |Std Dev            |1.581|
98 |Minimum            |1.000|
99 |Maximum            |5.000|
100 |Percentiles 0      |1.000|
101 |            25     |1.500|
102 |            50     |3.000|
103 |            75     |4.500|
104 |            100    |5.000|
105 +-------------------+-----+
106 EOF
107 if [ $? -ne 0 ] ; then fail ; fi
108
109 pass;