Sat Jul 30 21:54:23 2005 Ben Pfaff <blp@gnu.org>
[pspp-builds.git] / tests / bugs / random.sh
1 #!/bin/sh
2
3 # This program tests for a bug which caused UNIFORM(x) to always return zero.
4
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      cd /
21      rm -rf $TEMPDIR
22 }
23
24
25 fail()
26 {
27     echo $activity
28     echo FAILED
29     cleanup;
30     exit 1;
31 }
32
33
34 no_result()
35 {
36     echo $activity
37     echo NO RESULT;
38     cleanup;
39     exit 2;
40 }
41
42 pass()
43 {
44     cleanup;
45     exit 0;
46 }
47
48 mkdir -p $TEMPDIR
49
50 cd $TEMPDIR
51
52 activity="create program"
53 cat > $TESTFILE <<EOF
54 set seed=10.
55 input program.
56 + loop #i = 1 to 20.
57 +    do repeat response=R1.
58 +       compute response = uniform(10).
59 +    end repeat.
60 +    end case.
61 + end loop.
62 + end file.
63 end input program.                                                              
64
65 list.
66 EOF
67 if [ $? -ne 0 ] ; then no_result ; fi
68
69 activity="run program"
70 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
71 if [ $? -ne 0 ] ; then no_result ; fi
72
73
74 activity="compare output"
75 diff -b -B -w $TEMPDIR/pspp.list - << EOF
76       R1
77 --------
78      7.71 
79      2.99 
80       .21 
81      4.95 
82      6.34 
83      4.43 
84      7.49 
85      8.32 
86      4.99 
87      5.83 
88      2.25 
89       .25 
90      1.98 
91      7.09 
92      7.61 
93      2.66 
94      1.69 
95      2.64 
96       .88 
97      1.50 
98
99 EOF
100 if [ $? -ne 0 ] ; then fail ; fi
101
102 pass;