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