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