7c97e4458af3f6e42e1d419df7703f1ac7030d86
[pspp-builds.git] / tests / command / n_of_cases.sh
1 #!/bin/sh
2
3 # This program tests the N OF CASES command to make sure
4 # that it actually works.
5
6 TEMPDIR=/tmp/pspp-tst-$$
7 TESTFILE=$TEMPDIR/`basename $0`.sps
8
9 # ensure that top_srcdir and top_builddir  are absolute
10 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
11 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
12 top_srcdir=`cd $top_srcdir; pwd`
13 top_builddir=`cd $top_builddir; pwd`
14
15 PSPP=$top_builddir/src/ui/terminal/pspp
16
17 STAT_CONFIG_PATH=$top_srcdir/config
18 export STAT_CONFIG_PATH
19
20 LANG=C
21 export LANG
22
23
24 cleanup()
25 {
26      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
27         echo "NOT cleaning $TEMPDIR"
28         return ; 
29      fi
30      rm -rf $TEMPDIR
31 }
32
33
34 fail()
35 {
36     echo $activity
37     echo FAILED
38     cleanup;
39     exit 1;
40 }
41
42
43 no_result()
44 {
45     echo $activity
46     echo NO RESULT;
47     cleanup;
48     exit 2;
49 }
50
51 pass()
52 {
53     cleanup;
54     exit 0;
55 }
56
57 mkdir -p $TEMPDIR
58
59 cd $TEMPDIR
60
61 cat > $TESTFILE <<EOF
62 INPUT PROGRAM.
63 LOOP #I = 1 TO 100.
64 COMPUTE X=#I.
65 END CASE.
66 END LOOP.
67 END FILE.
68 END INPUT PROGRAM.
69
70 N OF CASES 15.
71
72 LIST.
73 EOF
74 if [ $? -ne 0 ] ; then no_result ; fi
75
76
77 activity="run program"
78 $SUPERVISOR $PSPP --testing-mode $TESTFILE
79 if [ $? -ne 0 ] ; then no_result ; fi
80
81
82 activity="compare output"
83 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
84 diff -b  $TEMPDIR/pspp.list - <<EOF
85        X
86 --------
87     1.00 
88     2.00 
89     3.00 
90     4.00 
91     5.00 
92     6.00 
93     7.00 
94     8.00 
95     9.00 
96    10.00 
97    11.00 
98    12.00 
99    13.00 
100    14.00 
101    15.00 
102 EOF
103 if [ $? -ne 0 ] ; then fail ; fi
104
105
106 pass;