LOOP: Convert tests to Autotest framework.
[pspp] / tests / formats / num-out.sh
1 #! /bin/sh
2
3 TEMPDIR=/tmp/pspp-tst-$$
4 mkdir -p $TEMPDIR
5 trap 'cd /; rm -rf $TEMPDIR' 0
6
7 # ensure that top_builddir  are absolute
8 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 top_builddir=`cd $top_builddir; pwd`
11 PSPP=$top_builddir/src/ui/terminal/pspp$EXEEXT
12 : ${PERL:=perl}
13
14 # ensure that top_srcdir is absolute
15 top_srcdir=`cd $top_srcdir; pwd`
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 fail()
21 {
22     echo $activity
23     echo FAILED
24     exit 1;
25 }
26
27
28 no_result()
29 {
30     echo $activity
31     echo NO RESULT;
32     exit 2;
33 }
34
35 pass()
36 {
37     exit 0;
38 }
39
40 cd $TEMPDIR
41
42 activity="generate pspp syntax"
43 $PERL $top_srcdir/tests/formats/num-out.pl > num-out.pspp
44 if [ $? -ne 0 ] ; then no_result ; fi
45 echo -n .
46
47 activity="run program"
48 $SUPERVISOR $PSPP -o pspp.csv num-out.pspp
49 if [ $? -ne 0 ] ; then no_result ; fi
50 echo -n .
51
52 activity="inexactify results"
53 $top_builddir/tests/formats/inexactify$EXEEXT < output.txt > output.inexact
54 if [ $? -ne 0 ] ; then no_result ; fi
55 echo -n .
56
57 activity="gunzip expected results"
58 gzip -cd < $top_srcdir/tests/formats/num-out.expected.cmp.gz > expected.txt.cmp
59 if [ $? -ne 0 ] ; then no_result ; fi
60 echo -n .
61
62 activity="decompress expected results"
63 $PERL $top_srcdir/tests/formats/num-out-decmp.pl < expected.txt.cmp > expected.txt
64 if [ $? -ne 0 ] ; then no_result ; fi
65 echo -n .
66
67 activity="inexactify expected results"
68 $top_builddir/tests/formats/inexactify$EXEEXT < expected.txt > expected.inexact
69 if [ $? -ne 0 ] ; then no_result ; fi
70 echo -n .
71
72 activity="compare output"
73 $PERL $top_srcdir/tests/formats/num-out-compare.pl \
74         $PSPP_NUM_OUT_COMPARE_FLAGS expected.inexact output.inexact
75 if [ $? -ne 0 ] ; then fail ; fi
76
77 echo .
78
79 pass