fb2ac6dc138972ad4f64d6386825ceeb8d45d814
[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      cd /
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         /PERCENTILES = 0 25 33.333 50 66.666 75 100
68
69 EOF
70 if [ $? -ne 0 ] ; then no_result; fi
71
72 activity="run program $i"
73 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76 activity="move output"
77 cp $TEMPDIR/pspp.list $TEMPDIR/list.ref
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80 i=$[$i+1];
81
82 activity="create program $i"
83 cat > $TEMPDIR/prog.sps <<EOF
84 DATA LIST LIST notable /x * .
85 BEGIN DATA.
86
87
88
89
90 5
91 END DATA.
92
93 FREQUENCIES 
94         VAR=x
95         /NTILES = 3
96         /NTILES = 4
97         .
98 EOF
99 if [ $? -ne 0 ] ; then no_result; fi
100
101 activity="run program $i"
102 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
103 if [ $? -ne 0 ] ; then no_result ; fi
104
105 activity="compare output"
106 diff $TEMPDIR/pspp.list $TEMPDIR/list.ref
107 if [ $? -ne 0 ] ; then fail; fi
108
109
110 pass;