Fix use of "export" to work with traditional shells.
[pspp-builds.git] / tests / command / t-test-1s.sh
1 #!/bin/sh
2
3 # This program tests that the T-TEST /TESTVAL command works OK
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      rm -rf $TEMPDIR
20 }
21
22
23 fail()
24 {
25     echo $activity
26     echo FAILED
27     cleanup;
28     exit 1;
29 }
30
31
32 no_result()
33 {
34     echo $activity
35     echo NO RESULT;
36     cleanup;
37     exit 2;
38 }
39
40 pass()
41 {
42     cleanup;
43     exit 0;
44 }
45
46 mkdir -p $TEMPDIR
47
48 cd $TEMPDIR
49
50 activity="create program"
51 cat > $TESTFILE <<EOF
52 data list list /ID * ABC *.
53 begin data.
54 1 3.5
55 2 2.0
56 3 2.0
57 4 3.5
58 5 3.0
59 6 4.0
60 end data.
61
62 t-test /testval=2.0 /var=abc.
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66
67 activity="run program"
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="compare output"
72 diff -B -b $TEMPDIR/pspp.list - <<EOF
73 1.1 DATA LIST.  Reading free-form data from the command file.
74 +--------+------+
75 |Variable|Format|
76 #========#======#
77 |ID      |F8.0  |
78 |ABC     |F8.0  |
79 +--------+------+
80
81 2.1 T-TEST.  One-Sample Statistics
82 #===#=#====#==============#========#
83 #   #N|Mean|Std. Deviation|SE. Mean#
84 #===#=#====#==============#========#
85 #ABC#6|3.00|           .84|    .342#
86 #===#=#====#==============#========#
87
88 2.2 T-TEST.  One-Sample Test
89 #===#=====================================================#
90 #   #                Test Value = 2.000000                #
91 #   #-----+--+---------------+---------------+------------#
92 #   #     |  |               |               |    95%     #
93 #   #     |  |               |               +-----+------#
94 #   #  t  |df|Sig. (2-tailed)|Mean Difference|Lower| Upper#
95 #===#=====#==#===============#===============#=====#======#
96 #ABC#2.928| 5|           .033|          1.000|.1220|1.8780#
97 #===#=====#==#===============#===============#=====#======#
98 EOF
99 if [ $? -ne 0 ] ; then fail ; fi
100
101
102 pass