1d8b05e729a48a179c7a9c5930d69b03c3e13f1c
[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 export STAT_CONFIG_PATH=$top_srcdir/config
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 set seed=10.
53 input program.
54 + loop #i = 1 to 20.
55 +    do repeat response=R1.
56 +       compute response = uniform(10).
57 +    end repeat.
58 +    end case.
59 + end loop.
60 + end file.
61 end input program.                                                              
62
63 list.
64 EOF
65 if [ $? -ne 0 ] ; then no_result ; fi
66
67 activity="run program"
68 $SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71
72 activity="compare output"
73 diff -b -B -w $TEMPDIR/pspp.list - << EOF
74       R1
75 --------
76      7.71 
77      2.99 
78       .21 
79      4.95 
80      6.34 
81      4.43 
82      7.49 
83      8.32 
84      4.99 
85      5.83 
86      2.25 
87       .25 
88      1.98 
89      7.09 
90      7.61 
91      2.66 
92      1.69 
93      2.64 
94       .88 
95      1.50 
96
97 EOF
98 if [ $? -ne 0 ] ; then fail ; fi
99
100 pass;