Fix use of "export" to work with traditional shells.
[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      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create program"
52 cat > $TESTFILE <<EOF
53 DATA LIST LIST /SEX (A1) X *.
54 BEGIN DATA.
55 M 31
56 F 21
57 M 41
58 F 31
59 M 13
60 F 12
61 M 14
62 F 13
63 END DATA.
64
65
66 TEMPORARY
67 SELECT IF SEX EQ 'F'
68 FREQUENCIES /X .
69
70 FINISH
71 EOF
72 if [ $? -ne 0 ] ; then no_result ; fi
73
74 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
75 if [ $? -ne 0 ] ; then no_result ; fi
76
77 diff -b -B -w $TEMPDIR/pspp.list - << EOF
78 1.1 DATA LIST.  Reading free-form data from the command file.
79 +--------+------+
80 |Variable|Format|
81 #========#======#
82 |SEX     |A1    |
83 |X       |F8.0  |
84 +--------+------+
85
86 2.1 FREQUENCIES.  X: 
87 +-----------+--------+---------+--------+--------+--------+
88 |           |        |         |        |  Valid |   Cum  |
89 |Value Label|  Value |Frequency| Percent| Percent| Percent|
90 #===========#========#=========#========#========#========#
91 |           |   12.00|        1|    25.0|    25.0|    25.0|
92 |           |   13.00|        1|    25.0|    25.0|    50.0|
93 |           |   21.00|        1|    25.0|    25.0|    75.0|
94 |           |   31.00|        1|    25.0|    25.0|   100.0|
95 #===========#========#=========#========#========#========#
96 |               Total|        4|   100.0|   100.0|        |
97 +--------------------+---------+--------+--------+--------+
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
108 EOF
109 if [ $? -ne 0 ] ; then fail ; fi
110
111 pass;