Bug #21128. Reviewed by John Darrington.
[pspp-builds.git] / tests / output / paper-size.sh
1 #!/bin/sh
2
3 # This program tests paper size support.
4
5 TEMPDIR=/tmp/pspp-tst-$$
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
12
13 # ensure that top_srcdir is absolute
14 top_srcdir=`cd $top_srcdir; pwd`
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
22 cleanup()
23 {
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
54 cd $TEMPDIR
55
56 activity="Create File 1"
57 cat > paper-size.pspp <<EOF
58 debug paper size ''.
59 debug paper size 'a4'.
60 debug paper size 'letter'.
61 debug paper size '10x14in'.
62 debug paper size '210x297mm'.
63 EOF
64 if [ $? -ne 0 ] ; then no_result ; fi
65
66 activity="Run pspp 1"
67 PAPERSIZE=letter $SUPERVISOR $PSPP --testing-mode paper-size.pspp > paper-size.out
68 if [ $? -ne 0 ] ; then no_result ; fi
69
70 activity="compare results"
71 diff -b  $TEMPDIR/paper-size.out - <<EOF
72 "" => 8.5 x 11.0 in, 216 x 279 mm
73 "a4" => 8.3 x 11.7 in, 210 x 297 mm
74 "letter" => 8.5 x 11.0 in, 216 x 279 mm
75 "10x14in" => 10.0 x 14.0 in, 254 x 356 mm
76 "210x297mm" => 8.3 x 11.7 in, 210 x 297 mm
77 EOF
78 if [ $? -ne 0 ] ; then fail ; fi
79
80 activity="Create File 2"
81 cat > paper-size-2.pspp <<EOF
82 debug paper size ''.
83 EOF
84 if [ $? -ne 0 ] ; then no_result ; fi
85
86 activity="Run pspp 2"
87 PAPERSIZE=a4 $SUPERVISOR $PSPP --testing-mode paper-size-2.pspp > paper-size-2.out
88 if [ $? -ne 0 ] ; then no_result ; fi
89
90 activity="compare results 2"
91 diff -b  $TEMPDIR/paper-size-2.out - <<EOF
92 "" => 8.3 x 11.7 in, 210 x 297 mm
93 EOF
94 if [ $? -ne 0 ] ; then fail ; fi
95
96 pass;