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