Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / stats / ntiles.sh
1 #! /bin/sh
2
3 # Tests the NTILE subcommand of the frequencies command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 STAT_CONFIG_PATH=$top_srcdir/config
13 export STAT_CONFIG_PATH
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
19      :
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
51 i=1;
52
53 activity="create program $i"
54 cat > $TEMPDIR/prog.sps <<EOF
55 DATA LIST LIST notable /x * .
56 BEGIN DATA.
57
58
59
60
61 5
62 END DATA.
63
64 FREQUENCIES 
65         VAR=x
66         /PERCENTILES = 0 25 33.333 50 66.666 75 100
67
68 EOF
69 if [ $? -ne 0 ] ; then no_result; fi
70
71 activity="run program $i"
72 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75 activity="move output"
76 cp $TEMPDIR/pspp.list $TEMPDIR/list.ref
77 if [ $? -ne 0 ] ; then no_result ; fi
78
79 i=$[$i+1];
80
81 activity="create program $i"
82 cat > $TEMPDIR/prog.sps <<EOF
83 DATA LIST LIST notable /x * .
84 BEGIN DATA.
85
86
87
88
89 5
90 END DATA.
91
92 FREQUENCIES 
93         VAR=x
94         /NTILES = 3
95         /NTILES = 4
96         .
97 EOF
98 if [ $? -ne 0 ] ; then no_result; fi
99
100 activity="run program $i"
101 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
102 if [ $? -ne 0 ] ; then no_result ; fi
103
104 activity="compare output"
105 diff $TEMPDIR/pspp.list $TEMPDIR/list.ref
106 if [ $? -ne 0 ] ; then fail; fi
107
108
109 pass;