48ff213ba0a368606b5884b5530374faf6efbad8
[pspp-builds.git] / tests / stats / descript-mean-bug.sh
1 #!/bin/sh
2
3 # This program tests that DESCRIPTIVES asking for a mean only works,
4 # which didn't at one point.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 export STAT_CONFIG_PATH=$top_srcdir/config
14
15
16 cleanup()
17 {
18      rm -rf $TEMPDIR
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 activity="create program"
50 cat > $TEMPDIR/descript.stat <<EOF
51 data list notable / X 1.
52 begin data.
53 0
54 1
55 2
56 3
57 4
58 5
59 end data.
60
61 descript all/stat=mean.
62
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66
67 activity="run program"
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TEMPDIR/descript.stat
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="compare output"
72 diff -B -b $TEMPDIR/pspp.list - <<EOF
73 1.1 DESCRIPTIVES.  Valid cases = 6; cases with missing value(s) = 0.
74 +--------#-+-----+
75 |Variable#N| Mean|
76 #========#=#=====#
77 |X       #6|2.500|
78 +--------#-+-----+
79 EOF
80 if [ $? -ne 0 ] ; then fail ; fi
81
82
83 pass