Made tests BSD diff compatible
[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      cd /
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 /ID * ABC *.
54 begin data.
55 1 3.5
56 2 2.0
57 3 2.0
58 4 3.5
59 5 3.0
60 6 4.0
61 end data.
62
63 t-test /testval=2.0 /var=abc.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67
68 activity="run program"
69 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="compare output"
73 perl -pi -e s/^\s*\$//g $TEMPDIR/pspp.list
74 diff  -b $TEMPDIR/pspp.list - <<EOF | perl -e 's/^\s*$//g'
75 1.1 DATA LIST.  Reading free-form data from the command file.
76 +--------+------+
77 |Variable|Format|
78 #========#======#
79 |ID      |F8.0  |
80 |ABC     |F8.0  |
81 +--------+------+
82
83 2.1 T-TEST.  One-Sample Statistics
84 #===#=#====#==============#========#
85 #   #N|Mean|Std. Deviation|SE. Mean#
86 #===#=#====#==============#========#
87 #ABC#6|3.00|           .84|    .342#
88 #===#=#====#==============#========#
89
90 2.2 T-TEST.  One-Sample Test
91 #===#=====================================================#
92 #   #                Test Value = 2.000000                #
93 #   #-----+--+---------------+---------------+------------#
94 #   #     |  |               |               |    95%     #
95 #   #     |  |               |               +-----+------#
96 #   #  t  |df|Sig. (2-tailed)|Mean Difference|Lower| Upper#
97 #===#=====#==#===============#===============#=====#======#
98 #ABC#2.928| 5|           .033|          1.000|.1220|1.8780#
99 #===#=====#==#===============#===============#=====#======#
100 EOF
101 if [ $? -ne 0 ] ; then fail ; fi
102
103
104 pass