Fix use of "export" to work with traditional shells.
[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 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      rm -rf $TEMPDIR
23 }
24
25
26 fail()
27 {
28     echo $activity
29     echo FAILED
30     cleanup;
31     exit 1;
32 }
33
34
35 no_result()
36 {
37     echo $activity
38     echo NO RESULT;
39     cleanup;
40     exit 2;
41 }
42
43 pass()
44 {
45     cleanup;
46     exit 0;
47 }
48
49 mkdir -p $TEMPDIR
50 cd $TEMPDIR
51
52 activity="run script to generate random distribution test command file"
53 perl $top_srcdir/tests/expressions/randist/randist.pl \
54     < $top_srcdir/tests/expressions/randist/randist.txt \
55     > randist.pspp
56 if [ $? -ne 0 ] ; then no_result ; fi
57
58 activity="run command file"
59 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii \
60     $TEMPDIR/randist.pspp >$TEMPDIR/randist.err 2> $TEMPDIR/randist.out
61 if [ $? -ne 0 ] ; then fail ; fi
62
63 for d in beta cauchy chisq exp f gamma laplace logistic lnormal \
64          normal pareto t uniform weibull; do
65     activity="compare output for $d distribution"
66     diff -B -b $top_srcdir/tests/expressions/randist/$d.out $TEMPDIR/$d.out
67     if [ $? -ne 0 ] ; then fail ; fi
68 done
69
70 pass