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