Fix GCC 4.3 warning about uninitialized structure member.
[pspp] / 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 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      if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
26         echo "NOT cleaning $TEMPDIR" 
27         return ; 
28      fi
29      cd /
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 activity="create program"
62 cat > $TESTFILE << EOF_foobar
63 title 'Test BEGIN DATA ... END DATA'.
64
65 data list /A B 1-2.
66 list.
67 begin data.
68 12
69 34
70 56
71 78
72 90
73 end data.
74
75 data list /A B 1-2.
76 begin data.
77 09
78 87
79 65
80 43
81 21
82 end data.
83 list.
84 EOF_foobar
85 if [ $? -ne 0 ] ; then no_result ; fi
86
87
88 activity="run program"
89 $SUPERVISOR $PSPP --testing-mode $TESTFILE
90 if [ $? -ne 0 ] ; then no_result ; fi
91
92 activity="compare data"
93 perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
94 diff -b $TEMPDIR/pspp.list - << foobar
95 1.1 DATA LIST.  Reading 1 record from INLINE.
96 +--------+------+-------+------+
97 |Variable|Record|Columns|Format|
98 #========#======#=======#======#
99 |A       |     1|  1-  1|F1.0  |
100 |B       |     1|  2-  2|F1.0  |
101 +--------+------+-------+------+
102 A B
103 - -
104 1 2 
105 3 4 
106 5 6 
107 7 8 
108 9 0 
109 2.1 DATA LIST.  Reading 1 record from INLINE.
110 +--------+------+-------+------+
111 |Variable|Record|Columns|Format|
112 #========#======#=======#======#
113 |A       |     1|  1-  1|F1.0  |
114 |B       |     1|  2-  2|F1.0  |
115 +--------+------+-------+------+
116 A B
117 - -
118 0 9 
119 8 7 
120 6 5 
121 4 3 
122 2 1 
123 foobar
124 if [ $? -ne 0 ] ; then fail ; fi
125
126
127 pass;