fix bug 19819
[pspp] / tests / command / datasheet.sh
1 #!/bin/sh
2
3 # This program tests datasheet support.
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_builddir  are absolute
9 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 top_builddir=`cd $top_builddir; pwd`
12 PSPP=$top_builddir/src/ui/terminal/pspp
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 LANG=C
21 export LANG
22
23 cleanup()
24 {
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
55 cd $TEMPDIR
56
57 activity="Create File 1"
58 cat > $TESTFILE <<EOF
59 debug datasheet max=3,3 backing=0,0/progress=none/output=file("/dev/null").
60 debug datasheet max=3,3 backing=3,3/progress=none/output=file("/dev/null").
61 debug datasheet max=3,3 backing=3,1/progress=none/output=file("/dev/null").
62 debug datasheet max=3,3 backing=1,3/progress=none/output=file("/dev/null").
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66
67 activity="Run pspp 1"
68 $SUPERVISOR $PSPP --testing-mode $TESTFILE > datasheet.out
69 if [ $? -ne 0 ] ; then no_result ; fi
70
71 activity="compare results"
72 diff -b  $TEMPDIR/datasheet.out - <<EOF
73 Datasheet test max(3,3) backing(0,0) successful.
74 Datasheet test max(3,3) backing(3,3) successful.
75 Datasheet test max(3,3) backing(3,1) successful.
76 Datasheet test max(3,3) backing(1,3) successful.
77 EOF
78 if [ $? -ne 0 ] ; then fail ; fi
79
80 pass;