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