Rewrite PSPP output engine.
[pspp-builds.git] / tests / bugs / temp-freq.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused FREQUENCIES following
4 # TEMPORARY to crash (PR 11492).
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_builddir  are absolute
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
12 top_builddir=`cd $top_builddir; pwd`
13 PSPP=$top_builddir/src/ui/terminal/pspp
14
15 # ensure that top_srcdir is absolute
16 top_srcdir=`cd $top_srcdir; pwd`
17
18 STAT_CONFIG_PATH=$top_srcdir/config
19 export STAT_CONFIG_PATH
20
21 LANG=C
22 export LANG
23
24
25 cleanup()
26 {
27      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
28         echo "NOT cleaning $TEMPDIR" 
29         return ; 
30      fi
31      cd /
32      rm -rf $TEMPDIR
33 }
34
35
36 fail()
37 {
38     echo $activity
39     echo FAILED
40     cleanup;
41     exit 1;
42 }
43
44
45 no_result()
46 {
47     echo $activity
48     echo NO RESULT;
49     cleanup;
50     exit 2;
51 }
52
53 pass()
54 {
55     cleanup;
56     exit 0;
57 }
58
59 mkdir -p $TEMPDIR
60
61 cd $TEMPDIR
62
63 activity="create program"
64 cat > $TESTFILE <<EOF
65 DATA LIST LIST /SEX (A1) X *.
66 BEGIN DATA.
67 M 31
68 F 21
69 M 41
70 F 31
71 M 13
72 F 12
73 M 14
74 F 13
75 END DATA.
76
77
78 TEMPORARY
79 SELECT IF SEX EQ 'F'
80 FREQUENCIES /X .
81
82 FINISH
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 $SUPERVISOR $PSPP --testing-mode $TESTFILE
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89 diff -c $TEMPDIR/pspp.csv - << EOF
90 Table: Reading free-form data from INLINE.
91 Variable,Format
92 SEX,A1
93 X,F8.0
94
95 Table: X
96 Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent
97 ,12.00,1,25.00,25.00,25.00
98 ,13.00,1,25.00,25.00,50.00
99 ,21.00,1,25.00,25.00,75.00
100 ,31.00,1,25.00,25.00,100.00
101 Total,,4,100.0,100.0,
102
103 N,Valid,4
104 ,Missing,0
105 Mean,,19.25
106 Std Dev,,8.81
107 Minimum,,12.00
108 Maximum,,31.00
109 EOF
110 if [ $? -ne 0 ] ; then fail ; fi
111
112 pass;