35d4af737deba3186d1aad520814c701b39254c5
[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 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18      :
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46
47 cd $TEMPDIR
48
49
50 i=1;
51
52 activity="create program $i"
53 cat > $TEMPDIR/prog.sps <<EOF
54 DATA LIST LIST notable /x * .
55 BEGIN DATA.
56
57
58
59
60 5
61 END DATA.
62
63 FREQUENCIES 
64         VAR=x
65         /PERCENTILES = 0 25 33.333 50 66.666 75 100
66
67 EOF
68 if [ $? -ne 0 ] ; then no_result; fi
69
70 activity="run program $i"
71 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 activity="move output"
75 cp $TEMPDIR/pspp.list $TEMPDIR/list.ref
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 i=$[$i+1];
79
80 activity="create program $i"
81 cat > $TEMPDIR/prog.sps <<EOF
82 DATA LIST LIST notable /x * .
83 BEGIN DATA.
84
85
86
87
88 5
89 END DATA.
90
91 FREQUENCIES 
92         VAR=x
93         /NTILES = 3
94         /NTILES = 4
95         .
96 EOF
97 if [ $? -ne 0 ] ; then no_result; fi
98
99 activity="run program $i"
100 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/prog.sps
101 if [ $? -ne 0 ] ; then no_result ; fi
102
103 activity="compare output"
104 diff $TEMPDIR/pspp.list $TEMPDIR/list.ref
105 if [ $? -ne 0 ] ; then fail; fi
106
107
108 pass;