0f303879736dcacf432e0a892992e5a40fcf124d
[pspp-builds.git] / tests / expressions / randist.sh
1 #! /bin/sh
2
3 # Tests random distribution functions.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6
7 here=`pwd`;
8
9 # ensure that top_srcdir is absolute
10 cd $top_srcdir; top_srcdir=`pwd`
11
12 export STAT_CONFIG_PATH=$top_srcdir/config
13
14
15 cleanup()
16 {
17      rm -rf $TEMPDIR
18      :
19 }
20
21
22 fail()
23 {
24     echo $activity
25     echo FAILED
26     cleanup;
27     exit 1;
28 }
29
30
31 no_result()
32 {
33     echo $activity
34     echo NO RESULT;
35     cleanup;
36     exit 2;
37 }
38
39 pass()
40 {
41     cleanup;
42     exit 0;
43 }
44
45 mkdir -p $TEMPDIR
46 cd $TEMPDIR
47
48 activity="run script to generate random distribution test command file"
49 perl $top_srcdir/tests/expressions/randist/randist.pl \
50     < $top_srcdir/tests/expressions/randist/randist.txt \
51     > randist.pspp
52 if [ $? -ne 0 ] ; then no_result ; fi
53
54 activity="run command file"
55 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \
56     $TEMPDIR/randist.pspp >$TEMPDIR/randist.err 2> $TEMPDIR/randist.out
57 if [ $? -ne 0 ] ; then fail ; fi
58
59 for d in beta cauchy chisq exp f gamma laplace logistic lnormal \
60          normal pareto t uniform weibull; do
61     activity="compare output for $d distribution"
62     diff -B -b $top_srcdir/tests/expressions/randist/$d.out $TEMPDIR/$d.out
63     if [ $? -ne 0 ] ; then fail ; fi
64 done
65
66 pass