Checkin of new directory structure.
[pspp-builds.git] / tests / command / beg-data.sh
1 #!/bin/sh
2
3 # This program tests the BEGIN DATA / END DATA commands
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
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
20 cleanup()
21 {
22      cd /
23      rm -rf $TEMPDIR
24 }
25
26
27 fail()
28 {
29     echo $activity
30     echo FAILED
31     cleanup;
32     exit 1;
33 }
34
35
36 no_result()
37 {
38     echo $activity
39     echo NO RESULT;
40     cleanup;
41     exit 2;
42 }
43
44 pass()
45 {
46     cleanup;
47     exit 0;
48 }
49
50 mkdir -p $TEMPDIR
51
52 cd $TEMPDIR
53
54 activity="create program"
55 cat > $TESTFILE << EOF_foobar
56 title 'Test BEGIN DATA ... END DATA'.
57
58 data list /A B 1-2.
59 list.
60 begin data.
61 12
62 34
63 56
64 78
65 90
66 end data.
67
68 data list /A B 1-2.
69 begin data.
70 09
71 87
72 65
73 43
74 21
75 end data.
76 list.
77 EOF_foobar
78 if [ $? -ne 0 ] ; then no_result ; fi
79
80
81 activity="run program"
82 $SUPERVISOR $top_builddir/src/pspp -o raw-ascii $TESTFILE
83 if [ $? -ne 0 ] ; then no_result ; fi
84
85 activity="compare data"
86 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
87 diff -b $TEMPDIR/pspp.list - << foobar
88 1.1 DATA LIST.  Reading 1 record from INLINE.
89 +--------+------+-------+------+
90 |Variable|Record|Columns|Format|
91 #========#======#=======#======#
92 |A       |     1|  1-  1|F1.0  |
93 |B       |     1|  2-  2|F1.0  |
94 +--------+------+-------+------+
95 A B
96 - -
97 1 2 
98 3 4 
99 5 6 
100 7 8 
101 9 0 
102 2.1 DATA LIST.  Reading 1 record from INLINE.
103 +--------+------+-------+------+
104 |Variable|Record|Columns|Format|
105 #========#======#=======#======#
106 |A       |     1|  1-  1|F1.0  |
107 |B       |     1|  2-  2|F1.0  |
108 +--------+------+-------+------+
109 A B
110 - -
111 0 9 
112 8 7 
113 6 5 
114 4 3 
115 2 1 
116 foobar
117 if [ $? -ne 0 ] ; then fail ; fi
118
119
120 pass;