b0943ed545da807f6c8381b9f22f4fc877974b62
[pspp-builds.git] / tests / command / loop.sh
1 #!/bin/sh
2
3 # This program tests the LOOP command
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 here=`pwd`;
9
10 # ensure that top_srcdir is absolute
11 cd $top_srcdir; top_srcdir=`pwd`
12
13 STAT_CONFIG_PATH=$top_srcdir/config
14 export STAT_CONFIG_PATH
15
16
17 cleanup()
18 {
19      cd /
20      rm -rf $TEMPDIR
21 }
22
23
24 fail()
25 {
26     echo $activity
27     echo FAILED
28     cleanup;
29     exit 1;
30 }
31
32
33 no_result()
34 {
35     echo $activity
36     echo NO RESULT;
37     cleanup;
38     exit 2;
39 }
40
41 pass()
42 {
43     cleanup;
44     exit 0;
45 }
46
47 mkdir -p $TEMPDIR
48
49 cd $TEMPDIR
50
51 activity="create prog"
52 cat > $TEMPDIR/loop.stat <<EOF
53 data list /X 1 Y 2 ZOOLOGICAL 3.
54 begin data.
55 125
56 256
57 397
58 401
59 end data.
60 loop iterative_Variable=y to zoological by abs(zoological-y)/(zoological-y).
61 print /x iterative_Variable.
62 break.          /* Generates warning.
63 end loop.
64 execute.
65 EOF
66 if [ $? -ne 0 ] ; then no_result ; fi
67
68 activity="run program"
69 $SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TEMPDIR/loop.stat > $TEMPDIR/stdout
70 if [ $? -ne 0 ] ; then no_result ; fi
71
72 activity="compare stdout"
73 perl -pi -e 's/^\s*$//g' $TEMPDIR/stdout
74 diff -b $TEMPDIR/stdout  - <<EOF
75 EOF
76 if [ $? -ne 0 ] ; then fail ; fi
77
78 activity="compare results"
79 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
80 diff  -b $TEMPDIR/pspp.list  - <<EOF
81 1.1 DATA LIST.  Reading 1 record from INLINE.
82 +----------+------+-------+------+
83 | Variable |Record|Columns|Format|
84 #==========#======#=======#======#
85 |X         |     1|  1-  1|F1.0  |
86 |Y         |     1|  2-  2|F1.0  |
87 |ZOOLOGICAL|     1|  3-  3|F1.0  |
88 +----------+------+-------+------+
89 1     2.00 
90 2     5.00 
91 3     9.00 
92 4      .00 
93 EOF
94 if [ $? -ne 0 ] ; then fail ; fi
95
96
97 pass;