187d7ac2cad1fc4841ceb64a57de2ff53c15b3b8
[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 here=`pwd`;
10
11 # ensure that top_srcdir is absolute
12 cd $top_srcdir; top_srcdir=`pwd`
13
14 STAT_CONFIG_PATH=$top_srcdir/config
15 export STAT_CONFIG_PATH
16
17
18 cleanup()
19 {
20      cd /
21      rm -rf $TEMPDIR
22 }
23
24
25 fail()
26 {
27     echo $activity
28     echo FAILED
29     cleanup;
30     exit 1;
31 }
32
33
34 no_result()
35 {
36     echo $activity
37     echo NO RESULT;
38     cleanup;
39     exit 2;
40 }
41
42 pass()
43 {
44     cleanup;
45     exit 0;
46 }
47
48 mkdir -p $TEMPDIR
49
50 cd $TEMPDIR
51
52 activity="create program"
53 cat > $TESTFILE <<EOF
54 DATA LIST LIST /SEX (A1) X *.
55 BEGIN DATA.
56 M 31
57 F 21
58 M 41
59 F 31
60 M 13
61 F 12
62 M 14
63 F 13
64 END DATA.
65
66
67 TEMPORARY
68 SELECT IF SEX EQ 'F'
69 FREQUENCIES /X .
70
71 FINISH
72 EOF
73 if [ $? -ne 0 ] ; then no_result ; fi
74
75 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
76 if [ $? -ne 0 ] ; then no_result ; fi
77
78 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
79 diff -b  -w $TEMPDIR/pspp.list - << EOF
80 1.1 DATA LIST.  Reading free-form data from INLINE.
81 +--------+------+
82 |Variable|Format|
83 #========#======#
84 |SEX     |A1    |
85 |X       |F8.0  |
86 +--------+------+
87 2.1 FREQUENCIES.  X: 
88 +-----------+--------+---------+--------+--------+--------+
89 |           |        |         |        |  Valid |   Cum  |
90 |Value Label|  Value |Frequency| Percent| Percent| Percent|
91 #===========#========#=========#========#========#========#
92 |           |   12.00|        1|    25.0|    25.0|    25.0|
93 |           |   13.00|        1|    25.0|    25.0|    50.0|
94 |           |   21.00|        1|    25.0|    25.0|    75.0|
95 |           |   31.00|        1|    25.0|    25.0|   100.0|
96 #===========#========#=========#========#========#========#
97 |               Total|        4|   100.0|   100.0|        |
98 +--------------------+---------+--------+--------+--------+
99 +---------------+------+
100 |N       Valid  |     4|
101 |        Missing|     0|
102 |Mean           |19.250|
103 |Std Dev        | 8.808|
104 |Minimum        |12.000|
105 |Maximum        |31.000|
106 +---------------+------+
107 EOF
108 if [ $? -ne 0 ] ; then fail ; fi
109
110 pass;