Checkin of new directory structure.
[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
13
14 STAT_CONFIG_PATH=$top_srcdir/config
15 export STAT_CONFIG_PATH
16
17
18 cleanup()
19 {
20      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
21         echo NOT removing directory $TEMPDIR
22         return ; 
23      fi
24      cd /
25      rm -rf $TEMPDIR
26 }
27
28
29 fail()
30 {
31     echo $activity
32     echo FAILED
33     cleanup;
34     exit 1;
35 }
36
37
38 no_result()
39 {
40     echo $activity
41     echo NO RESULT;
42     cleanup;
43     exit 2;
44 }
45
46 pass()
47 {
48     cleanup;
49     exit 0;
50 }
51
52 mkdir -p $TEMPDIR
53 cd $TEMPDIR
54
55 activity="run script to generate random distribution test command file"
56 perl $top_srcdir/tests/expressions/randist/randist.pl \
57     < $top_srcdir/tests/expressions/randist/randist.txt \
58     > randist.pspp
59 if [ $? -ne 0 ] ; then no_result ; fi
60
61 activity="run command file"
62 $SUPERVISOR $top_builddir/src/pspp --testing-mode -o raw-ascii \
63     $TEMPDIR/randist.pspp >$TEMPDIR/randist.err 2> $TEMPDIR/randist.out
64 if [ $? -ne 0 ] ; then fail ; fi
65
66 for d in beta cauchy chisq exp f gamma laplace logistic lnormal \
67          normal pareto t uniform weibull; do
68     activity="compare output for $d distribution"
69     perl -pi -e 's/^\s*$//g' $top_srcdir/tests/expressions/randist/$d.out $TEMPDIR/$d.out
70     diff -b $top_srcdir/tests/expressions/randist/$d.out $TEMPDIR/$d.out
71     if [ $? -ne 0 ] ; then fail ; fi
72 done
73
74 pass