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