Fix GCC 4.3 warning about uninitialized structure member.
[pspp] / tests / command / get-data-gnm.sh
1 #!/bin/sh
2
3 # This program tests that pspp can read gnumeric files
4
5 TEMPDIR=/tmp/pspp-tst-$$
6 TESTFILE=$TEMPDIR/`basename $0`.sps
7
8 # ensure that top_srcdir and top_builddir  are absolute
9 if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
10 if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
11 top_srcdir=`cd $top_srcdir; pwd`
12 top_builddir=`cd $top_builddir; pwd`
13
14 PSPP=$top_builddir/src/ui/terminal/pspp
15
16 STAT_CONFIG_PATH=$top_srcdir/config
17 export STAT_CONFIG_PATH
18
19 LANG=C
20 export LANG
21
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="zip the gnm file and place it in the test directory"
62 gzip -c $top_srcdir/tests/Book1.gnm.unzipped > $TEMPDIR/Book1.gnumeric
63 if [ $? -ne 0 ] ; then no_result ; fi
64
65 activity="create program 1"
66 cat > $TESTFILE <<EOF
67 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric'  /READNAMES=off /SHEET=name 'This' /CELLRANGE=range 'g9:i13' .
68 DISPLAY VARIABLES.
69 LIST.
70
71
72 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric'  /READNAMES=on /SHEET=name 'This' /CELLRANGE=range 'g8:i13' .
73 DISPLAY VARIABLES.
74 LIST.
75
76
77 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /SHEET=index 3.
78 DISPLAY VARIABLES.
79 LIST.
80
81 * This sheet has no data in one of its variables
82 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /READNAMES=on /SHEET=index 5.
83 DISPLAY VARIABLES.
84 LIST.
85
86 EOF
87 if [ $? -ne 0 ] ; then no_result ; fi
88
89 activity="run program 1"
90 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
91 if [ $? -ne 0 ] ; then no_result ; fi
92
93
94 activity="compare output 1"
95 diff $TEMPDIR/pspp.list - <<EOF
96 1.1 DISPLAY.  
97 +--------+-------------------------------------------+--------+
98 |Variable|Description                                |Position|
99 #========#===========================================#========#
100 |VAR001  |Format: F8.2                               |       1|
101 |        |Measure: Scale                             |        |
102 |        |Display Alignment: Right                   |        |
103 |        |Display Width: 8                           |        |
104 +--------+-------------------------------------------+--------+
105 |VAR002  |Format: A8                                 |       2|
106 |        |Measure: Nominal                           |        |
107 |        |Display Alignment: Left                    |        |
108 |        |Display Width: 8                           |        |
109 +--------+-------------------------------------------+--------+
110 |VAR003  |Format: F8.2                               |       3|
111 |        |Measure: Scale                             |        |
112 |        |Display Alignment: Right                   |        |
113 |        |Display Width: 8                           |        |
114 +--------+-------------------------------------------+--------+
115
116   VAR001   VAR002   VAR003
117 -------- -------- --------
118      .00 fred        20.00 
119     1.00 11          21.00 
120     2.00 twelve      22.00 
121     3.00 13          23.00 
122     4.00 14          24.00 
123
124 2.1 DISPLAY.  
125 +--------+-------------------------------------------+--------+
126 |Variable|Description                                |Position|
127 #========#===========================================#========#
128 |V1      |Format: F8.2                               |       1|
129 |        |Measure: Scale                             |        |
130 |        |Display Alignment: Right                   |        |
131 |        |Display Width: 8                           |        |
132 +--------+-------------------------------------------+--------+
133 |V2      |Format: A8                                 |       2|
134 |        |Measure: Nominal                           |        |
135 |        |Display Alignment: Left                    |        |
136 |        |Display Width: 8                           |        |
137 +--------+-------------------------------------------+--------+
138 |VAR001  |Format: F8.2                               |       3|
139 |        |Measure: Scale                             |        |
140 |        |Display Alignment: Right                   |        |
141 |        |Display Width: 8                           |        |
142 +--------+-------------------------------------------+--------+
143
144       V1       V2   VAR001
145 -------- -------- --------
146      .00 fred        20.00 
147     1.00 11          21.00 
148     2.00 twelve      22.00 
149     3.00 13          23.00 
150     4.00 14          24.00 
151
152 3.1 DISPLAY.  
153 +--------+-------------------------------------------+--------+
154 |Variable|Description                                |Position|
155 #========#===========================================#========#
156 |name    |Format: A8                                 |       1|
157 |        |Measure: Nominal                           |        |
158 |        |Display Alignment: Left                    |        |
159 |        |Display Width: 8                           |        |
160 +--------+-------------------------------------------+--------+
161 |id      |Format: F8.2                               |       2|
162 |        |Measure: Scale                             |        |
163 |        |Display Alignment: Right                   |        |
164 |        |Display Width: 8                           |        |
165 +--------+-------------------------------------------+--------+
166 |height  |Format: F8.2                               |       3|
167 |        |Measure: Scale                             |        |
168 |        |Display Alignment: Right                   |        |
169 |        |Display Width: 8                           |        |
170 +--------+-------------------------------------------+--------+
171
172     name       id   height
173 -------- -------- --------
174 fred          .00    23.40 
175 bert         1.00      .56 
176 charlie      2.00      .   
177 dick         3.00   -34.09 
178
179 4.1 DISPLAY.  
180 +--------+-------------------------------------------+--------+
181 |Variable|Description                                |Position|
182 #========#===========================================#========#
183 |vone    |Format: F8.2                               |       1|
184 |        |Measure: Scale                             |        |
185 |        |Display Alignment: Right                   |        |
186 |        |Display Width: 8                           |        |
187 +--------+-------------------------------------------+--------+
188 |vtwo    |Format: F8.2                               |       2|
189 |        |Measure: Scale                             |        |
190 |        |Display Alignment: Right                   |        |
191 |        |Display Width: 8                           |        |
192 +--------+-------------------------------------------+--------+
193 |vthree  |Format: A8                                 |       3|
194 |        |Measure: Nominal                           |        |
195 |        |Display Alignment: Left                    |        |
196 |        |Display Width: 8                           |        |
197 +--------+-------------------------------------------+--------+
198 |v4      |Format: F8.2                               |       4|
199 |        |Measure: Scale                             |        |
200 |        |Display Alignment: Right                   |        |
201 |        |Display Width: 8                           |        |
202 +--------+-------------------------------------------+--------+
203
204     vone     vtwo   vthree       v4
205 -------- -------- -------- --------
206     1.00     3.00              5.00 
207     2.00     4.00              6.00 
208
209 EOF
210 if [ $? -ne 0 ] ; then fail ; fi
211
212
213 activity="create program 2"
214 cat > $TESTFILE <<EOF
215 * This sheet is empty
216 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /SHEET=name 'Empty'.
217
218
219 * This sheet doesnt exist
220 GET DATA /TYPE=gnm /FILE='$TEMPDIR/Book1.gnumeric' /SHEET=name 'foobarxx'.
221
222 EOF
223 if [ $? -ne 0 ] ; then no_result ; fi
224
225 activity="run program 2"
226 $SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE > /dev/null
227 if [ $? -ne 0 ] ; then fail ; fi
228
229 activity="compare output 2"
230 diff $TEMPDIR/pspp.list - <<EOF
231 warning: Selected sheet or range of spreadsheet "$TEMPDIR/Book1.gnumeric" is empty.
232 warning: Selected sheet or range of spreadsheet "$TEMPDIR/Book1.gnumeric" is empty.
233
234 EOF
235 if [ $? -ne 0 ] ; then fail ; fi
236
237 pass;