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