afe3bff3b5d87195ebad697c8d048706bcb0445c
[pspp] / tests / data / sys-file-reader.at
1 dnl PSPP - a program for statistical analysis.
2 dnl Copyright (C) 2017 Free Software Foundation, Inc.
3 dnl 
4 dnl This program is free software: you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation, either version 3 of the License, or
7 dnl (at your option) any later version.
8 dnl 
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 dnl GNU General Public License for more details.
13 dnl 
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 dnl
17 AT_BANNER([system file reader - positive])
18
19 AT_SETUP([variable labels and missing values])
20 AT_KEYWORDS([sack synthetic system file positive])
21 AT_DATA([sys-file.sack], [dnl
22 dnl File header.
23 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
24 2; dnl Layout code
25 28; dnl Nominal case size
26 0; dnl Not compressed
27 0; dnl Not weighted
28 1; dnl 1 case.
29 100.0; dnl Bias.
30 "01 Jan 11"; "20:53:52";
31 "PSPP synthetic test file: "; i8 244; i8 245; i8 246; i8 248; s34 "";
32 i8 0 *3;
33
34 dnl Numeric variable, no label or missing values.
35 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
36
37 dnl Numeric variable, variable label.
38 2; 0; 1; 0; 0x050800 *2; s8 "NUM2";
39 32; "Numeric variable 2's label ("; i8 249; i8 250; i8 251; ")";
40
41 dnl Numeric variable, one missing value.
42 2; 0; 0; 1; 0x050800 *2; s8 "NUM3";
43 1.0;
44
45 dnl Numeric variable, variable label and missing value.
46 2; 0; 1; 1; 0x050800 *2; s8 "NUM4";
47 30; "Another numeric variable label"; i8 0 * 2;
48 1.0;
49
50 dnl Numeric variable, two missing values.
51 2; 0; 0; 2; 0x050800 *2; s8 "NUM5"; 1.0; 2.0;
52
53 dnl Numeric variable, three missing values.
54 2; 0; 0; 3; 0x050800 *2; s8 "NUM6"; 1.0; 2.0; 3.0;
55
56 dnl Numeric variable, range of missing values.
57 2; 0; 0; -2; 0x050800 *2; s8 "NUM7"; 1.0; 3.0;
58
59 dnl Numeric variables, range of missing values plus discrete value.
60 2; 0; 0; -3; 0x050800 *2; s8 "NUM8"; 1.0; 3.0; 5.0;
61 2; 0; 0; -3; 0x050800 *2; s8 "NUM9"; 1.0; HIGHEST; -5.0;
62 2; 0; 0; -3; 0x050800 *2; "NUM"; i8 192; i8 200; i8 204; i8 209; i8 210;
63 LOWEST; 1.0; 5.0;
64
65 dnl String variable, no label or missing values.
66 2; 4; 0; 0; 0x010400 *2; s8 "STR1";
67
68 dnl String variable, variable label.
69 2; 4; 1; 0; 0x010400 *2; s8 "STR2";
70 25; "String variable 2's label"; i8 0 * 3;
71
72 dnl String variable, one missing value.
73 2; 4; 0; 1; 0x010400 *2; s8 "STR3"; s8 "MISS";
74
75 dnl String variable, variable label and missing value.
76 2; 4; 1; 1; 0x010400 *2; s8 "STR4";
77 29; "Another string variable label"; i8 0 * 3;
78 s8 "OTHR";
79
80 dnl String variable, two missing values.
81 2; 4; 0; 2; 0x010400 *2; s8 "STR5"; s8 "MISS"; s8 "OTHR";
82
83 dnl String variable, three missing values.
84 2; 4; 0; 3; 0x010400 *2; s8 "STR6"; s8 "MISS"; s8 "OTHR"; s8 "MORE";
85
86 dnl Long string variable, one missing value.
87 dnl (This is not how SPSS represents missing values for long strings--it
88 dnl uses a separate record as shown later below--but old versions of PSPP
89 dnl did use this representation so we continue supporting it for backward
90 dnl compatibility.
91 2; 11; 0; 1; 0x010b00 *2; s8 "STR7"; "first8by";
92 2; -1; 0; 0; 0; 0; s8 "";
93
94 dnl Long string variables that will have missing values added with a
95 dnl later record.
96 2; 9; 0; 0; 0x010900 *2; s8 "STR8";
97 2; -1; 0; 0; 0; 0; s8 "";
98 2; 10; 0; 0; 0x010a00 *2; s8 "STR9";
99 2; -1; 0; 0; 0; 0; s8 "";
100 2; 11; 0; 0; 0x010b00 *2; s8 "STR10";
101 2; -1; 0; 0; 0; 0; s8 "";
102
103 dnl Long string variable, value label.
104 2; 25; 1; 0; 0x011900 *2; s8 "STR11"; 14; "25-byte string"; i8 0 * 2;
105 ( 2; -1; 0; 0; 0; 0; s8 ""; ) * 2;
106 dnl Variable label fields on continuation records have been spotted in system
107 dnl files created by "SPSS Power Macintosh Release 6.1".
108 2; -1; 1; 0; 0; 0; s8 ""; 20; "dummy variable label";
109
110 dnl Machine integer info record.
111 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
112
113 dnl Machine floating-point info record.
114 7; 4; 8; 3; SYSMIS; HIGHEST; LOWEST;
115
116 dnl Long string variable missing values record.
117 7; 22; 1; COUNT (
118 dnl One missing value for STR8.
119 COUNT("STR8"); i8 1; 8; "abcdefgh";
120
121 dnl Two missing values for STR9.
122 COUNT("STR9"); i8 2; 8; "abcdefgh"; 8; "01234567";
123
124 dnl Three missing values for STR9.
125 COUNT("STR10"); i8 3; 8; "abcdefgh"; 8; "01234567"; 8; "0       ";
126 );
127
128 dnl Character encoding record.
129 7; 20; 1; 12; "windows-1252";
130
131 dnl Dictionary termination record.
132 999; 0;
133
134 dnl Data.
135 1.0; 2.0; 3.0; 4.0; 5.0; 6.0; 7.0; 8.0; 9.0; 10.0;
136 s8 "abcd"; s8 "efgh"; s8 "ijkl"; s8 "mnop"; s8 "qrst"; s8 "uvwx";
137 s16 "yzABCDEFGHI"; s16 "JKLMNOPQR"; s16 "STUVWXYZ01";
138 s16 "23456789abc"; s32 "defghijklmnopqstuvwxyzABC";
139 ])
140 for variant in be le; do
141   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
142   AT_DATA([sys-file.sps], [dnl
143 GET FILE='sys-file.sav'.
144 DISPLAY FILE LABEL.
145 DISPLAY DICTIONARY.
146 LIST.
147 ])
148   AT_CHECK([pspp -o pspp.csv sys-file.sps])
149   AT_CHECK([cat pspp.csv], [0], [dnl
150 File label: PSPP synthetic test file: ôõöø
151
152 Table: Variables
153 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
154 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
155 num2,2,Numeric variable 2's label (ùúû),Scale,Input,8,Right,F8.0,F8.0,
156 num3,3,,Scale,Input,8,Right,F8.0,F8.0,1
157 num4,4,Another numeric variable label,Scale,Input,8,Right,F8.0,F8.0,1
158 num5,5,,Scale,Input,8,Right,F8.0,F8.0,1; 2
159 num6,6,,Scale,Input,8,Right,F8.0,F8.0,1; 2; 3
160 num7,7,,Scale,Input,8,Right,F8.0,F8.0,1 THRU 3
161 num8,8,,Scale,Input,8,Right,F8.0,F8.0,1 THRU 3; 5
162 num9,9,,Scale,Input,8,Right,F8.0,F8.0,1 THRU HIGHEST; -5
163 numàèìñò,10,,Scale,Input,8,Right,F8.0,F8.0,LOWEST THRU 1; 5
164 str1,11,,Nominal,Input,4,Left,A4,A4,
165 str2,12,String variable 2's label,Nominal,Input,4,Left,A4,A4,
166 str3,13,,Nominal,Input,4,Left,A4,A4,"""MISS"""
167 str4,14,Another string variable label,Nominal,Input,4,Left,A4,A4,"""OTHR"""
168 str5,15,,Nominal,Input,4,Left,A4,A4,"""MISS""; ""OTHR"""
169 str6,16,,Nominal,Input,4,Left,A4,A4,"""MISS""; ""OTHR""; ""MORE"""
170 str7,17,,Nominal,Input,11,Left,A11,A11,"""first8by"""
171 str8,18,,Nominal,Input,9,Left,A9,A9,"""abcdefgh"""
172 str9,19,,Nominal,Input,10,Left,A10,A10,"""abcdefgh""; ""01234567"""
173 str10,20,,Nominal,Input,11,Left,A11,A11,"""abcdefgh""; ""01234567""; ""0       """
174 str11,21,25-byte string,Nominal,Input,25,Left,A25,A25,
175
176 Table: Data List
177 num1,num2,num3,num4,num5,num6,num7,num8,num9,numàèìñò,str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11
178 1,2,3,4,5,6,7,8,9,10,abcd,efgh,ijkl,mnop,qrst,uvwx,yzABCDEFGHI,JKLMNOPQR,STUVWXYZ01,23456789abc,defghijklmnopqstuvwxyzABC
179 ])
180 done
181 AT_CLEANUP
182
183 AT_SETUP([unspecified number of variable positions])
184 AT_KEYWORDS([sack synthetic system file positive])
185 AT_DATA([sys-file.sack], [dnl
186 dnl File header.
187 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
188 2; dnl Layout code
189 -1; dnl Nominal case size (unspecified)
190 0; dnl Not compressed
191 0; dnl Not weighted 
192 1; dnl 1 case.
193 100.0; dnl Bias.
194 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
195 i8 0 *3;
196
197 dnl Numeric variable, no label or missing values.
198 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
199
200 dnl Numeric variable, variable label.
201 2; 0; 1; 0; 0x050800 *2; s8 "NUM2";
202 26; "Numeric variable 2's label"; i8 0 *2;
203
204 dnl Character encoding record.
205 7; 20; 1; 12; "windows-1252";
206
207 dnl Dictionary termination record.
208 999; 0;
209
210 dnl Data.
211 1.0; 2.0; 
212 ])
213 for variant in be le; do
214   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
215   AT_DATA([sys-file.sps], [dnl
216 GET FILE='sys-file.sav'.
217 DISPLAY DICTIONARY.
218 LIST.
219 ])
220   AT_CHECK([pspp -o pspp.csv sys-file.sps])
221   AT_CHECK([cat pspp.csv], [0], [dnl
222 Table: Variables
223 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
224 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
225 num2,2,Numeric variable 2's label,Scale,Input,8,Right,F8.0,F8.0,
226
227 Table: Data List
228 num1,num2
229 1,2
230 ])
231 done
232 AT_CLEANUP
233
234 AT_SETUP([wrong number of variable positions but version 13])
235 AT_KEYWORDS([sack synthetic system file positive])
236 AT_DATA([sys-file.sack], [dnl
237 dnl File header.
238 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
239 2; dnl Layout code
240 -1; dnl Nominal case size (unspecified)
241 0; dnl Not compressed
242 0; dnl Not weighted 
243 1; dnl 1 case.
244 100.0; dnl Bias.
245 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
246 i8 0 *3;
247
248 dnl Numeric variable, no label or missing values.
249 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
250
251 dnl Numeric variable, variable label.
252 2; 0; 1; 0; 0x050800 *2; s8 "NUM2";
253 26; "Numeric variable 2's label"; i8 0 *2;
254
255 dnl Machine integer info record (SPSS 13).
256 7; 3; 4; 8; 13; 2; 3; -1; 1; 1; ENDIAN; 1252;
257
258 dnl Character encoding record.
259 7; 20; 1; 12; "windows-1252";
260
261 dnl Dictionary termination record.
262 999; 0;
263
264 dnl Data.
265 1.0; 2.0; 
266 ])
267 for variant in be le; do
268   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
269   AT_DATA([sys-file.sps], [dnl
270 GET FILE='sys-file.sav'.
271 DISPLAY DICTIONARY.
272 LIST.
273 ])
274   AT_CHECK([pspp -o pspp.csv sys-file.sps])
275   AT_CHECK([cat pspp.csv], [0], [dnl
276 Table: Variables
277 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
278 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
279 num2,2,Numeric variable 2's label,Scale,Input,8,Right,F8.0,F8.0,
280
281 Table: Data List
282 num1,num2
283 1,2
284 ])
285 done
286 AT_CLEANUP
287
288 AT_SETUP([value labels])
289 AT_KEYWORDS([sack synthetic system file positive])
290 AT_DATA([sys-file.sack], [dnl
291 dnl File header.
292 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
293 2; dnl Layout code
294 22; dnl Nominal case size
295 0; dnl Not compressed
296 0; dnl Not weighted 
297 1; dnl 1 case.
298 100.0; dnl Bias.
299 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
300 i8 0 *3;
301
302 dnl Numeric variables.
303 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
304 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
305 2; 0; 0; 0; 0x050800 *2; s8 "NUM3";
306 2; 0; 0; 0; 0x050800 *2; s8 "NUM4";
307 2; 0; 0; 0; 0x050800 *2; s8 "NUM5";
308
309 dnl String variables.
310 2; 1; 0; 0; 0x010100 *2; s8 "STR1"; dnl index 6
311 2; 2; 0; 0; 0x010200 *2; s8 "STR2"; dnl index 7
312 2; 3; 0; 0; 0x010300 *2; s8 "STR3"; dnl index 8
313 2; 4; 0; 0; 0x010400 *2; s8 "STR4"; dnl index 9
314 2; 4; 0; 0; 0x010400 *2; s8 "STR5"; dnl index 10
315 2; 6; 0; 0; 0x010600 *2; s8 "STR6"; dnl index 11
316 2; 7; 0; 0; 0x010700 *2; s8 "STR7"; dnl index 12
317 2; 8; 0; 0; 0x010800 *2; s8 "STR8"; dnl index 13
318 2; 9; 0; 0; 0x010900 *2; "STR9"; i8 230; s3 ""; dnl index 14
319 2; -1; 0; 0; 0; 0; s8 "";
320 2; 12; 0; 0; 0x010c00 *2; s8 "STR12"; dnl index 16
321 2; -1; 0; 0; 0; 0; s8 "";
322 2; 16; 0; 0; 0x011000 *2; s8 "STR16"; dnl index 18
323 2; -1; 0; 0; 0; 0; s8 "";
324 2; 17; 0; 0; 0x011100 *2; s8 "STR17"; dnl index 20
325 ( 2; -1; 0; 0; 0; 0; s8 ""; ) * 2;
326
327 dnl One value label for NUM1.
328 3; 1; 1.0; i8 17; i8 238; i8 228; i8 232; i8 237; s19 " (in Russian)"; 4; 1; 1;
329
330 dnl Two value labels for NUM2, as a single pair of type 3 and type 4 records.
331 3; 2; 1.0; i8 3; s7 "one"; 2.0; i8 3; s7 "two"; 4; 1; 2;
332
333 dnl Two value labels for NUM3, as two pairs of type 3 and type 4 records.
334 3; 1; 3.0; i8 5; s7 "three"; 4; 1; 3;
335 3; 1; 4.0; i8 4; s7 "four"; 4; 1; 3;
336
337 dnl Two common value labels for NUM4 and NUM5, plus two different ones for each.
338 3; 1; 5.0; i8 4; s7 "five"; 4; 1; 4;
339 3; 1; 6.0; i8 3; s7 "six"; 4; 1; 5;
340 3; 2; 7.0; i8 5; s7 "seven"; 8.0; i8 5; s7 "eight"; 4; 2; 4; 5;
341 3; 1; 9.0; i8 4; s7 "nine"; 4; 1; 4;
342 3; 1; 10.0; i8 3; s7 "ten"; 4; 1; 5;
343
344 dnl One value label for STR1.
345 3; 1; s8 "a"; i8 19; s23 "value label for `a'"; 4; 1; 6;
346
347 dnl Two value labels for STR2, as a single pair of type 3 and type 4 records.
348 3; 2;
349 s8 "bc"; i8 20; s23 "value label for `bc'";
350 s8 "de"; i8 20; s23 "value label for `de'";
351 4; 1; 7;
352
353 dnl Two value labels for STR3, as two pairs of type 3 and type 4 records.
354 3; 1; s8 "fgh"; i8 21; s23 "value label for `fgh'"; 4; 1; 8;
355 3; 1; s8 "ijk"; i8 21; s23 "value label for `ijk'"; 4; 1; 8;
356
357 dnl Two common value labels for STR4 and STR5, plus two different ones for each.
358 3; 1; s8 "lmno"; i8 22; s23 "value label for `lmno'"; 4; 1; 9;
359 3; 1; s8 "pqrs"; i8 22; s23 "value label for `pqrs'"; 4; 1; 10;
360 3; 2;
361 s8 "tuvw"; i8 22; s23 "value label for `tuvw'";
362 s8 "xyzA"; i8 22; s23 "value label for `xyzA'";
363 4; 2; 9; 10;
364 3; 1; s8 "BCDE"; i8 22; s23 "value label for `BCDE'"; 4; 1; 9;
365 3; 1; s8 "FGHI"; i8 22; s23 "value label for `FGHI'"; 4; 1; 10;
366
367 dnl One value label for STR6, STR7, STR8.
368 3; 1; s8 "JKLMNO"; i8 24; s31 "value label for `JKLMNO'"; 4; 1; 11;
369 3; 1; s8 "JKLMNOP"; i8 25; s31 "value label for `JKLMNOP'"; 4; 1; 12;
370 3; 1; s8 "JKLMNOPQ"; i8 26; s31 "value label for `JKLMNOPQ'"; 4; 1; 13;
371
372 dnl Machine integer info record.
373 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1251;
374
375 dnl Character encoding record.
376 7; 20; 1; 12; "windows-1251";
377
378 7; 21; 1; COUNT (
379 dnl One value label for STR9ж,
380 COUNT("STR9"; i8 230); 9; 1; COUNT("RSTUVWXYZ"); COUNT("value label for `RSTUVWXYZ'");
381
382 dnl Two value labels for STR12.
383 COUNT("STR12"); 12; 2;
384 COUNT("0123456789ab"); COUNT("value label for `0123456789ab'");
385 COUNT("cdefghijklmn"); COUNT("value label for `cdefghijklmn'");
386
387 dnl Three value labels for STR16.
388 COUNT("STR16"); 16; 3;
389 COUNT("opqrstuvwxyzABCD"); COUNT("value label for `opqrstuvwxyzABCD'");
390 COUNT("EFGHIJKLMNOPQRST"); COUNT("value label for `EFGHIJKLMNOPQRST'");
391 COUNT("UVWXYZ0123456789"); COUNT("value label for `UVWXYZ0123456789' with Cyrillic letters: `"; i8 244; i8 245; i8 246; "'");
392
393 dnl One value label for STR17.
394 COUNT("STR17"); 17; 1;
395 COUNT("abcdefghijklmnopq"); COUNT("value label for `abcdefghijklmnopq'");
396 );
397
398 dnl Dictionary termination record.
399 999; 0;
400 ])
401 for variant in be le; do
402   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
403   AT_DATA([sys-file.sps], [dnl
404 GET FILE='sys-file.sav'.
405 DISPLAY DICTIONARY.
406 ])
407   AT_CHECK([pspp -o pspp.csv sys-file.sps])
408   AT_CHECK([cat pspp.csv], [0], [dnl
409 Table: Variables
410 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
411 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
412 num2,2,,Scale,Input,8,Right,F8.0,F8.0,
413 num3,3,,Scale,Input,8,Right,F8.0,F8.0,
414 num4,4,,Scale,Input,8,Right,F8.0,F8.0,
415 num5,5,,Scale,Input,8,Right,F8.0,F8.0,
416 str1,6,,Nominal,Input,1,Left,A1,A1,
417 str2,7,,Nominal,Input,2,Left,A2,A2,
418 str3,8,,Nominal,Input,3,Left,A3,A3,
419 str4,9,,Nominal,Input,4,Left,A4,A4,
420 str5,10,,Nominal,Input,4,Left,A4,A4,
421 str6,11,,Nominal,Input,6,Left,A6,A6,
422 str7,12,,Nominal,Input,7,Left,A7,A7,
423 str8,13,,Nominal,Input,8,Left,A8,A8,
424 str9ж,14,,Nominal,Input,9,Left,A9,A9,
425 str12,15,,Nominal,Input,12,Left,A12,A12,
426 str16,16,,Nominal,Input,16,Left,A16,A16,
427 str17,17,,Nominal,Input,17,Left,A17,A17,
428
429 Table: Value Labels
430 Variable,Value,Label
431 num1,1,один (in Russian)
432 num2,1,one
433 ,2,two
434 num3,3,three
435 ,4,four
436 num4,5,five
437 ,7,seven
438 ,8,eight
439 ,9,nine
440 num5,6,six
441 ,7,seven
442 ,8,eight
443 ,10,ten
444 str1,a,value label for `a'
445 str2,bc,value label for `bc'
446 ,de,value label for `de'
447 str3,fgh,value label for `fgh'
448 ,ijk,value label for `ijk'
449 str4,BCDE,value label for `BCDE'
450 ,lmno,value label for `lmno'
451 ,tuvw,value label for `tuvw'
452 ,xyzA,value label for `xyzA'
453 str5,FGHI,value label for `FGHI'
454 ,pqrs,value label for `pqrs'
455 ,tuvw,value label for `tuvw'
456 ,xyzA,value label for `xyzA'
457 str6,JKLMNO,value label for `JKLMNO'
458 str7,JKLMNOP,value label for `JKLMNOP'
459 str8,JKLMNOPQ,value label for `JKLMNOPQ'
460 str9ж,RSTUVWXYZ,value label for `RSTUVWXYZ'
461 str12,0123456789ab,value label for `0123456789ab'
462 ,cdefghijklmn,value label for `cdefghijklmn'
463 str16,EFGHIJKLMNOPQRST,value label for `EFGHIJKLMNOPQRST'
464 ,UVWXYZ0123456789,value label for `UVWXYZ0123456789' with Cyrillic letters: `фхц'
465 ,opqrstuvwxyzABCD,value label for `opqrstuvwxyzABCD'
466 str17,abcdefghijklmnopq,value label for `abcdefghijklmnopq'
467 ])
468 done
469 AT_CLEANUP
470
471 AT_SETUP([documents])
472 AT_KEYWORDS([sack synthetic system file positive])
473 AT_DATA([sys-file.sack], [dnl
474 dnl File header.
475 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
476 2; dnl Layout code
477 1; dnl Nominal case size
478 0; dnl Not compressed
479 0; dnl Not weighted 
480 1; dnl 1 case.
481 100.0; dnl Bias.
482 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
483 i8 0 *3;
484
485 dnl Numeric variable, no label or missing values.
486 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
487
488 dnl Machine integer info record.
489 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
490
491 dnl Document record.
492 6; 5;
493 s80 "First line of documents";
494 s80 "Second line of documents";
495 "abb"; i8 233; " appliqu"; i8 233; " attach"; i8 233; " blas"; i8 233; " caf"; i8 233; " canap"; i8 233; " clich"; i8 233; " consomm"; i8 233;
496 s25 "";
497 s80 "";
498 s80 "Last line of documents";
499
500 dnl Character encoding record.
501 7; 20; 1; 12; "windows-1252";
502
503 dnl Dictionary termination record.
504 999; 0;
505
506 dnl Data.
507 1.0;
508 ])
509 for variant in be le; do
510   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
511   AT_DATA([sys-file.sps], [dnl
512 GET FILE='sys-file.sav'.
513 DISPLAY DOCUMENTS.
514 LIST.
515 ])
516   AT_CHECK([pspp -o pspp.csv sys-file.sps])
517   AT_CHECK([cat pspp.csv], [0], [dnl
518 Documents in the active dataset:
519
520 First line of documents
521
522 Second line of documents
523
524 abbé appliqué attaché blasé café canapé cliché consommé
525
526
527
528 Last line of documents
529
530 Table: Data List
531 num1
532 1
533 ])
534 done
535 AT_CLEANUP
536
537 AT_SETUP([empty document record])
538 AT_KEYWORDS([sack synthetic system file positive])
539 AT_DATA([sys-file.sack], [dnl
540 dnl File header.
541 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
542 2; dnl Layout code
543 1; dnl Nominal case size
544 0; dnl Not compressed
545 0; dnl Not weighted 
546 1; dnl 1 case.
547 100.0; dnl Bias.
548 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
549 i8 0 *3;
550
551 dnl Numeric variable, no label or missing values.
552 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
553
554 dnl Machine integer info record.
555 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
556
557 dnl Document record.
558 6; 0;
559
560 dnl Character encoding record.
561 7; 20; 1; 12; "windows-1252";
562
563 dnl Dictionary termination record.
564 999; 0;
565
566 dnl Data.
567 1.0;
568 ])
569 for variant in be le; do
570   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
571   AT_DATA([sys-file.sps], [dnl
572 GET FILE='sys-file.sav'.
573 LIST.
574 ])
575   AT_CHECK([pspp -o pspp.csv sys-file.sps])
576   AT_CHECK([cat pspp.csv], [0], [dnl
577 Table: Data List
578 num1
579 1
580 ])
581 done
582 AT_CLEANUP
583
584 AT_SETUP([multiple response sets])
585 AT_KEYWORDS([sack synthetic system file positive])
586 AT_DATA([sys-file.sack], [dnl
587 dnl File header.
588 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
589 2; dnl Layout code
590 16; dnl Nominal case size
591 0; dnl Not compressed
592 0; dnl Not weighted 
593 0; dnl No cases.
594 100.0; dnl Bias.
595 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
596 i8 0 *3;
597
598 dnl $a
599 2; 0; 0; 0; 0x050800 *2; i8 0x82; i8 0xa0; s6 "";
600 2; 0; 0; 0; 0x050800 *2; s8 "B";
601 2; 0; 0; 0; 0x050800 *2; s8 "C";
602
603 dnl $b
604 2; 0; 0; 0; 0x050800 *2; s8 "D";
605 2; 0; 0; 0; 0x050800 *2; s8 "E";
606 2; 0; 0; 0; 0x050800 *2; s8 "F";
607 2; 0; 0; 0; 0x050800 *2; s8 "G";
608
609 dnl $c
610 2; 4; 0; 0; 0x010400 *2; s8 "H";
611 2; 4; 0; 0; 0x010400 *2; s8 "I";
612 2; 4; 0; 0; 0x010400 *2; s8 "J";
613
614 dnl $d
615 2; 0; 0; 0; 0x050800 *2; s8 "K";
616 2; 0; 0; 0; 0x050800 *2; s8 "L";
617 2; 0; 0; 0; 0x050800 *2; s8 "M";
618
619 dnl $e
620 2; 6; 0; 0; 0x010600 *2; s8 "N";
621 2; 6; 0; 0; 0x010600 *2; s8 "O";
622 2; 6; 0; 0; 0x010600 *2; s8 "P";
623
624 dnl Machine integer info record.
625 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 932;
626
627 7; 7; 1;
628 COUNT(
629   "$a=C 10 my mcgroup "; i8 0x82; i8 0xa0; " b c"; i8 10;
630   "$b=D2 55 0  g e f d"; i8 10; i8 10;
631   "$c=D4 "; i8 0x82; i8 0xcd; i8 0x82; i8 0xa2; " 10 mdgroup #2 h i j"; i8 10);
632
633 7; 19; 1;
634 COUNT(
635   i8 10;
636   "$d=E 1 2 34 13 third mdgroup k l m"; i8 10;
637   "$e=E 11 6 choice 0  n o p"; i8 10; i8 10; i8 10; i8 10);
638
639 dnl Character encoding record.
640 7; 20; 1; 9; "shift_jis";
641
642 dnl Dictionary termination record.
643 999; 0;
644 ])
645 for variant in be le; do
646   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
647   AT_DATA([sys-file.sps], [dnl
648 GET FILE='sys-file.sav'.
649 MRSETS /DISPLAY NAME=ALL.
650 ])
651   AT_CHECK([pspp -o pspp.csv sys-file.sps])
652   AT_CHECK([cat pspp.csv], [0], [dnl
653 Table: Multiple Response Sets
654 Name,Variables,Details
655 $a,"あ
656 b
657 c
658 ","Multiple category set
659 Label: my mcgroup
660 "
661 $b,"g
662 e
663 f
664 d
665 ","Multiple dichotomy set
666 Counted value: 55
667 Category label source: Variable labels
668 "
669 $c,"h
670 i
671 j
672 ","Multiple dichotomy set
673 Label: mdgroup #2
674 Label source: Provided by user
675 Counted value: `はい'
676 Category label source: Variable labels
677 "
678 $d,"k
679 l
680 m
681 ","Multiple dichotomy set
682 Label: third mdgroup
683 Label source: Provided by user
684 Counted value: 34
685 Category label source: Value labels of counted value
686 "
687 $e,"n
688 o
689 p
690 ","Multiple dichotomy set
691 Label source: First variable label among variables
692 Counted value: `choice'
693 Category label source: Value labels of counted value
694 "
695 ])
696 done
697 AT_CLEANUP
698
699 dnl Also checks for handling of CR-only line ends in file label and
700 dnl extra product info.
701 AT_SETUP([extra product info])
702 AT_KEYWORDS([sack synthetic system file positive])
703 AT_DATA([sys-file.sack], [dnl
704 dnl File header.
705 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
706 2; dnl Layout code
707 4; dnl Nominal case size
708 0; dnl Not compressed
709 0; dnl Not weighted
710 0; dnl No cases.
711 100.0; dnl Bias.
712 "01 Jan 11"; "20:53:52"; "PSPP synthetic"; i8 13; s49 "test file";
713 i8 0 *3;
714
715 dnl Numeric variables.
716 2; 0; 0; 0; 0x050800 *2; s8 "A";
717 2; 0; 0; 0; 0x050800 *2; s8 "B";
718 2; 0; 0; 0; 0x050800 *2; s8 "C";
719 2; 0; 0; 0; 0x050800 *2; s8 "D";
720
721 dnl Extra product info.
722 7; 10; 1; COUNT ("Extra product info"; i8 13; "another line"; i8 13; "blah");
723
724 dnl Character encoding record.
725 7; 20; 1; 12; "windows-1252";
726
727 dnl Dictionary termination record.
728 999; 0;
729 ])
730 for variant in be le; do
731   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
732   AT_DATA([sys-file.sps], [dnl
733 SYSFILE INFO FILE='sys-file.sav'.
734 ])
735   AT_CHECK([pspp -o pspp.csv sys-file.sps])
736   AT_CHECK([sed 7q pspp.csv], [0], [dnl
737 File:,sys-file.sav
738 Label:,"PSPP synthetic
739 test file"
740 Created:,01 Jan 11 20:53:52 by $(@%:@) SPSS DATA FILE PSPP synthetic test file
741 Product:,"Extra product info
742 another line
743 blah"
744 ])
745 done
746 AT_CLEANUP
747
748 AT_SETUP([variable display parameters, without width])
749 AT_KEYWORDS([sack synthetic system file positive])
750 AT_DATA([sys-file.sack], [dnl
751 dnl File header.
752 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
753 2; dnl Layout code
754 19; dnl Nominal case size
755 0; dnl Not compressed
756 0; dnl Not weighted 
757 0; dnl No cases.
758 100.0; dnl Bias.
759 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
760 i8 0 *3;
761
762 dnl Numeric variables.
763 2; 0; 0; 0; 0x050800 *2; s8 "A";
764 2; 0; 0; 0; 0x050800 *2; s8 "B";
765 2; 0; 0; 0; 0x050800 *2; s8 "C";
766 2; 0; 0; 0; 0x050800 *2; s8 "D";
767
768 dnl Short string variables.
769 2; 3; 0; 0; 0x010300 *2; s8 "H";
770 2; 3; 0; 0; 0x010300 *2; s8 "I";
771 2; 3; 0; 0; 0x010300 *2; s8 "J";
772 2; 3; 0; 0; 0x010300 *2; s8 "K";
773
774 dnl Long string variables.
775 2; 9; 0; 0; 0x010900 *2; s8 "L";
776 2; -1; 0; 0; 0; 0; s8 "";
777 2; 10; 0; 0; 0x010a00 *2; s8 "M";
778 2; -1; 0; 0; 0; 0; s8 "";
779 2; 17; 0; 0; 0x011100 *2; s8 "N";
780 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 2;
781 2; 25; 0; 0; 0x011900 *2; s8 "O";
782 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 3;
783
784 dnl Variable display parameters
785 7; 11; 4; 24;
786 1; 0;
787 2; 0;
788 3; 0;
789 1; 1;
790 2; 1;
791 3; 1;
792 1; 2;
793 2; 2;
794 3; 2;
795 0; 0;
796 0; 1;
797 0; 2;
798
799 dnl Character encoding record.
800 7; 20; 1; 12; "windows-1252";
801
802 dnl Dictionary termination record.
803 999; 0;
804 ])
805 for variant in be le; do
806   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
807   AT_DATA([sys-file.sps], [dnl
808 GET FILE='sys-file.sav'.
809 DISPLAY DICTIONARY.
810 ])
811   AT_CHECK([pspp -o pspp.csv sys-file.sps])
812   AT_CHECK([cat pspp.csv], [0], [dnl
813 Table: Variables
814 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
815 a,1,,Nominal,Input,8,Left,F8.0,F8.0,
816 b,2,,Ordinal,Input,8,Left,F8.0,F8.0,
817 c,3,,Scale,Input,8,Left,F8.0,F8.0,
818 d,4,,Nominal,Input,8,Right,F8.0,F8.0,
819 h,5,,Ordinal,Input,3,Right,A3,A3,
820 i,6,,Scale,Input,3,Right,A3,A3,
821 j,7,,Nominal,Input,3,Center,A3,A3,
822 k,8,,Ordinal,Input,3,Center,A3,A3,
823 l,9,,Scale,Input,9,Center,A9,A9,
824 m,10,,Nominal,Input,10,Left,A10,A10,
825 n,11,,Nominal,Input,17,Right,A17,A17,
826 o,12,,Nominal,Input,25,Center,A25,A25,
827 ])
828 done
829 AT_CLEANUP
830
831 AT_SETUP([variable display parameters, with width])
832 AT_KEYWORDS([sack synthetic system file positive])
833 AT_DATA([sys-file.sack], [dnl
834 dnl File header.
835 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
836 2; dnl Layout code
837 19; dnl Nominal case size
838 0; dnl Not compressed
839 0; dnl Not weighted 
840 0; dnl No cases.
841 100.0; dnl Bias.
842 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
843 i8 0 *3;
844
845 dnl Numeric variables.
846 2; 0; 0; 0; 0x050800 *2; s8 "A";
847 2; 0; 0; 0; 0x050800 *2; s8 "B";
848 2; 0; 0; 0; 0x050800 *2; s8 "C";
849 2; 0; 0; 0; 0x050800 *2; s8 "D";
850
851 dnl Short string variables.
852 2; 3; 0; 0; 0x010300 *2; s8 "H";
853 2; 3; 0; 0; 0x010300 *2; s8 "I";
854 2; 3; 0; 0; 0x010300 *2; s8 "J";
855 2; 3; 0; 0; 0x010300 *2; s8 "K";
856
857 dnl Long string variables.
858 2; 9; 0; 0; 0x010900 *2; s8 "L";
859 2; -1; 0; 0; 0; 0; s8 "";
860 2; 10; 0; 0; 0x010a00 *2; s8 "M";
861 2; -1; 0; 0; 0; 0; s8 "";
862 2; 17; 0; 0; 0x011100 *2; s8 "N";
863 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 2;
864 2; 25; 0; 0; 0x011900 *2; s8 "O";
865 ( 2; -1; 0; 0; 0; 0; s8 "" ) * 3;
866
867 dnl Variable display parameters
868 7; 11; 4; 36;
869 1; 1; 0;
870 2; 2; 0;
871 3; 3; 0;
872 1; 4; 1;
873 2; 5; 1;
874 3; 6; 1;
875 1; 7; 2;
876 2; 8; 2;
877 3; 9; 2;
878 0; 10; 0;
879 0; 11; 1;
880 0; 12; 2;
881
882 dnl Character encoding record.
883 7; 20; 1; 12; "windows-1252";
884
885 dnl Dictionary termination record.
886 999; 0;
887 ])
888 for variant in be le; do
889   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
890   AT_DATA([sys-file.sps], [dnl
891 GET FILE='sys-file.sav'.
892 DISPLAY DICTIONARY.
893 ])
894   AT_CHECK([pspp -o pspp.csv sys-file.sps])
895   AT_CHECK([cat pspp.csv], [0], [dnl
896 Table: Variables
897 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
898 a,1,,Nominal,Input,1,Left,F8.0,F8.0,
899 b,2,,Ordinal,Input,2,Left,F8.0,F8.0,
900 c,3,,Scale,Input,3,Left,F8.0,F8.0,
901 d,4,,Nominal,Input,4,Right,F8.0,F8.0,
902 h,5,,Ordinal,Input,5,Right,A3,A3,
903 i,6,,Scale,Input,6,Right,A3,A3,
904 j,7,,Nominal,Input,7,Center,A3,A3,
905 k,8,,Ordinal,Input,8,Center,A3,A3,
906 l,9,,Scale,Input,9,Center,A9,A9,
907 m,10,,Nominal,Input,10,Left,A10,A10,
908 n,11,,Nominal,Input,11,Right,A17,A17,
909 o,12,,Nominal,Input,12,Center,A25,A25,
910 ])
911 done
912 AT_CLEANUP
913
914 AT_SETUP([long variable names])
915 AT_KEYWORDS([sack synthetic system file positive])
916 AT_DATA([sys-file.sack], [dnl
917 dnl File header.
918 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
919 2; dnl Layout code
920 7; dnl Nominal case size
921 0; dnl Not compressed
922 0; dnl Not weighted 
923 0; dnl No cases.
924 100.0; dnl Bias.
925 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
926 i8 0 *3;
927
928 dnl Numeric variables.
929 2; 0; 0; 0; 0x050800 *2; s8 "LONGVARI";
930 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_A";
931 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_B";
932 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_C";
933 2; 0; 0; 0; 0x050800 *2; "CO"; i8 214; "RDINA";
934 2; 0; 0; 0; 0x050800 *2; "CO"; i8 214; "RDI_A";
935 2; 0; 0; 0; 0x050800 *2; "CO"; i8 214; "RDI_B";
936
937 dnl Machine integer info record.
938 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
939
940 dnl Machine floating-point info record.
941 7; 4; 8; 3; SYSMIS; HIGHEST; LOWEST;
942
943 dnl Long variable names.
944 7; 13; 1; COUNT (
945 "LONGVARI=LongVariableName1"; i8 9;
946 "LONGVA_A=LongVariableName2"; i8 9;
947 "LONGVA_B=LongVariableName3"; i8 9;
948 "LONGVA_C=LongVariableName4"; i8 9;
949 "CO"; i8 214; "RDINA=Co"; i8 246; "rdinate_X"; i8 9;
950 "CO"; i8 214; "RDI_A=Co"; i8 246; "rdinate_Y"; i8 9;
951 "CO"; i8 214; "RDI_B=Co"; i8 246; "rdinate_Z";
952 );
953
954 dnl Character encoding record.
955 7; 20; 1; 12; "windows-1252";
956
957 dnl Dictionary termination record.
958 999; 0;
959 ])
960 for variant in be le; do
961   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
962   AT_DATA([sys-file.sps], [dnl
963 GET FILE='sys-file.sav'.
964 DISPLAY DICTIONARY.
965 ])
966   AT_CHECK([pspp -o pspp.csv sys-file.sps])
967   AT_CHECK([cat pspp.csv], [0], [dnl
968 Table: Variables
969 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
970 LongVariableName1,1,,Scale,Input,8,Right,F8.0,F8.0,
971 LongVariableName2,2,,Scale,Input,8,Right,F8.0,F8.0,
972 LongVariableName3,3,,Scale,Input,8,Right,F8.0,F8.0,
973 LongVariableName4,4,,Scale,Input,8,Right,F8.0,F8.0,
974 Coördinate_X,5,,Scale,Input,8,Right,F8.0,F8.0,
975 Coördinate_Y,6,,Scale,Input,8,Right,F8.0,F8.0,
976 Coördinate_Z,7,,Scale,Input,8,Right,F8.0,F8.0,
977 ])
978 done
979 AT_CLEANUP
980
981 AT_SETUP([very long strings])
982 AT_KEYWORDS([sack synthetic system file positive])
983 AT_DATA([sys-file.sack], [dnl
984 dnl File header.
985 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
986 2; dnl Layout code
987 109; dnl Nominal case size
988 0; dnl Not compressed
989 0; dnl Not weighted 
990 1; dnl No cases.
991 100.0; dnl Bias.
992 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
993 i8 0 *3;
994
995 dnl 256-byte string.
996 2; 255; 0; 0; 0x01FF00 *2; "S"; i8 201; s6 "Q256";
997 (2; -1; 0; 0; 0; 0; s8 "") * 31;
998 2; 4; 0; 0; 0x010400 *2; "S"; i8 201; "Q256_1";
999
1000 dnl 600-byte string.
1001 2; 255; 0; 0; 0x01FF00 *2; s8 "STR600";
1002 (2; -1; 0; 0; 0; 0; s8 "") * 31;
1003 2; 255; 0; 0; 0x01FF00 *2; s8 "STR600_1";
1004 (2; -1; 0; 0; 0; 0; s8 "") * 31;
1005 2; 96; 0; 0; 0x016000 *2; s8 "STR600_2";
1006 (2; -1; 0; 0; 0; 0; s8 "") * 11;
1007
1008 dnl Machine integer info record.
1009 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
1010
1011 dnl Very long string record.
1012 7; 14; 1; COUNT (
1013 "S"; i8 201; "Q256=00256"; i8 0; i8 9;
1014 "STR600=00600"; i8 0; i8 9;
1015 );
1016
1017 dnl Character encoding record.
1018 7; 20; 1; 12; "windows-1252";
1019
1020 dnl Dictionary termination record.
1021 999; 0;
1022
1023 dnl Data.
1024 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#" * 4;
1025 "abcdefgh";
1026 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#" * 9;
1027 "abcdefghijklmnopqrstuvwxyzABCDEF";
1028 ])
1029 for variant in be le; do
1030   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1031   AT_DATA([sys-file.sps], [dnl
1032 GET FILE='sys-file.sav'.
1033 DISPLAY DICTIONARY.
1034 LIST.
1035 ])
1036   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1037   AT_CHECK([cat pspp.csv], [0], [dnl
1038 Table: Variables
1039 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1040 séq256,1,,Nominal,Input,32,Left,A256,A256,
1041 str600,2,,Nominal,Input,32,Left,A600,A600,
1042
1043 Table: Data List
1044 séq256,str600
1045 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@a,abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#abcdefghijklmnopqrstuvwxyz
1046 ])
1047 done
1048 AT_CLEANUP
1049
1050 AT_SETUP([data file and variable attributes])
1051 AT_KEYWORDS([sack synthetic system file positive])
1052 AT_DATA([sys-file.sack], [dnl
1053 dnl File header.
1054 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1055 2; dnl Layout code
1056 3; dnl Nominal case size
1057 0; dnl Not compressed
1058 0; dnl Not weighted 
1059 0; dnl 1 case.
1060 100.0; dnl Bias.
1061 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1062 i8 0 *3;
1063
1064 dnl Variables.
1065 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
1066 2; 0; 0; 0; 0x050800 *2; s8 "SECONDVA";
1067 2; 0; 0; 0; 0x050800 *2; s8 "THIRDVAR";
1068
1069 dnl Machine integer info record.
1070 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
1071
1072 dnl Long variable names.
1073 7; 13; 1; COUNT (
1074 "FIRSTVAR=FirstVariable"; i8 9;
1075 "SECONDVA=S"; i8 233; "condVariable"; i8 9;
1076 "THIRDVAR=ThirdVariable"; i8 9
1077 );
1078
1079 dnl Data file attributes record.
1080 7; 17; 1; COUNT (
1081 "Attr1('Value1'"; i8 10; "''d"; i8 233; "claration''"; i8 10; ")";
1082 "S"; i8 233; "condAttr('123'"; i8 10; "'456'"; i8 10; ")";
1083 );
1084
1085 dnl Variable attributes record.
1086 7; 18; 1; COUNT (
1087 "FirstVariable:";
1088   "ad"; i8 232; "le('23'"; i8 10; "'34'"; i8 10; ")";
1089   "bert('123'"; i8 10; ")";
1090   "$@Role('1'"; i8 10; ")";
1091 "/S"; i8 233; "condVariable:";
1092   "xyzzy('quux'"; i8 10; ")";
1093 );
1094
1095 dnl Another variable attributes record.
1096 dnl Only system files written by "Stata 14.1/-savespss- 1.77 by S.Radyakin"
1097 dnl include multiple variable attributes records.
1098 7; 18; 1; COUNT ("ThirdVariable:fizz('buzz'"; i8 10; ")";);
1099
1100 dnl Character encoding record.
1101 7; 20; 1; 12; "windows-1252";
1102
1103 dnl Dictionary termination record.
1104 999; 0;
1105 ])
1106 for variant in be le; do
1107   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1108   AT_DATA([sys-file.sps], [dnl
1109 GET FILE='sys-file.sav'.
1110 DISPLAY @ATTRIBUTES.
1111 ])
1112   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1113   AT_CHECK([cat pspp.csv], [0],
1114 [[Table: Variable and Dataset Attributes
1115 Variable,Name,Value
1116 (dataset),Attr1[1],Value1
1117 ,Attr1[2],'déclaration'
1118 ,SécondAttr[1],123
1119 ,SécondAttr[2],456
1120 FirstVariable,$@Role,1
1121 ,adèle[1],23
1122 ,adèle[2],34
1123 ,bert,123
1124 SécondVariable,xyzzy,quux
1125 ThirdVariable,fizz,buzz
1126 ]])
1127   AT_DATA([sys-file.sps], [dnl
1128 GET FILE='sys-file.sav'.
1129 DISPLAY DICTIONARY.
1130 ])
1131   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1132   AT_CHECK([cat pspp.csv], [0],
1133 [[Table: Variables
1134 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1135 FirstVariable,1,,Scale,Output,8,Right,F8.0,F8.0,
1136 SécondVariable,2,,Scale,Input,8,Right,F8.0,F8.0,
1137 ThirdVariable,3,,Scale,Input,8,Right,F8.0,F8.0,
1138 ]])
1139 done
1140 AT_CLEANUP
1141
1142 AT_SETUP([variable roles])
1143 AT_KEYWORDS([sack synthetic system file positive])
1144 AT_DATA([sys-file.sack], [dnl
1145 dnl File header.
1146 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1147 2; dnl Layout code
1148 7; dnl Nominal case size
1149 0; dnl Not compressed
1150 0; dnl Not weighted
1151 0; dnl 1 case.
1152 100.0; dnl Bias.
1153 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1154 i8 0 *3;
1155
1156 dnl Variables.
1157 2; 0; 0; 0; 0x050800 *2; s8 "I";
1158 2; 0; 0; 0; 0x050800 *2; s8 "O";
1159 2; 0; 0; 0; 0x050800 *2; s8 "B";
1160 2; 0; 0; 0; 0x050800 *2; s8 "N";
1161 2; 0; 0; 0; 0x050800 *2; s8 "P";
1162 2; 0; 0; 0; 0x050800 *2; s8 "S";
1163 2; 0; 0; 0; 0x050800 *2; s8 "X";
1164
1165 dnl Machine integer info record.
1166 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
1167
1168 dnl Variable attributes record.
1169 7; 18; 1; COUNT (
1170 "I:$@Role('0'"; i8 10; ")";
1171 "/O:$@Role('1'"; i8 10; ")";
1172 "/B:$@Role('2'"; i8 10; ")";
1173 "/N:$@Role('3'"; i8 10; ")";
1174 "/P:$@Role('4'"; i8 10; ")";
1175 "/S:$@Role('5'"; i8 10; ")";
1176 "/X:$@Role('6'"; i8 10; ")";
1177 );
1178
1179 dnl Character encoding record.
1180 7; 20; 1; 12; "windows-1252";
1181
1182 dnl Dictionary termination record.
1183 999; 0;
1184 ])
1185 for variant in be le; do
1186   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1187   AT_DATA([sys-file.sps], [dnl
1188 GET FILE='sys-file.sav'.
1189 DISPLAY DICTIONARY.
1190 ])
1191   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [dnl
1192 warning: `sys-file.sav': Invalid role for variable x.
1193 ])
1194   AT_CHECK([cat pspp.csv], [0], [dnl
1195 warning: `sys-file.sav': Invalid role for variable x.
1196
1197 Table: Variables
1198 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1199 i,1,,Scale,Input,8,Right,F8.0,F8.0,
1200 o,2,,Scale,Output,8,Right,F8.0,F8.0,
1201 b,3,,Scale,Both,8,Right,F8.0,F8.0,
1202 n,4,,Scale,None,8,Right,F8.0,F8.0,
1203 p,5,,Scale,Partition,8,Right,F8.0,F8.0,
1204 s,6,,Scale,Split,8,Right,F8.0,F8.0,
1205 x,7,,Scale,Input,8,Right,F8.0,F8.0,
1206 ])
1207 done
1208 AT_CLEANUP
1209
1210 AT_SETUP([compressed data])
1211 AT_KEYWORDS([sack synthetic system file positive])
1212 AT_DATA([sys-file.sack], [dnl
1213 dnl File header.
1214 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1215 2; dnl Layout code
1216 6; dnl Nominal case size
1217 1; dnl Simple compression
1218 0; dnl Not weighted 
1219 -1; dnl Unspecified number of cases.
1220 100.0; dnl Bias.
1221 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1222 i8 0 *3;
1223
1224 dnl Numeric variables.
1225 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1226 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1227
1228 dnl String variable.
1229 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1230 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1231 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1232 2; -1; 0; 0; 0; 0; s8 "";
1233
1234 dnl Character encoding record.
1235 7; 20; 1; 12; "windows-1252";
1236
1237 dnl Dictionary termination record.
1238 999; 0;
1239
1240 dnl Compressed data.
1241 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
1242 i8 253 253 253 254; i8 101 102 253 253; s8 "jklm"; s8 "nopqrstu";
1243 s8 "vwxyzABC"; s8 "DEFG"; s8 "HIJKLMNO";
1244 i8 254 253 252 0 0 0 0 0; s8 "PQRSTUVW";
1245
1246 ])
1247 for variant in be le; do
1248   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1249   AT_DATA([sys-file.sps], [dnl
1250 GET FILE='sys-file.sav'.
1251 DISPLAY DICTIONARY.
1252 LIST.
1253 ])
1254   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1255   AT_CHECK([cat pspp.csv], [0], [dnl
1256 Table: Variables
1257 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1258 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
1259 num2,2,,Scale,Input,8,Right,F8.0,F8.0,
1260 str4,3,,Nominal,Input,4,Left,A4,A4,
1261 str8,4,,Nominal,Input,8,Left,A8,A8,
1262 str15,5,,Nominal,Input,15,Left,A15,A15,
1263
1264 Table: Data List
1265 num1,num2,str4,str8,str15
1266 -99,0,,abcdefgh,0123   @&t@
1267 .,151,jklm,nopqrstu,vwxyzABC       @&t@
1268 1,2,DEFG,HIJKLMNO,PQRSTUV
1269 ])
1270 done
1271 AT_CLEANUP
1272
1273 AT_SETUP([compressed data, zero bias])
1274 AT_KEYWORDS([sack synthetic system file positive])
1275 AT_DATA([sys-file.sack], [dnl
1276 dnl File header.
1277 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1278 2; dnl Layout code
1279 6; dnl Nominal case size
1280 1; dnl Simple compression.
1281 0; dnl Not weighted 
1282 -1; dnl Unspecified number of cases.
1283 0.0; dnl Bias.
1284 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1285 i8 0 *3;
1286
1287 dnl Numeric variables.
1288 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1289 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1290
1291 dnl String variable.
1292 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1293 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1294 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1295 2; -1; 0; 0; 0; 0; s8 "";
1296
1297 dnl Character encoding record.
1298 7; 20; 1; 12; "windows-1252";
1299
1300 dnl Dictionary termination record.
1301 999; 0;
1302
1303 dnl Compressed data.
1304 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
1305 i8 253 253 253 254; i8 101 102 253 253; s8 "jklm"; s8 "nopqrstu";
1306 s8 "vwxyzABC"; s8 "DEFG"; s8 "HIJKLMNO";
1307 i8 254 253 252 0 0 0 0 0; s8 "PQRSTUVW";
1308
1309 ])
1310 for variant in be le; do
1311   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1312   AT_DATA([sys-file.sps], [dnl
1313 GET FILE='sys-file.sav'.
1314 DISPLAY DICTIONARY.
1315 LIST.
1316 ])
1317   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0])
1318   AT_CHECK([cat pspp.csv], [0], [dnl
1319 Table: Variables
1320 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1321 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
1322 num2,2,,Scale,Input,8,Right,F8.0,F8.0,
1323 str4,3,,Nominal,Input,4,Left,A4,A4,
1324 str8,4,,Nominal,Input,8,Left,A8,A8,
1325 str15,5,,Nominal,Input,15,Left,A15,A15,
1326
1327 Table: Data List
1328 num1,num2,str4,str8,str15
1329 1,100,,abcdefgh,0123   @&t@
1330 .,251,jklm,nopqrstu,vwxyzABC       @&t@
1331 101,102,DEFG,HIJKLMNO,PQRSTUV
1332 ])
1333 done
1334 AT_CLEANUP
1335
1336 AT_SETUP([compressed data, other bias])
1337 AT_KEYWORDS([sack synthetic system file positive])
1338 AT_DATA([sys-file.sack], [dnl
1339 dnl File header.
1340 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1341 2; dnl Layout code
1342 6; dnl Nominal case size
1343 1; dnl Simple compression.
1344 0; dnl Not weighted 
1345 -1; dnl Unspecified number of cases.
1346 50.0; dnl Bias.
1347 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1348 i8 0 *3;
1349
1350 dnl Numeric variables.
1351 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1352 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1353
1354 dnl String variable.
1355 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1356 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1357 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1358 2; -1; 0; 0; 0; 0; s8 "";
1359
1360 dnl Character encoding record.
1361 7; 20; 1; 12; "windows-1252";
1362
1363 dnl Dictionary termination record.
1364 999; 0;
1365
1366 dnl Compressed data.
1367 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
1368 i8 253 253 253 254; i8 101 102 253 253; s8 "jklm"; s8 "nopqrstu";
1369 s8 "vwxyzABC"; s8 "DEFG"; s8 "HIJKLMNO";
1370 i8 254 253 252 0 0 0 0 0; s8 "PQRSTUVW";
1371
1372 ])
1373 for variant in be le; do
1374   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1375   AT_DATA([sys-file.sps], [dnl
1376 GET FILE='sys-file.sav'.
1377 DISPLAY DICTIONARY.
1378 LIST.
1379 ])
1380   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], 
1381     [warning: `sys-file.sav' near offset 0x54: Compression bias is not the usual value of 100, or system file uses unrecognized floating-point format.
1382 ])
1383   AT_CHECK([cat pspp.csv], [0], [dnl
1384 "warning: `sys-file.sav' near offset 0x54: Compression bias is not the usual value of 100, or system file uses unrecognized floating-point format."
1385
1386 Table: Variables
1387 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1388 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
1389 num2,2,,Scale,Input,8,Right,F8.0,F8.0,
1390 str4,3,,Nominal,Input,4,Left,A4,A4,
1391 str8,4,,Nominal,Input,8,Left,A8,A8,
1392 str15,5,,Nominal,Input,15,Left,A15,A15,
1393
1394 Table: Data List
1395 num1,num2,str4,str8,str15
1396 -49,50,,abcdefgh,0123   @&t@
1397 .,201,jklm,nopqrstu,vwxyzABC       @&t@
1398 51,52,DEFG,HIJKLMNO,PQRSTUV
1399 ])
1400 done
1401 AT_CLEANUP
1402
1403 m4_divert_push([PREPARE_TESTS])
1404 zcompressed_sack () {
1405     cat <<'EOF'
1406 dnl File header.
1407 "$FL3"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1408 2; dnl Layout code
1409 6; dnl Nominal case size
1410 2; dnl zlib compressed
1411 0; dnl Not weighted
1412 -1; dnl Unspecified number of cases.
1413 100.0; dnl Bias.
1414 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1415 i8 0 *3;
1416
1417 dnl Numeric variables.
1418 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1419 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
1420
1421 dnl String variable.
1422 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
1423 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
1424 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
1425 2; -1; 0; 0; 0; 0; s8 "";
1426
1427 dnl Character encoding record.
1428 7; 20; 1; 12; "windows-1252";
1429
1430 dnl Dictionary termination record.
1431 999; 0;
1432
1433 dnl ZLIB data header.
1434 i64 0x194;    # zheader_ofs
1435 i64 0x205;    # ztrailer_ofs
1436 i64 48;       # ztrailer_len
1437
1438 dnl ZLIB data block.
1439 dnl
1440 dnl This is the compressed form of:
1441 dnl
1442 dnl 01 64 fe fd fe fd ff fb  61 62 63 64 65 66 67 68  |.d......abcdefgh|
1443 dnl 30 31 32 33 20 20 20 20  fd fd fd fe 65 66 fd fd  |0123    ....ef..|
1444 dnl 6a 6b 6c 6d 20 20 20 20  6e 6f 70 71 72 73 74 75  |jklm    nopqrstu|
1445 dnl 76 77 78 79 7a 41 42 43  44 45 46 47 20 20 20 20  |vwxyzABCDEFG    |
1446 dnl 48 49 4a 4b 4c 4d 4e 4f  fe fd fc 00 00 00 00 00  |HIJKLMNO........|
1447 dnl 50 51 52 53 54 55 56 57                           |PQRSTUVW|
1448 dnl
1449 dnl which is the data from the "compressed data" test.
1450 hex "78 01 63 4c f9 f7 f7 df  df ff bf 13 93 92 53 52";
1451 hex "d3 d2 33 0c 0c 8d 8c 15  80 e0 ef df bf ff 52 d3";
1452 hex "fe fe cd ca ce c9 05 f1  f3 f2 0b 0a 8b 8a 4b 4a";
1453 hex "cb ca 2b 2a ab 1c 9d 9c  5d 5c dd dc 41 e2 1e 9e";
1454 hex "5e de 3e be 7e fe ff fe  fe 61 00 81 80 c0 a0 e0";
1455 hex "90 d0 b0 70 00 0f 3f 23  d7";
1456
1457 dnl ZLIB data trailer fixed header:
1458 i64 -100;     # ztrailer_bias
1459 i64 0;        # ztrailer_zero
1460 0x3ff000;     # block_size
1461 1;            # n_blocks
1462
1463 dnl ZLIB block descriptor:
1464 i64 0x194;    # uncompressed_ofs
1465 i64 0x1ac;    # compressed_ofs
1466 88;           # uncompressed_size
1467 89;           # compressed_size
1468 EOF
1469 }
1470 m4_divert_pop([PREPARE_TESTS])
1471
1472 AT_SETUP([zcompressed data])
1473 AT_KEYWORDS([sack synthetic system file positive zlib])
1474 zcompressed_sack > sys-file.sack
1475 for variant in be le; do
1476   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1477   AT_DATA([sys-file.sps], [dnl
1478 GET FILE='sys-file.sav'.
1479 DISPLAY DICTIONARY.
1480 LIST.
1481 ])
1482   AT_CHECK([pspp -o pspp.csv sys-file.sps])
1483   AT_CHECK([cat pspp.csv], [0], [dnl
1484 Table: Variables
1485 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1486 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
1487 num2,2,,Scale,Input,8,Right,F8.0,F8.0,
1488 str4,3,,Nominal,Input,4,Left,A4,A4,
1489 str8,4,,Nominal,Input,8,Left,A8,A8,
1490 str15,5,,Nominal,Input,15,Left,A15,A15,
1491
1492 Table: Data List
1493 num1,num2,str4,str8,str15
1494 -99,0,,abcdefgh,0123   @&t@
1495 .,151,jklm,nopqrstu,vwxyzABC       @&t@
1496 1,2,DEFG,HIJKLMNO,PQRSTUV
1497 ])
1498 done
1499 AT_CLEANUP
1500 \f
1501 AT_BANNER([system file reader - negative])
1502
1503 AT_SETUP([no variables])
1504 AT_KEYWORDS([sack synthetic system file negative])
1505 AT_DATA([sys-file.sack], [dnl
1506 dnl File header.
1507 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1508 2; dnl Layout code
1509 0; dnl Nominal case size (empty)
1510 0; dnl Not compressed
1511 0; dnl Not weighted
1512 0; dnl 0 cases.
1513 100.0; dnl Bias.
1514 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
1515 i8 0 *3;
1516
1517 dnl Character encoding record.
1518 7; 20; 1; 12; "windows-1252";
1519
1520 dnl Dictionary termination record.
1521 999; 0;
1522 ])
1523 for variant in be le; do
1524   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1525   AT_DATA([sys-file.sps], [dnl
1526 GET FILE='sys-file.sav'.
1527 ])
1528   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
1529 sys-file.sps:1: error: GET: `sys-file.sav': Data file dictionary has no variables.
1530 ])
1531
1532   dnl At one point pspp-convert would hang forever if there were no variables,
1533   dnl so check against regression.
1534   AT_CHECK([pspp-convert sys-file.sav sys-file.txt])
1535   AT_CHECK([cat sys-file.txt], [0], [
1536 ])
1537 done
1538 AT_CLEANUP
1539
1540 AT_SETUP([unspecified character encoding])
1541 AT_KEYWORDS([sack synthetic system file positive])
1542 AT_DATA([sys-file.sack], [dnl
1543 dnl File header.
1544 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1545 2; dnl Layout code
1546 4; dnl Nominal case size
1547 0; dnl Not compressed
1548 0; dnl Not weighted
1549 0; dnl No cases.
1550 100.0; dnl Bias.
1551 "01 Jan 11"; "20:53:52";
1552 "PSPP synthetic test file: "; i8 244; i8 245; i8 246; i8 248; s34 "";
1553 i8 0 *3;
1554
1555 dnl Numeric variables.
1556 2; 0; 0; 0; 0x050800 *2; s8 "A";
1557 2; 0; 0; 0; 0x050800 *2; s8 "B";
1558 2; 0; 0; 0; 0x050800 *2; s8 "C";
1559 2; 0; 0; 0; 0x050800 *2; s8 "D";
1560
1561 dnl Dictionary termination record.
1562 999; 0;
1563 ])
1564 for variant in be le; do
1565   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1566   AT_DATA([sys-file.sps], [dnl
1567 GET 'sys-file.sav'.
1568 ])
1569   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [stdout])
1570   AT_CHECK([sed 's/default encoding.*For/default encoding.  For/' stdout], [0], [dnl
1571 "warning: `sys-file.sav': This system file does not indicate its own character encoding.  Using default encoding.  For best results, specify an encoding explicitly.  Use SYSFILE INFO with ENCODING=""DETECT"" to analyze the possible encodings."
1572 ])
1573 done
1574 AT_CLEANUP
1575
1576 AT_SETUP([misplaced type 4 record])
1577 AT_KEYWORDS([sack synthetic system file negative])
1578 AT_DATA([sys-file.sack], [dnl
1579 dnl File header.
1580 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1581 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1582
1583 dnl Numeric variable.
1584 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1585
1586 dnl Type 4 record.
1587 >>4<<;
1588 ])
1589 for variant in be le; do
1590   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1591   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1592 ])
1593   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1594    [error: `sys-file.sav' near offset 0xd4: Misplaced type 4 record.
1595 ])
1596 done
1597 AT_CLEANUP
1598
1599 AT_SETUP([bad record type])
1600 AT_KEYWORDS([sack synthetic system file negative])
1601 AT_DATA([sys-file.sack], [dnl
1602 dnl File header.
1603 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1604 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1605
1606 dnl Numeric variable.
1607 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1608
1609 dnl Type 8 record (not a valid type).
1610 >>8<<;
1611 ])
1612 for variant in be le; do
1613   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1614   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1615 ])
1616   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1617    [error: `sys-file.sav' near offset 0xd4: Unrecognized record type 8.
1618 ])
1619 done
1620 AT_CLEANUP
1621
1622 AT_SETUP([wrong number of variable positions])
1623 AT_KEYWORDS([sack synthetic system file negative])
1624 AT_DATA([sys-file.sack], [dnl
1625 dnl File header.
1626 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1627 2; >>2<<; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1628
1629 dnl Numeric variable.
1630 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1631
1632 dnl Character encoding record.
1633 7; 20; 1; 12; "windows-1252";
1634
1635 dnl End of dictionary.
1636 999; 0;
1637 ])
1638 for variant in be le; do
1639   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1640   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1641 ])
1642   AT_CHECK([pspp -O format=csv sys-file.sps], [0], 
1643    [warning: `sys-file.sav': File header claims 2 variable positions but 1 were read from file.
1644 ])
1645 done
1646 AT_CLEANUP
1647
1648 AT_SETUP([variable name may not begin with `#'])
1649 AT_KEYWORDS([sack synthetic system file negative])
1650 AT_DATA([sys-file.sack], [dnl
1651 dnl File header.
1652 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1653 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1654
1655 dnl Numeric variable.
1656 2; 0; 0; 0; 0x050800 *2; s8 >>"$UM1"<<;
1657
1658 dnl Character encoding record.
1659 7; 20; 1; 12; "windows-1252";
1660
1661 dnl End of dictionary.
1662 999; 0;
1663 ])
1664 for variant in be le; do
1665   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1666   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1667 ])
1668   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1669    [error: `sys-file.sav' near offset 0xb4: Invalid variable name `$UM1'.
1670 ])
1671 done
1672 AT_CLEANUP
1673
1674 AT_SETUP([variable name may not be reserved word])
1675 AT_KEYWORDS([sack synthetic system file negative])
1676 AT_DATA([sys-file.sack], [dnl
1677 dnl File header.
1678 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1679 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1680
1681 dnl Numeric variable.
1682 2; 0; 0; 0; 0x050800 *2; s8 >>"TO"<<;
1683
1684 dnl Character encoding record.
1685 7; 20; 1; 12; "windows-1252";
1686
1687 dnl End of dictionary.
1688 999; 0;
1689 ])
1690 for variant in be le; do
1691   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1692   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1693 ])
1694   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1695    [error: `sys-file.sav' near offset 0xb4: Invalid variable name `TO'.
1696 ])
1697 done
1698 AT_CLEANUP
1699
1700 AT_SETUP([variable width must be between 0 and 255])
1701 AT_KEYWORDS([sack synthetic system file negative])
1702 AT_DATA([sys-file.sack], [dnl
1703 dnl File header.
1704 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1705 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1706
1707 dnl String variable with invalid width 256.
1708 2; 256; 0; 0; 0x050800 *2; s8 "VAR1";
1709
1710 dnl Character encoding record.
1711 7; 20; 1; 12; "windows-1252";
1712
1713 dnl End of dictionary.
1714 999; 0;
1715 ])
1716 for variant in be le; do
1717   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1718   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1719 ])
1720   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1721    [error: `sys-file.sav' near offset 0xb4: Bad width 256 for variable VAR1.
1722 ])
1723 done
1724 AT_CLEANUP
1725
1726 dnl SPSS-generated system file can contain duplicate variable names
1727 dnl (see bug #41475).
1728 AT_SETUP([duplicate variable name])
1729 AT_KEYWORDS([sack synthetic system file negative])
1730 AT_DATA([sys-file.sack], [dnl
1731 dnl File header.
1732 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1733 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1734
1735 dnl Numeric variables.
1736 2; 0; 0; 0; 0x050800 *2; s8 "VAR1";
1737 2; 0; 0; 0; 0x050800 *2; s8 "VAR1";
1738
1739 dnl Character encoding record.
1740 7; 20; 1; 12; "windows-1252";
1741
1742 dnl End of dictionary.
1743 999; 0;
1744 ])
1745 for variant in be le; do
1746   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1747   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1748 DISPLAY DICTIONARY.
1749 ])
1750   AT_CHECK([pspp -O format=csv sys-file.sps], [0],
1751    [warning: `sys-file.sav' near offset 0xd4: Renaming variable with duplicate name `VAR1' to `VAR001'.
1752
1753 Table: Variables
1754 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1755 var1,1,,Scale,Input,8,Right,F8.0,F8.0,
1756 var001,2,,Scale,Input,8,Right,F8.0,F8.0,
1757 ])
1758 done
1759 AT_CLEANUP
1760
1761 AT_SETUP([variable label indicator not 0 or 1])
1762 AT_KEYWORDS([sack synthetic system file negative])
1763 AT_DATA([sys-file.sack], [dnl
1764 dnl File header.
1765 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1766 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1767
1768 dnl Numeric variable.
1769 2; 0; >>2<<; 0; 0x050800 *2; s8 "VAR1";
1770
1771 dnl Character encoding record.
1772 7; 20; 1; 12; "windows-1252";
1773
1774 dnl End of dictionary.
1775 999; 0;
1776 ])
1777 for variant in be le; do
1778   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1779   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1780 ])
1781   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1782    [error: `sys-file.sav' near offset 0xb4: Variable label indicator field is not 0 or 1.
1783 ])
1784 done
1785 AT_CLEANUP
1786
1787 AT_SETUP([invalid numeric missing value indicator])
1788 AT_KEYWORDS([sack synthetic system file negative])
1789 AT_DATA([sys-file.sack], [dnl
1790 dnl File header.
1791 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1792 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1793
1794 dnl Numeric variable.
1795 2; 0; 0; >>-1<<; 0x050800 *2; s8 "VAR1";
1796
1797 dnl Character encoding record.
1798 7; 20; 1; 12; "windows-1252";
1799
1800 dnl End of dictionary.
1801 999; 0;
1802 ])
1803 for variant in be le; do
1804   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1805   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1806 ])
1807   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1808    ["error: `sys-file.sav' near offset 0xb4: Numeric missing value indicator field is not -3, -2, 0, 1, 2, or 3."
1809 ])
1810 done
1811 AT_CLEANUP
1812
1813 AT_SETUP([invalid string missing value indicator])
1814 AT_KEYWORDS([sack synthetic system file negative])
1815 AT_DATA([sys-file.sack], [dnl
1816 dnl File header.
1817 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1818 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1819
1820 dnl String variable.
1821 2; 8; 0; >>4<<; 0x010800 *2; s8 "VAR1";
1822
1823 dnl Character encoding record.
1824 7; 20; 1; 12; "windows-1252";
1825
1826 dnl End of dictionary.
1827 999; 0;
1828 ])
1829 for variant in be le; do
1830   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1831   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1832 ])
1833   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1834    ["error: `sys-file.sav' near offset 0xb4: String missing value indicator field is not 0, 1, 2, or 3."
1835 ])
1836 done
1837 AT_CLEANUP
1838
1839 AT_SETUP([missing string continuation record])
1840 AT_KEYWORDS([sack synthetic system file negative])
1841 AT_DATA([sys-file.sack], [dnl
1842 dnl File header.
1843 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1844 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1845
1846 dnl String variable.
1847 2; 10; 0; 0; 0x010a00 *2; s8 "VAR1";
1848 >>2; 0; 0; 0; 0x050800 *2; s8 "VAR2";<<
1849
1850 dnl Character encoding record.
1851 7; 20; 1; 12; "windows-1252";
1852
1853 dnl End of dictionary.
1854 999; 0;
1855 ])
1856 for variant in be le; do
1857   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1858   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1859 ])
1860   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
1861    [error: `sys-file.sav' near offset 0xb4: Missing string continuation record.
1862 ])
1863 done
1864 AT_CLEANUP
1865
1866 AT_SETUP([invalid variable format])
1867 AT_KEYWORDS([sack synthetic system file negative])
1868 AT_DATA([sys-file.sack], [dnl
1869 dnl File header.
1870 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1871 2; 4; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
1872
1873 dnl Numeric variable, invalid format types.
1874 dnl No warning is issued for type 0 because it has been observed in real
1875 dnl system files.
1876 2; 0; 0; 0; >>0xff0800; 0<<; s8 "NUM1";
1877
1878 dnl Numeric variable, string formats.
1879 2; 0; 0; 0; >>0x010800<<; >>0x021000<<; s8 "VAR1";
1880
1881 dnl String variable, numeric formats.
1882 2; 4; 0; 0; >>0x050800<<; >>0x110a01<<; s8 "STR1";
1883
1884 dnl String variable, wrong width formats.
1885 2; 4; 0; 0; >>0x010800<<; >>0x020400<<; s8 "STR2";
1886
1887 dnl Character encoding record.
1888 7; 20; 1; 12; "windows-1252";
1889
1890 dnl End of dictionary.
1891 999; 0;
1892 ])
1893 for variant in be le; do
1894   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1895   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
1896 ])
1897   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
1898 warning: `sys-file.sav' near offset 0xc0: Variable NUM1 with width 0 has invalid print format 0xff0800.
1899
1900 warning: `sys-file.sav' near offset 0xe0: Variable VAR1 with width 0 has invalid print format 0x10800.
1901
1902 warning: `sys-file.sav' near offset 0xe4: Variable VAR1 with width 0 has invalid write format 0x21000.
1903
1904 warning: `sys-file.sav' near offset 0x100: Variable STR1 with width 4 has invalid print format 0x50800.
1905
1906 warning: `sys-file.sav' near offset 0x104: Variable STR1 with width 4 has invalid write format 0x110a01.
1907
1908 warning: `sys-file.sav' near offset 0x120: Variable STR2 with width 4 has invalid print format 0x10800.
1909
1910 warning: `sys-file.sav' near offset 0x124: Variable STR2 with width 4 has invalid write format 0x20400.
1911 ])
1912 done
1913 AT_CLEANUP
1914
1915 AT_SETUP([invalid long string missing values])
1916 AT_KEYWORDS([sack synthetic system file negative])
1917 AT_DATA([sys-file.sack], [dnl
1918 dnl File header.
1919 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
1920 2; dnl Layout code
1921 7; dnl Nominal case size
1922 0; dnl Not compressed
1923 0; dnl Not weighted
1924 1; dnl 1 case.
1925 100.0; dnl Bias.
1926 "01 Jan 11"; "20:53:52";
1927 "PSPP synthetic test file: "; i8 244; i8 245; i8 246; i8 248; s34 "";
1928 i8 0 *3;
1929
1930 dnl One numeric variable.
1931 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
1932
1933 dnl Long string variables that will have missing values added with a
1934 dnl later record.
1935 2; 9; 0; 0; 0x010900 *2; s8 "STR1";
1936 2; -1; 0; 0; 0; 0; s8 "";
1937 2; 10; 0; 0; 0x010a00 *2; s8 "STR2";
1938 2; -1; 0; 0; 0; 0; s8 "";
1939 2; 11; 0; 0; 0x010b00 *2; s8 "STR3";
1940 2; -1; 0; 0; 0; 0; s8 "";
1941
1942 dnl Machine integer info record.
1943 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
1944
1945 dnl Machine floating-point info record.
1946 7; 4; 8; 3; SYSMIS; HIGHEST; LOWEST;
1947
1948 dnl Long string variable missing values record.
1949 7; 22; 1; COUNT (
1950 dnl Zero missing values (not allowed) for STR1 .
1951 COUNT("STR1"); i8 >>0<<;
1952
1953 dnl Four missing values (not allowed) for STR2.
1954 COUNT("STR2"); i8 4;
1955 8; "abcdefgh"; 8; "ijklmnop"; 8; "qrstuvwx"; 8; "yz012345";
1956
1957 dnl Missing values for unknown variable
1958 COUNT(>>"Nonexistent"<<); i8 1; 8; "abcdefgh";
1959
1960 dnl Missing values for numeric variable
1961 COUNT(>>"NUM1"<<); i8 1; 8; "abcdefgh";
1962
1963 dnl Too long missing value
1964 COUNT("STR3"); i8 1; >>COUNT("abcdefghijkl")<<;
1965 );
1966
1967 dnl Character encoding record.
1968 7; 20; 1; 12; "windows-1252";
1969
1970 dnl Dictionary termination record.
1971 999; 0;
1972 s8 "abcd"; s8 "efgh"; s8 "ijkl"; s8 "mnop"; s8 "qrst"; s8 "uvwx";
1973 s16 "yzABCDEFGHI"; s16 "JKLMNOPQR"; s16 "STUVWXYZ01";
1974 s16 "23456789abc"; s32 "defghijklmnopqstuvwxyzABC";
1975 ])
1976
1977 for variant in be le; do
1978   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
1979   AT_DATA([sys-file.sps], [dnl
1980 GET FILE='sys-file.sav'.
1981 DISPLAY DICTIONARY.
1982 ])
1983   AT_CHECK([pspp -O format=csv sys-file.sps], [0],
1984    ["warning: `sys-file.sav' near offset 0x1f8: Long string missing values record says variable STR1 has 0 missing values, but only 1 to 3 missing values are allowed."
1985
1986 "warning: `sys-file.sav' near offset 0x201: Long string missing values record says variable STR2 has 4 missing values, but only 1 to 3 missing values are allowed."
1987
1988 warning: `sys-file.sav' near offset 0x242: Ignoring long string missing value record for unknown variable Nonexistent.
1989
1990 warning: `sys-file.sav' near offset 0x257: Ignoring long string missing value record for numeric variable NUM1.
1991
1992 "warning: `sys-file.sav' near offset 0x270: Ignoring long string missing value 0 for variable str3, with width 11, that has bad value width 12."
1993
1994 Table: Variables
1995 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
1996 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
1997 str1,2,,Nominal,Input,9,Left,A9,A9,
1998 str2,3,,Nominal,Input,10,Left,A10,A10,"""abcdefgh""; ""ijklmnop""; ""qrstuvwx"""
1999 str3,4,,Nominal,Input,11,Left,A11,A11,
2000 ])
2001 done
2002 AT_CLEANUP
2003
2004 AT_SETUP([weighting variable must be numeric])
2005 AT_KEYWORDS([sack synthetic system file negative])
2006 AT_DATA([sys-file.sack], [dnl
2007 dnl File header.
2008 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2009 2; 2; 1; >>2<<; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2010
2011 dnl Numeric variable.
2012 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2013
2014 dnl String variable.
2015 2; 4; 0; 0; 0x010400 *2; s8 "STR1";
2016
2017 dnl Character encoding record.
2018 7; 20; 1; 12; "windows-1252";
2019
2020 dnl End of dictionary.
2021 999; 0;
2022 ])
2023 for variant in be le; do
2024   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2025   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2026 DISPLAY DICTIONARY.
2027 ])
2028   AT_CHECK([pspp -O format=csv sys-file.sps], [0],
2029    [warning: `sys-file.sav': Ignoring string variable `STR1' set as weighting variable.
2030
2031 Table: Variables
2032 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
2033 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
2034 str1,2,,Nominal,Input,4,Left,A4,A4,
2035 ])
2036 done
2037 AT_CLEANUP
2038
2039 AT_SETUP([bad weighting variable index])
2040 AT_KEYWORDS([sack synthetic system file negative])
2041 AT_DATA([sys-file.sack], [dnl
2042 dnl File header.
2043 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2044 2; 2; 1; >>3<<; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2045
2046 dnl Numeric variable.
2047 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2048
2049 dnl String variable.
2050 2; 4; 0; 0; 0x010400 *2; s8 "STR1";
2051
2052 dnl Character encoding record.
2053 7; 20; 1; 12; "windows-1252";
2054
2055 dnl End of dictionary.
2056 999; 0;
2057 ])
2058 for variant in be le; do
2059   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2060   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2061 ])
2062   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
2063    [error: `sys-file.sav' near offset 0x4c: Variable index 3 not in valid range 1...2.
2064 ])
2065 done
2066 AT_CLEANUP
2067
2068 AT_SETUP([variable index is long string contination])
2069 AT_KEYWORDS([sack synthetic system file negative])
2070 AT_DATA([sys-file.sack], [dnl
2071 dnl File header.
2072 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2073 2; 3; 1; >>3<<; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2074
2075 dnl Numeric variable.
2076 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2077
2078 dnl Long string variable.
2079 2; 9; 0; 0; 0x010900 *2; s8 "STR1";
2080 (2; -1; 0; 0; 0; 0; s8 "");
2081
2082 dnl Character encoding record.
2083 7; 20; 1; 12; "windows-1252";
2084
2085 dnl End of dictionary.
2086 999; 0;
2087 ])
2088 for variant in be le; do
2089   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2090   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2091 ])
2092   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
2093    [error: `sys-file.sav' near offset 0x4c: Variable index 3 refers to long string continuation.
2094 ])
2095 done
2096 AT_CLEANUP
2097
2098 AT_SETUP([multiple documents records])
2099 AT_KEYWORDS([sack synthetic system file negative])
2100 AT_DATA([sys-file.sack], [dnl
2101 dnl File header.
2102 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2103 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2104
2105 dnl Numeric variable, no label or missing values.
2106 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2107
2108 dnl Two document records.
2109 (6; 1; s80 "One line of documents") >>* 2<<;
2110
2111 dnl Dictionary termination record.
2112 999; 0;
2113
2114 dnl Character encoding record.
2115 7; 20; 1; 12; "windows-1252";
2116
2117 dnl Data.
2118 1.0;
2119 ])
2120 for variant in be le; do
2121   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2122   AT_DATA([sys-file.sps], [dnl
2123 GET FILE='sys-file.sav'.
2124 ])
2125   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
2126 error: `sys-file.sav' near offset 0x12c: Duplicate type 6 (document) record.
2127 ])
2128 done
2129 AT_CLEANUP
2130
2131
2132 AT_SETUP([extension record too large])
2133 AT_KEYWORDS([sack synthetic system file negative])
2134 AT_DATA([sys-file.sack], [dnl
2135 dnl File header.
2136 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2137 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2138
2139 dnl Numeric variable, no label or missing values.
2140 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2141
2142 dnl Too-large extension record.
2143 7; 3; >>0xfffff000 * 2<<;
2144 ])
2145 for variant in be le; do
2146   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2147   AT_DATA([sys-file.sps], [dnl
2148 GET FILE='sys-file.sav'.
2149 ])
2150   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
2151 error: `sys-file.sav' near offset 0xd8: Record type 7 subtype 3 too large.
2152 ])
2153 done
2154 AT_CLEANUP
2155
2156 AT_SETUP([unknown extension record])
2157 AT_KEYWORDS([sack synthetic system file negative])
2158 AT_DATA([sys-file.sack], [dnl
2159 dnl File header.
2160 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2161 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2162
2163 dnl Numeric variable, no label or missing values.
2164 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2165
2166 dnl Unknown extension record type.
2167 7; 30; 1; 1; i8 0;
2168
2169 dnl Character encoding record.
2170 7; 20; 1; 12; "windows-1252";
2171
2172 dnl End of dictionary.
2173 999; 0;
2174 ])
2175 for variant in be le; do
2176   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2177   AT_DATA([sys-file.sps], [dnl
2178 GET FILE='sys-file.sav'.
2179 ])
2180   AT_CHECK_UNQUOTED([pspp -O format=csv sys-file.sps], [0], [dnl
2181 "warning: \`sys-file.sav' near offset 0xd8: Unrecognized record type 7, subtype 30.  For help, please send this file to ${PACKAGE_BUGREPORT} and mention that you were using ${PACKAGE_STRING}."
2182 ])
2183 done
2184 AT_CLEANUP
2185
2186 AT_SETUP([bad machine integer info size])
2187 AT_KEYWORDS([sack synthetic system file negative])
2188 AT_DATA([sys-file.sack], [dnl
2189 dnl File header.
2190 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2191 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2192
2193 dnl Numeric variable, no label or missing values.
2194 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2195
2196 dnl Machine integer info record.
2197 7; 3; 4; >>9<<; 1; 2; 3; -1; 1; 1; ENDIAN; 1252; >>1234<<;
2198
2199 dnl Character encoding record.
2200 7; 20; 1; 12; "windows-1252";
2201
2202 dnl End of dictionary.
2203 999; 0;
2204 ])
2205 for variant in be le; do
2206   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2207   AT_DATA([sys-file.sps], [dnl
2208 GET FILE='sys-file.sav'.
2209 ])
2210   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2211 "warning: `sys-file.sav' near offset 0xd8: Record type 7, subtype 3 has bad count 9 (expected 8)."
2212 ])
2213 done
2214 AT_CLEANUP
2215
2216 AT_SETUP([bad machine integer info float format])
2217 AT_KEYWORDS([sack synthetic system file negative])
2218 AT_DATA([sys-file.sack], [dnl
2219 dnl File header.
2220 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2221 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2222
2223 dnl Numeric variable, no label or missing values.
2224 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2225
2226 dnl Machine integer info record.
2227 7; 3; 4; 8; 1; 2; 3; -1; >>2<<; 1; ENDIAN; 1252;
2228
2229 dnl Character encoding record.
2230 7; 20; 1; 12; "windows-1252";
2231
2232 dnl End of dictionary.
2233 999; 0;
2234 ])
2235 for variant in be le; do
2236   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2237   AT_DATA([sys-file.sps], [dnl
2238 GET FILE='sys-file.sav'.
2239 ])
2240   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
2241 error: `sys-file.sav' near offset 0xd8: Floating-point representation indicated by system file (2) differs from expected (1).
2242 ])
2243 done
2244 AT_CLEANUP
2245
2246 AT_SETUP([bad machine integer info endianness])
2247 AT_KEYWORDS([sack synthetic system file negative])
2248 AT_DATA([sys-file.sack], [dnl
2249 dnl File header.
2250 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2251 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2252
2253 dnl Numeric variable, no label or missing values.
2254 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2255
2256 dnl Machine integer info record.
2257 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; >>3<<; 1252;
2258
2259 dnl Character encoding record.
2260 7; 20; 1; 12; "windows-1252";
2261
2262 dnl End of dictionary.
2263 999; 0;
2264 ])
2265 for variant in "be 1" "le 2"; do
2266   set $variant
2267   AT_CHECK([sack --$[1] sys-file.sack > sys-file.sav])
2268   AT_DATA([sys-file.sps], [dnl
2269 GET FILE='sys-file.sav'.
2270 DISPLAY DICTIONARY.
2271 ])
2272   AT_CHECK_UNQUOTED([pspp -O format=csv sys-file.sps], [0], [dnl
2273 warning: \`sys-file.sav' near offset 0xd8: Integer format indicated by system file (3) differs from expected ($[2]).
2274
2275 Table: Variables
2276 Name,Position,Label,Measurement Level,Role,Width,Alignment,Print Format,Write Format,Missing Values
2277 num1,1,,Scale,Input,8,Right,F8.0,F8.0,
2278 ])
2279 done
2280 AT_CLEANUP
2281
2282
2283 AT_SETUP([bad machine floating-point info size])
2284 AT_KEYWORDS([sack synthetic system file negative])
2285 AT_DATA([sys-file.sack], [dnl
2286 dnl File header.
2287 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2288 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2289
2290 dnl Numeric variable, no label or missing values.
2291 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2292
2293 dnl Machine floating-point info record.
2294 7; 4; 8; >>4<<; SYSMIS; HIGHEST; LOWEST; 0.0;
2295
2296 dnl Character encoding record.
2297 7; 20; 1; 12; "windows-1252";
2298
2299 dnl End of dictionary.
2300 999; 0;
2301 ])
2302 for variant in be le; do
2303   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2304   AT_DATA([sys-file.sps], [dnl
2305 GET FILE='sys-file.sav'.
2306 ])
2307   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2308 "warning: `sys-file.sav' near offset 0xd8: Record type 7, subtype 4 has bad count 4 (expected 3)."
2309 ])
2310 done
2311 AT_CLEANUP
2312
2313 AT_SETUP([wrong special floating point values])
2314 AT_KEYWORDS([sack synthetic system file negative])
2315 AT_DATA([sys-file.sack], [dnl
2316 dnl File header.
2317 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2318 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2319
2320 dnl Numeric variable, no label or missing values.
2321 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2322
2323 dnl Machine floating-point info record.
2324 7; 4; 8; 3; >>0.0<<; >>1.0<<; >>2.0<<;
2325
2326 dnl Character encoding record.
2327 7; 20; 1; 12; "windows-1252";
2328
2329 dnl End of dictionary.
2330 999; 0;
2331 ])
2332 for variant in be le; do
2333   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2334   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2335 ])
2336   AT_CHECK([pspp -O format=csv sys-file.sps | sed 's/ [(].*/.../'], [0], [dnl
2337 "warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 0...
2338
2339 "warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 1...
2340
2341 "warning: `sys-file.sav' near offset 0xd8: File specifies unexpected value 2...
2342 ])
2343 done
2344 AT_CLEANUP
2345
2346 AT_SETUP([bad mrsets name])
2347 AT_KEYWORDS([sack synthetic system file negative multiple response])
2348 AT_DATA([sys-file.sack], [dnl
2349 dnl File header.
2350 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2351 2; dnl Layout code
2352 16; dnl Nominal case size
2353 0; dnl Not compressed
2354 0; dnl Not weighted
2355 0; dnl No cases.
2356 100.0; dnl Bias.
2357 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
2358 i8 0 *3;
2359
2360 dnl $a
2361 2; 0; 0; 0; 0x050800 *2; i8 0x82; i8 0xa0; s6 "";
2362 2; 0; 0; 0; 0x050800 *2; s8 "B";
2363 2; 0; 0; 0; 0x050800 *2; s8 "C";
2364
2365 dnl $b
2366 2; 0; 0; 0; 0x050800 *2; s8 "D";
2367 2; 0; 0; 0; 0x050800 *2; s8 "E";
2368 2; 0; 0; 0; 0x050800 *2; s8 "F";
2369 2; 0; 0; 0; 0x050800 *2; s8 "G";
2370
2371 dnl $c
2372 2; 4; 0; 0; 0x010400 *2; s8 "H";
2373 2; 4; 0; 0; 0x010400 *2; s8 "I";
2374 2; 4; 0; 0; 0x010400 *2; s8 "J";
2375
2376 dnl $d
2377 2; 0; 0; 0; 0x050800 *2; s8 "K";
2378 2; 0; 0; 0; 0x050800 *2; s8 "L";
2379 2; 0; 0; 0; 0x050800 *2; s8 "M";
2380
2381 dnl $e
2382 2; 6; 0; 0; 0x010600 *2; s8 "N";
2383 2; 6; 0; 0; 0x010600 *2; s8 "O";
2384 2; 6; 0; 0; 0x010600 *2; s8 "P";
2385
2386 dnl Machine integer info record.
2387 7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 932;
2388
2389 7; 7; 1;
2390 COUNT(
2391   "$a=C 10 my mcgroup "; i8 0x82; i8 0xa0; " b c"; i8 10;
2392   "b=D2 55 0  g e f d"; i8 10;
2393   "$c=D4 "; i8 0x82; i8 0xcd; i8 0x82; i8 0xa2; " 10 mdgroup #2 h i j"; i8 10);
2394
2395 7; 19; 1;
2396 COUNT(
2397   "$d=E 1 2 34 13 third mdgroup k l m"; i8 10;
2398   "e=E 11 6 choice 0  n o p"; i8 10);
2399
2400 dnl Character encoding record.
2401 7; 20; 1; 9; "shift_jis";
2402
2403 dnl Dictionary termination record.
2404 999; 0;
2405 ])
2406 for variant in be le; do
2407   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2408   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2409 MRSETS /DISPLAY NAME=ALL.
2410 ])
2411   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2412 warning: `sys-file.sav': Invalid multiple response set name `b'.
2413
2414 warning: `sys-file.sav': Invalid multiple response set name `e'.
2415
2416 Table: Multiple Response Sets
2417 Name,Variables,Details
2418 $a,"あ
2419 b
2420 c
2421 ","Multiple category set
2422 Label: my mcgroup
2423 "
2424 $c,"h
2425 i
2426 j
2427 ","Multiple dichotomy set
2428 Label: mdgroup #2
2429 Label source: Provided by user
2430 Counted value: `はい'
2431 Category label source: Variable labels
2432 "
2433 $d,"k
2434 l
2435 m
2436 ","Multiple dichotomy set
2437 Label: third mdgroup
2438 Label source: Provided by user
2439 Counted value: 34
2440 Category label source: Value labels of counted value
2441 "
2442 ])
2443 done
2444 AT_CLEANUP
2445
2446 AT_SETUP([missing space after C in mrsets])
2447 AT_KEYWORDS([sack synthetic system file negative multiple response])
2448 AT_DATA([sys-file.sack], [dnl
2449 dnl File header.
2450 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2451 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2452
2453 dnl Numeric variable, no label or missing values.
2454 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2455
2456 dnl Multiple response sets.
2457 7; 7; 1; COUNT("$a=Cx");
2458
2459 dnl Character encoding record.
2460 7; 20; 1; 12; "windows-1252";
2461
2462 999; 0;
2463 ])
2464 for variant in be le; do
2465   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2466   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2467 ])
2468   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2469 warning: `sys-file.sav' near offset 0xd8: Missing space following `C' at offset 4 in MRSETS record.
2470 ])
2471 done
2472 AT_CLEANUP
2473
2474 AT_SETUP([missing space after E in mrsets])
2475 AT_KEYWORDS([sack synthetic system file negative multiple response])
2476 AT_DATA([sys-file.sack], [dnl
2477 dnl File header.
2478 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2479 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2480
2481 dnl Numeric variable, no label or missing values.
2482 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2483
2484 dnl Multiple response sets.
2485 7; 7; 1; COUNT("$a=Ex");
2486
2487 dnl Character encoding record.
2488 7; 20; 1; 12; "windows-1252";
2489
2490 999; 0;
2491 ])
2492 for variant in be le; do
2493   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2494   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2495 ])
2496   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2497 warning: `sys-file.sav' near offset 0xd8: Missing space following `E' at offset 4 in MRSETS record.
2498 ])
2499 done
2500 AT_CLEANUP
2501
2502 AT_SETUP([missing label source in mrsets])
2503 AT_KEYWORDS([sack synthetic system file negative multiple response])
2504 AT_DATA([sys-file.sack], [dnl
2505 dnl File header.
2506 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2507 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2508
2509 dnl Numeric variable, no label or missing values.
2510 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2511
2512 dnl Multiple response sets.
2513 7; 7; 1; COUNT("$a=E ");
2514
2515 dnl Character encoding record.
2516 7; 20; 1; 12; "windows-1252";
2517
2518 999; 0;
2519 ])
2520 for variant in be le; do
2521   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2522   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2523 ])
2524   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2525 warning: `sys-file.sav' near offset 0xd8: Missing label source value following `E' at offset 5 in MRSETS record.
2526
2527 warning: `sys-file.sav' near offset 0xd8: Expecting digit at offset 5 in MRSETS record.
2528 ])
2529 done
2530 AT_CLEANUP
2531
2532 AT_SETUP([unexpected label source in mrsets])
2533 AT_KEYWORDS([sack synthetic system file negative multiple response])
2534 AT_DATA([sys-file.sack], [dnl
2535 dnl File header.
2536 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2537 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2538
2539 dnl Numeric variable, no label or missing values.
2540 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2541
2542 dnl Multiple response sets.
2543 7; 7; 1; COUNT("$a=E 2");
2544
2545 dnl Character encoding record.
2546 7; 20; 1; 12; "windows-1252";
2547
2548 999; 0;
2549 ])
2550 for variant in be le; do
2551   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2552   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2553 ])
2554   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2555 warning: `sys-file.sav' near offset 0xd8: Unexpected label source value following `E' at offset 7 in MRSETS record.
2556
2557 warning: `sys-file.sav' near offset 0xd8: Expecting digit at offset 7 in MRSETS record.
2558 ])
2559 done
2560 AT_CLEANUP
2561
2562 AT_SETUP([bad type character in mrsets])
2563 AT_KEYWORDS([sack synthetic system file negative multiple response])
2564 AT_DATA([sys-file.sack], [dnl
2565 dnl File header.
2566 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2567 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2568
2569 dnl Numeric variable, no label or missing values.
2570 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2571
2572 dnl Multiple response sets.
2573 7; 7; 1; COUNT("$a=");
2574
2575 dnl Character encoding record.
2576 7; 20; 1; 12; "windows-1252";
2577
2578 999; 0;
2579 ])
2580 for variant in be le; do
2581   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2582   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2583 ])
2584   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2585 "warning: `sys-file.sav' near offset 0xd8: Missing `C', `D', or `E' at offset 3 in MRSETS record."
2586 ])
2587 done
2588 AT_CLEANUP
2589
2590 AT_SETUP([bad counted string length in mrsets])
2591 AT_KEYWORDS([sack synthetic system file negative multiple response])
2592 AT_DATA([sys-file.sack], [dnl
2593 dnl File header.
2594 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2595 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2596
2597 dnl Numeric variable, no label or missing values.
2598 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2599
2600 dnl Multiple response sets.
2601 7; 7; 1; COUNT("$a=Dx");
2602
2603 dnl Character encoding record.
2604 7; 20; 1; 12; "windows-1252";
2605
2606 999; 0;
2607 ])
2608 for variant in be le; do
2609   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2610   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2611 ])
2612   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2613 warning: `sys-file.sav' near offset 0xd8: Expecting digit at offset 4 in MRSETS record.
2614 ])
2615 done
2616 AT_CLEANUP
2617
2618 AT_SETUP([missing space in counted string in mrsets])
2619 AT_KEYWORDS([sack synthetic system file negative multiple response])
2620 AT_DATA([sys-file.sack], [dnl
2621 dnl File header.
2622 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2623 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2624
2625 dnl Numeric variable, no label or missing values.
2626 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2627
2628 dnl Multiple response sets.
2629 7; 7; 1; COUNT("$a=D1x");
2630
2631 dnl Character encoding record.
2632 7; 20; 1; 12; "windows-1252";
2633
2634 999; 0;
2635 ])
2636 for variant in be le; do
2637   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2638   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2639 ])
2640   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2641 warning: `sys-file.sav' near offset 0xd8: Expecting space at offset 5 in MRSETS record.
2642 ])
2643 done
2644 AT_CLEANUP
2645
2646 AT_SETUP([counted string too long in mrsets])
2647 AT_KEYWORDS([sack synthetic system file negative multiple response])
2648 AT_DATA([sys-file.sack], [dnl
2649 dnl File header.
2650 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2651 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2652
2653 dnl Numeric variable, no label or missing values.
2654 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2655
2656 dnl Multiple response sets.
2657 7; 7; 1; COUNT("$a=D4 abc");
2658
2659 dnl Character encoding record.
2660 7; 20; 1; 12; "windows-1252";
2661
2662 999; 0;
2663 ])
2664 for variant in be le; do
2665   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2666   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2667 ])
2668   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2669 warning: `sys-file.sav' near offset 0xd8: 4-byte string starting at offset 6 exceeds record length 9.
2670 ])
2671 done
2672 AT_CLEANUP
2673
2674 AT_SETUP([missing space after counted string in mrsets])
2675 AT_KEYWORDS([sack synthetic system file negative multiple response])
2676 AT_DATA([sys-file.sack], [dnl
2677 dnl File header.
2678 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2679 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2680
2681 dnl Numeric variable, no label or missing values.
2682 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2683
2684 dnl Multiple response sets.
2685 7; 7; 1; COUNT("$a=D3 abcx");
2686
2687 dnl Character encoding record.
2688 7; 20; 1; 12; "windows-1252";
2689
2690 999; 0;
2691 ])
2692 for variant in be le; do
2693   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2694   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2695 ])
2696   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2697 warning: `sys-file.sav' near offset 0xd8: Expecting space at offset 9 following 3-byte string.
2698 ])
2699 done
2700 AT_CLEANUP
2701
2702 AT_SETUP([missing newline after variable name in mrsets])
2703 AT_KEYWORDS([sack synthetic system file negative multiple response])
2704 AT_DATA([sys-file.sack], [dnl
2705 dnl File header.
2706 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2707 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2708
2709 dnl Numeric variable, no label or missing values.
2710 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2711
2712 dnl Multiple response sets.
2713 7; 7; 1; COUNT("$a=C 0  NUM1");
2714
2715 dnl Character encoding record.
2716 7; 20; 1; 12; "windows-1252";
2717
2718 999; 0;
2719 ])
2720 for variant in be le; do
2721   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2722   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2723 ])
2724   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2725 warning: `sys-file.sav' near offset 0xd8: Missing new-line parsing variable names at offset 13 in MRSETS record.
2726
2727 warning: `sys-file.sav': MRSET $a has only one variable.
2728 ])
2729 done
2730 AT_CLEANUP
2731
2732 AT_SETUP([duplicate variable name in mrsets])
2733 AT_KEYWORDS([sack synthetic system file negative multiple response])
2734 AT_DATA([sys-file.sack], [dnl
2735 dnl File header.
2736 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2737 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2738
2739 dnl Numeric variable, no label or missing values.
2740 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2741
2742 dnl Multiple response sets.
2743 7; 7; 1; COUNT("$a=C 0  NUM1 NUM1"; i8 10);
2744
2745 dnl Character encoding record.
2746 7; 20; 1; 12; "windows-1252";
2747
2748 999; 0;
2749 ])
2750 for variant in be le; do
2751   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2752   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2753 ])
2754   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2755 warning: `sys-file.sav': MRSET $a contains duplicate variable name NUM1.
2756
2757 warning: `sys-file.sav': MRSET $a has only one variable.
2758 ])
2759 done
2760 AT_CLEANUP
2761
2762 AT_SETUP([mixed variable types in mrsets])
2763 AT_KEYWORDS([sack synthetic system file negative multiple response])
2764 AT_DATA([sys-file.sack], [dnl
2765 dnl File header.
2766 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2767 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2768
2769 dnl Variables.
2770 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2771 2; 8; 0; 0; 0x010800 *2; s8 "STR1";
2772
2773 dnl Multiple response sets.
2774 7; 7; 1; COUNT("$a=C 0  NUM1 STR1"; i8 10);
2775
2776 dnl Character encoding record.
2777 7; 20; 1; 12; "windows-1252";
2778
2779 999; 0;
2780 ])
2781 for variant in be le; do
2782   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2783   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2784 ])
2785   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2786 warning: `sys-file.sav': MRSET $a contains both string and numeric variables.
2787
2788 warning: `sys-file.sav': MRSET $a has only one variable.
2789 ])
2790 done
2791 AT_CLEANUP
2792
2793 AT_SETUP([missing newline after variable name in mrsets])
2794 AT_KEYWORDS([sack synthetic system file negative multiple response])
2795 AT_DATA([sys-file.sack], [dnl
2796 dnl File header.
2797 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2798 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2799
2800 dnl Numeric variable, no label or missing values.
2801 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2802
2803 dnl Multiple response sets.
2804 7; 7; 1; COUNT("$a=C 0  NUM1"; i8 10);
2805
2806 dnl Character encoding record.
2807 7; 20; 1; 12; "windows-1252";
2808
2809 999; 0;
2810 ])
2811 for variant in be le; do
2812   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2813   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2814 ])
2815   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2816 warning: `sys-file.sav': MRSET $a has only one variable.
2817 ])
2818 done
2819 AT_CLEANUP
2820
2821 AT_SETUP([zero or one variable in mrset])
2822 AT_KEYWORDS([sack synthetic system file negative multiple response])
2823 AT_DATA([sys-file.sack], [dnl
2824 dnl File header.
2825 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2826 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2827
2828 dnl Numeric variable, no label or missing values.
2829 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2830
2831 dnl Multiple response sets.
2832 7; 7; 1; COUNT("$a=C 0  NUM1"; i8 10; "$b=C 0  "; i8 10);
2833
2834 dnl Character encoding record.
2835 7; 20; 1; 12; "windows-1252";
2836
2837 999; 0;
2838 ])
2839 for variant in be le; do
2840   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2841   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2842 ])
2843   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2844 warning: `sys-file.sav': MRSET $a has only one variable.
2845
2846 warning: `sys-file.sav': MRSET $b has no variables.
2847 ])
2848 done
2849 AT_CLEANUP
2850
2851 AT_SETUP([wrong display parameter size])
2852 AT_KEYWORDS([sack synthetic system file negative])
2853 AT_DATA([sys-file.sack], [dnl
2854 dnl File header.
2855 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2856 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2857
2858 dnl Numeric variable, no label or missing values.
2859 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2860
2861 dnl Display parameters record.
2862 7; 11; >>8<<; 2; 1.0; 1.0;
2863
2864 dnl Character encoding record.
2865 7; 20; 1; 12; "windows-1252";
2866
2867 dnl End of dictionary.
2868 999; 0;
2869 ])
2870 for variant in be le; do
2871   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2872   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2873 ])
2874   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2875 "warning: `sys-file.sav' near offset 0xd8: Record type 7, subtype 11 has bad size 8 (expected 4)."
2876 ])
2877 done
2878 AT_CLEANUP
2879
2880 AT_SETUP([wrong display parameter count])
2881 AT_KEYWORDS([sack synthetic system file negative])
2882 AT_DATA([sys-file.sack], [dnl
2883 dnl File header.
2884 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2885 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2886
2887 dnl Numeric variable, no label or missing values.
2888 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2889
2890 dnl Display parameters record.
2891 7; 11; 4; >>4<<; 1; 1; 2; 2;
2892
2893 dnl Character encoding record.
2894 7; 20; 1; 12; "windows-1252";
2895
2896 dnl End of dictionary.
2897 999; 0;
2898 ])
2899 for variant in be le; do
2900   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2901   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2902 ])
2903   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2904 warning: `sys-file.sav' near offset 0xd8: Extension 11 has bad count 4 (for 1 variables).
2905 ])
2906 done
2907 AT_CLEANUP
2908
2909 AT_SETUP([wrong display measurement level])
2910 AT_KEYWORDS([sack synthetic system file negative])
2911 AT_DATA([sys-file.sack], [dnl
2912 dnl File header.
2913 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2914 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2915
2916 dnl Numeric variable, no label or missing values.
2917 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2918
2919 dnl Display parameters record.
2920 7; 11; 4; 2; >>4<<; 0;
2921
2922 dnl Character encoding record.
2923 7; 20; 1; 12; "windows-1252";
2924
2925 dnl End of dictionary.
2926 999; 0;
2927 ])
2928 for variant in be le; do
2929   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2930   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2931 ])
2932   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2933 warning: `sys-file.sav' near offset 0xd8: Invalid variable display parameters for variable 0 (NUM1).  Default parameters substituted.
2934 ])
2935 done
2936 AT_CLEANUP
2937
2938 AT_SETUP([wrong display alignment])
2939 AT_KEYWORDS([sack synthetic system file negative])
2940 AT_DATA([sys-file.sack], [dnl
2941 dnl File header.
2942 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2943 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2944
2945 dnl Numeric variable, no label or missing values.
2946 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
2947
2948 dnl Display parameters record.
2949 7; 11; 4; 2; 1; >>-1<<;
2950
2951 dnl Character encoding record.
2952 7; 20; 1; 12; "windows-1252";
2953
2954 dnl End of dictionary.
2955 999; 0;
2956 ])
2957 for variant in be le; do
2958   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2959   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
2960 ])
2961   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2962 warning: `sys-file.sav' near offset 0xd8: Invalid variable display parameters for variable 0 (NUM1).  Default parameters substituted.
2963 ])
2964 done
2965 AT_CLEANUP
2966
2967 AT_SETUP([bad variable name in variable/value pair])
2968 AT_KEYWORDS([sack synthetic system file negative])
2969 AT_DATA([sys-file.sack], [dnl
2970 dnl File header.
2971 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
2972 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
2973
2974 dnl Numeric variables.
2975 2; 0; 0; 0; 0x050800 *2; s8 "LONGVARI";
2976
2977 dnl Long variable names.
2978 7; 13; 1; COUNT (>>"xyzzy"<<);
2979
2980 dnl Character encoding record.
2981 7; 20; 1; 12; "windows-1252";
2982
2983 dnl Dictionary termination record.
2984 999; 0;
2985 ])
2986 for variant in be le; do
2987   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
2988   AT_DATA([sys-file.sps], [dnl
2989 GET FILE='sys-file.sav'.
2990 ])
2991   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
2992 warning: `sys-file.sav' near offset 0xde: Dictionary record refers to unknown variable xyzzy.
2993 ])
2994 done
2995 AT_CLEANUP
2996
2997 AT_SETUP([duplicate long variable name])
2998 AT_KEYWORDS([sack synthetic system file negative])
2999 AT_DATA([sys-file.sack], [dnl
3000 dnl File header.
3001 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3002 2; 4; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3003
3004 dnl Numeric variables.
3005 2; 0; 0; 0; 0x050800 *2; s8 "LONGVARI";
3006 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_A";
3007 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_B";
3008 2; 0; 0; 0; 0x050800 *2; s8 "LONGVA_C";
3009
3010 dnl Long variable names.
3011 7; 13; 1; COUNT (
3012 "LONGVARI=_Invalid"; i8 9;
3013 "LONGVARI=$Invalid"; i8 9;
3014 "LONGVARI=#Invalid"; i8 9;
3015 "LONGVA_A=LongVariableName"; i8 9;
3016 "LONGVA_B=LONGVARIABLENAME"; i8 9;
3017 );
3018
3019 dnl Character encoding record.
3020 7; 20; 1; 12; "windows-1252";
3021
3022 dnl Dictionary termination record.
3023 999; 0;
3024 ])
3025 for variant in be le; do
3026   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3027   AT_DATA([sys-file.sps], [dnl
3028 GET FILE='sys-file.sav'.
3029 ])
3030   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3031 warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `_Invalid'.
3032
3033 warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `$Invalid'.
3034
3035 warning: `sys-file.sav' near offset 0x138: Long variable mapping from LONGVARI to invalid variable name `#Invalid'.
3036
3037 warning: `sys-file.sav' near offset 0x138: Duplicate long variable name `LONGVARIABLENAME'.
3038 ])
3039 done
3040 AT_CLEANUP
3041
3042 AT_SETUP([bad very long string length])
3043 AT_KEYWORDS([sack synthetic system file negative])
3044 AT_DATA([sys-file.sack], [dnl
3045 dnl File header.
3046 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3047 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3048
3049 dnl Numeric variable.
3050 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3051
3052 dnl Very long string map.
3053 7; 14; 1; COUNT (
3054 "NUM1=00000"; i8 0; i8 9;
3055 "NUM1=00255"; i8 0; i8 9;
3056 "NUM1=00256"; i8 0; i8 9;
3057 );
3058
3059 dnl Character encoding record.
3060 7; 20; 1; 12; "windows-1252";
3061
3062 dnl Dictionary termination record.
3063 999; 0;
3064 ])
3065 for variant in be le; do
3066   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3067   AT_DATA([sys-file.sps], [dnl
3068 GET FILE='sys-file.sav'.
3069 ])
3070   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3071 warning: `sys-file.sav' near offset 0xd8: NUM1 listed as string of invalid length 00000 in very long string record.
3072
3073 "warning: `sys-file.sav' near offset 0xd8: NUM1 listed in very long string record with width 00255, which requires only one segment."
3074
3075 error: `sys-file.sav' near offset 0xd8: Very long string NUM1 overflows dictionary.
3076 ])
3077 done
3078 AT_CLEANUP
3079
3080 AT_SETUP([bad very long string segment width])
3081 AT_KEYWORDS([sack synthetic system file negative])
3082 AT_DATA([sys-file.sack], [dnl
3083 dnl File header.
3084 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3085 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3086
3087 dnl Variables.
3088 2; 255; 0; 0; 0x01ff00 *2; s8 "STR1";
3089 (2; -1; 0; 0; 0; 0; s8 "") * 31;
3090 2; >>9<<; 0; 0; 0x010900 *2; s8 "STR1_A";
3091 >>2; -1; 0; 0; 0; 0; s8 "";<<
3092
3093 dnl Very long string map.
3094 7; 14; 1; COUNT (
3095 "STR1=00256"; i8 0; i8 9;
3096 );
3097
3098 dnl Character encoding record.
3099 7; 20; 1; 12; "windows-1252";
3100
3101 dnl Dictionary termination record.
3102 999; 0;
3103 ])
3104 for variant in be le; do
3105   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3106   AT_DATA([sys-file.sps], [dnl
3107 GET FILE='sys-file.sav'.
3108 ])
3109   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3110 error: `sys-file.sav' near offset 0x4f8: Very long string with width 256 has segment 1 of width 9 (expected 4).
3111 ])
3112 done
3113 AT_CLEANUP
3114
3115 AT_SETUP([too many value labels])
3116 AT_KEYWORDS([sack synthetic system file negative])
3117 AT_DATA([sys-file.sack], [dnl
3118 dnl File header.
3119 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3120 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3121
3122 dnl Numeric variable.
3123 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3124 3; >>0x7fffffff<<;
3125 ])
3126 for variant in be le; do
3127   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3128   AT_DATA([sys-file.sps], [dnl
3129 GET FILE='sys-file.sav'.
3130 ])
3131   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3132 error: `sys-file.sav' near offset 0xd4: Invalid number of labels 2147483647.
3133 ])
3134 done
3135 AT_CLEANUP
3136
3137 AT_SETUP([missing type 4 record])
3138 AT_KEYWORDS([sack synthetic system file negative])
3139 AT_DATA([sys-file.sack], [dnl
3140 dnl File header.
3141 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3142 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3143
3144 dnl Numeric variable.
3145 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3146
3147 dnl Value label with missing type 4 record.
3148 3; 1; 1.0; i8 3; s7 "one";
3149
3150 dnl Character encoding record.
3151 7; 20; 1; 12; "windows-1252";
3152
3153 dnl End of dictionary.
3154 >>999; 0<<;
3155 ])
3156 for variant in be le; do
3157   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3158   AT_DATA([sys-file.sps], [dnl
3159 GET FILE='sys-file.sav'.
3160 ])
3161   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3162 error: `sys-file.sav' near offset 0xe8: Variable index record (type 4) does not immediately follow value label record (type 3) as it should.
3163 ])
3164 done
3165 AT_CLEANUP
3166
3167 AT_SETUP([value label with no associated variables])
3168 AT_KEYWORDS([sack synthetic system file negative])
3169 AT_DATA([sys-file.sack], [dnl
3170 dnl File header.
3171 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3172 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3173
3174 dnl Numeric variable.
3175 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3176
3177 dnl Value label with no variables.
3178 3; 1; 1.0; i8 3; s7 "one"; 4; >>0<<;
3179 ])
3180 for variant in be le; do
3181   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3182   AT_DATA([sys-file.sps], [dnl
3183 GET FILE='sys-file.sav'.
3184 ])
3185   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3186 error: `sys-file.sav' near offset 0xec: Number of variables associated with a value label (0) is not between 1 and the number of variables (1).
3187 ])
3188 done
3189 AT_CLEANUP
3190
3191 AT_SETUP([type 4 record names long string variable])
3192 AT_KEYWORDS([sack synthetic system file negative])
3193 AT_DATA([sys-file.sack], [dnl
3194 dnl File header.
3195 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3196 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3197
3198 dnl Long string variable.
3199 2; 9; 0; 0; 0x010900 *2; s8 "STR1";
3200 2; -1; 0; 0; 0; 0; s8 "";
3201
3202 dnl Value label that names long string variable.
3203 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 1; >>1<<;
3204
3205 dnl Character encoding record.
3206 7; 20; 1; 12; "windows-1252";
3207
3208 dnl End of dictionary.
3209 999; 0;
3210 ])
3211 for variant in be le; do
3212   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3213   AT_DATA([sys-file.sps], [dnl
3214 GET FILE='sys-file.sav'.
3215 ])
3216   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3217 error: `sys-file.sav' near offset 0xf4: Value labels may not be added to long string variables (e.g. STR1) using records types 3 and 4.
3218 ])
3219 done
3220 AT_CLEANUP
3221
3222 AT_SETUP([variables for value label must all be same type])
3223 AT_KEYWORDS([sack synthetic system file negative])
3224 AT_DATA([sys-file.sack], [dnl
3225 dnl File header.
3226 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3227 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3228
3229 dnl Variables.
3230 2; 6; 0; 0; 0x010600 *2; s8 "STR1";
3231 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3232
3233 dnl Value label that names numeric and string variables.
3234 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 2; >>1; 2<<;
3235
3236 dnl Character encoding record.
3237 7; 20; 1; 12; "windows-1252";
3238
3239 dnl End of dictionary.
3240 999; 0;
3241 ])
3242 for variant in be le; do
3243   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3244   AT_DATA([sys-file.sps], [dnl
3245 GET FILE='sys-file.sav'.
3246 ])
3247   AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
3248 "error: `sys-file.sav' near offset 0xf4: Variables associated with value label are not all of identical type.  Variable STR1 is string, but variable NUM1 is numeric."
3249 ])
3250 done
3251 AT_CLEANUP
3252
3253 AT_SETUP([duplicate value labels type])
3254 AT_KEYWORDS([sack synthetic system file negative])
3255 AT_DATA([sys-file.sack], [dnl
3256 dnl File header.
3257 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3258 2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3259
3260 dnl Variables.
3261 2; 6; 0; 0; 0x010600 *2; s8 "STR1";
3262 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3263
3264 dnl Duplicate value labels.
3265 3; 1; s8 "xyzzy"; i8 3; s7 "one"; 4; 2; >>1; 1<<;
3266 3; 1; 1.0; i8 3; s7 "one"; 4; 2; >>2; 2<<;
3267
3268 dnl Character encoding record.
3269 7; 20; 1; 12; "windows-1252";
3270
3271 dnl End of dictionary.
3272 999; 0;
3273 ])
3274 for variant in be le; do
3275   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3276   AT_DATA([sys-file.sps], [dnl
3277 GET FILE='sys-file.sav'.
3278 ])
3279   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3280 warning: `sys-file.sav' near offset 0xf4: Duplicate value label for `xyzzy ' on STR1.
3281
3282 warning: `sys-file.sav' near offset 0x11c: Duplicate value label for 1 on NUM1.
3283 ])
3284 done
3285 AT_CLEANUP
3286
3287 AT_SETUP([missing attribute value])
3288 AT_KEYWORDS([sack synthetic system file negative])
3289 AT_DATA([sys-file.sack], [dnl
3290 dnl File header.
3291 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3292 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3293
3294 dnl Variables.
3295 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
3296
3297 dnl Data file attributes record.
3298 7; 17; 1; COUNT (
3299 "Attr1("
3300 );
3301
3302 dnl Variable attributes record.
3303 7; 18; 1; COUNT (
3304 "FIRSTVAR:";
3305   "fred('23'"; i8 10
3306 );
3307
3308 dnl Character encoding record.
3309 7; 20; 1; 12; "windows-1252";
3310
3311 dnl Dictionary termination record.
3312 999; 0;
3313 ])
3314 for variant in be le; do
3315   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3316   AT_DATA([sys-file.sps], [dnl
3317 GET FILE='sys-file.sav'.
3318 ])
3319   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3320 warning: `sys-file.sav' near offset 0xde: Error parsing attribute value Attr1[[1]].
3321
3322 warning: `sys-file.sav' near offset 0x101: Error parsing attribute value fred[[2]].
3323 ])
3324 done
3325 AT_CLEANUP
3326
3327 AT_SETUP([unquoted attribute value])
3328 AT_KEYWORDS([sack synthetic system file negative])
3329 AT_DATA([sys-file.sack], [dnl
3330 dnl File header.
3331 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3332 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3333
3334 dnl Variables.
3335 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
3336
3337 dnl Data file attributes record.
3338 7; 17; 1; COUNT (
3339 "Attr1(value"; i8 10;
3340 ")"
3341 );
3342
3343 dnl Variable attributes record.
3344 7; 18; 1; COUNT (
3345 "FIRSTVAR:";
3346   "fred(23"; i8 10; ")"
3347 );
3348
3349 dnl Character encoding record.
3350 7; 20; 1; 12; "windows-1252";
3351
3352 dnl Dictionary termination record.
3353 999; 0;
3354 ])
3355 for variant in be le; do
3356   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3357   AT_DATA([sys-file.sps], [dnl
3358 GET FILE='sys-file.sav'.
3359 ])
3360   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3361 warning: `sys-file.sav' near offset 0xe4: Attribute value Attr1[[1]] is not quoted: value.
3362
3363 warning: `sys-file.sav' near offset 0x106: Attribute value fred[[1]] is not quoted: 23.
3364 ])
3365 done
3366 AT_CLEANUP
3367
3368 AT_SETUP([duplicate attribute name])
3369 AT_KEYWORDS([sack synthetic system file negative])
3370 AT_DATA([sys-file.sack], [dnl
3371 dnl File header.
3372 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3373 2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3374
3375 dnl Variables.
3376 2; 0; 0; 0; 0x050800 *2; s8 "FIRSTVAR";
3377
3378 dnl Data file attributes record.
3379 7; 17; 1; COUNT (
3380 "Attr1('value'"; i8 10; ")";
3381 "Attr1('value'"; i8 10; ")";
3382 );
3383
3384 dnl Variable attributes record.
3385 7; 18; 1; COUNT (
3386 "FIRSTVAR:";
3387   "fred('23'"; i8 10; ")";
3388   "fred('23'"; i8 10; ")";
3389 );
3390
3391 dnl Character encoding record.
3392 7; 20; 1; 12; "windows-1252";
3393
3394 dnl Dictionary termination record.
3395 999; 0;
3396 ])
3397 for variant in be le; do
3398   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3399   AT_DATA([sys-file.sps], [dnl
3400 GET FILE='sys-file.sav'.
3401 ])
3402   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3403 warning: `sys-file.sav' near offset 0xf6: Duplicate attribute Attr1.
3404
3405 warning: `sys-file.sav' near offset 0x125: Duplicate attribute fred.
3406 ])
3407 done
3408 AT_CLEANUP
3409
3410 AT_SETUP([bad variable name in long string value label])
3411 AT_KEYWORDS([sack synthetic system file negative])
3412 AT_DATA([sys-file.sack], [dnl
3413 dnl File header.
3414 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3415 2; 3; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3416
3417 dnl Variables.
3418 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3419 2; 14; 0; 0; 0x010e00 *2; s8 "STR14";
3420 2; -1; 0; 0; 0; 0; s8 "";
3421
3422 7; 21; 1; COUNT (
3423 dnl No variable named STR9.
3424 COUNT(>>"STR9"<<); 9;
3425 1; COUNT("RSTUVWXYZ"); COUNT("value label for `RSTUVWXYZ'");
3426
3427 dnl NUM1 is numeric.
3428 COUNT(>>"NUM1"<<); 0;
3429 1; COUNT("xyz"); COUNT("value label for 1.0");
3430
3431 dnl Wrong width for STR14.
3432 COUNT("STR14"); >>9<<;
3433 1; COUNT("RSTUVWXYZ"); COUNT("value label for `RSTUVWXYZ'");
3434
3435 dnl Wrong width for value.
3436 COUNT("STR14"); 14;
3437 1; COUNT(>>"RSTUVWXYZ"<<); COUNT("value label for `RSTUVWXYZ'");
3438
3439 dnl Duplicate value label.
3440 COUNT("STR14"); 14; 2;
3441 COUNT("abcdefghijklmn"); COUNT("value label for `abcdefghijklmn'");
3442 >>COUNT("abcdefghijklmn"); COUNT("another value label for `abcdefghijklmn'")<<;
3443 );
3444
3445 dnl Character encoding record.
3446 7; 20; 1; 12; "windows-1252";
3447
3448 dnl Dictionary termination record.
3449 999; 0;
3450 ])
3451 for variant in be le; do
3452   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3453   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3454 ])
3455   AT_CHECK([pspp -O format=csv sys-file.sps], [0], [dnl
3456 warning: `sys-file.sav' near offset 0x128: Ignoring long string value label record for unknown variable STR9.
3457
3458 warning: `sys-file.sav' near offset 0x164: Ignoring long string value label record for numeric variable NUM1.
3459
3460 warning: `sys-file.sav' near offset 0x193: Ignoring long string value label record for variable STR14 because the record's width (9) does not match the variable's width (14).
3461
3462 "warning: `sys-file.sav' near offset 0x1d4: Ignoring long string value label 0 for variable str14, with width 14, that has bad value width 9."
3463
3464 warning: `sys-file.sav' near offset 0x259: Duplicate value label for `abcdefghijklmn' on str14.
3465 ])
3466 done
3467 AT_CLEANUP
3468
3469 AT_SETUP([fewer data records than indicated by file header])
3470 AT_KEYWORDS([sack synthetic system file negative])
3471 AT_DATA([sys-file.sack], [dnl
3472 dnl File header.
3473 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3474 2; 2; 0; 0; >>5<<; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3475
3476 dnl Numeric variables.
3477 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3478 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3479
3480 dnl Character encoding record.
3481 7; 20; 1; 12; "windows-1252";
3482
3483 dnl Data.
3484 999; 0;
3485 1.0; 2.0;
3486 3.0; 4.0;
3487 5.0; 6.0;
3488 7.0; 8.0;
3489 dnl Missing record here.
3490 ])
3491 for variant in be le; do
3492   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3493   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3494 LIST.
3495 ])
3496   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
3497    [error: Error reading case from file `sys-file.sav'.
3498
3499 Table: Data List
3500 num1,num2
3501 1,2
3502 3,4
3503 5,6
3504 7,8
3505 ])
3506 done
3507 AT_CLEANUP
3508
3509 AT_SETUP([partial data record between variables])
3510 AT_KEYWORDS([sack synthetic system file negative])
3511 AT_DATA([sys-file.sack], [dnl
3512 dnl File header.
3513 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3514 2; 2; 0; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3515
3516 dnl Numeric variables.
3517 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3518 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3519
3520 dnl Character encoding record.
3521 7; 20; 1; 12; "windows-1252";
3522
3523 dnl Data.
3524 999; 0;
3525 1.0; 2.0;
3526 3.0;
3527 ])
3528 for variant in be le; do
3529   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3530   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3531 LIST.
3532 ])
3533   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
3534    [error: `sys-file.sav' near offset 0x12c: File ends in partial case.
3535
3536 Table: Data List
3537 num1,num2
3538 1,2
3539 ])
3540 done
3541 AT_CLEANUP
3542
3543 AT_SETUP([partial data record within long string])
3544 AT_KEYWORDS([sack synthetic system file negative])
3545 AT_DATA([sys-file.sack], [dnl
3546 dnl File header.
3547 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3548 2; 2; 0; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
3549
3550 dnl Numeric variables.
3551 2; 14; 0; 0; 0x010e00 *2; s8 "STR14";
3552 2; -1; 0; 0; 0; 0; s8 "";
3553
3554 dnl Character encoding record.
3555 7; 20; 1; 12; "windows-1252";
3556
3557 dnl Data.
3558 999; 0;
3559 s14 "one data item";
3560 s8 "partial";
3561 ])
3562 for variant in be le; do
3563   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3564   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3565 LIST.
3566 ])
3567   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
3568    [error: `sys-file.sav' near offset 0x12a: Unexpected end of file.
3569
3570 Table: Data List
3571 str14
3572 one data item @&t@
3573 ])
3574 done
3575 AT_CLEANUP
3576
3577 AT_SETUP([partial compressed data record])
3578 AT_KEYWORDS([sack synthetic system file positive])
3579 AT_DATA([sys-file.sack], [dnl
3580 dnl File header.
3581 "$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3582 2; dnl Layout code
3583 6; dnl Nominal case size
3584 1; dnl Compressed
3585 0; dnl Not weighted 
3586 -1; dnl Unspecified number of cases.
3587 100.0; dnl Bias.
3588 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
3589 i8 0 *3;
3590
3591 dnl Numeric variables.
3592 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3593 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3594
3595 dnl String variable.
3596 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
3597 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
3598 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
3599 2; -1; 0; 0; 0; 0; s8 "";
3600
3601 dnl Character encoding record.
3602 7; 20; 1; 12; "windows-1252";
3603
3604 dnl Dictionary termination record.
3605 999; 0;
3606
3607 dnl Compressed data.
3608 i8 1 100 254 253 254 253; i8 255 251; "abcdefgh"; s8 "0123";
3609 ])
3610 for variant in be le; do
3611   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3612   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3613 LIST.
3614 ])
3615   AT_CHECK([pspp -O format=csv sys-file.sps], [1], 
3616    [error: `sys-file.sav' near offset 0x1ac: File ends in partial case.
3617
3618 Table: Data List
3619 num1,num2,str4,str8,str15
3620 -99,0,,abcdefgh,0123   @&t@
3621 ])
3622 done
3623 AT_CLEANUP
3624
3625 AT_SETUP([zcompressed data - bad zheader_ofs])
3626 AT_KEYWORDS([sack synthetic system file negative zlib])
3627 zcompressed_sack | sed 's/.*zheader_ofs.*/>>i64 0<<;/' > sys-file.sack
3628 for variant in be le; do
3629   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3630   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3631 ])
3632   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x194: Wrong ZLIB data header offset 0 (expected 0x194).
3633 ])
3634 done
3635 AT_CLEANUP
3636
3637 AT_SETUP([zcompressed data - bad ztrailer_ofs])
3638 AT_KEYWORDS([sack synthetic system file negative zlib])
3639 zcompressed_sack | sed 's/.*ztrailer_ofs.*/>>i64 0<<;/' > sys-file.sack
3640 for variant in be le; do
3641   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3642   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3643 ])
3644   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x194: Impossible ZLIB trailer offset 0x0.
3645 ])
3646 done
3647 AT_CLEANUP
3648
3649 # ztrailer_len must be a multiple of 24 and at least 48,
3650 # so a value of 12 is impossible.
3651 AT_SETUP([zcompressed data - invalid ztrailer_len])
3652 AT_KEYWORDS([sack synthetic system file negative zlib])
3653 zcompressed_sack | sed 's/.*ztrailer_len.*/>>i64 12<<;/' > sys-file.sack
3654 for variant in be le; do
3655   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3656   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3657 ])
3658   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x194: Invalid ZLIB trailer length 12.
3659 ])
3660 done
3661 AT_CLEANUP
3662
3663 # ztrailer_ofs + ztrailer_len must be the file size.
3664 AT_SETUP([zcompressed data - wrong ztrailer_len])
3665 AT_KEYWORDS([sack synthetic system file negative zlib])
3666 zcompressed_sack | sed 's/.*ztrailer_len.*/>>i64 72<<;/' > sys-file.sack
3667 for variant in be le; do
3668   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3669   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3670 ])
3671   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [warning: `sys-file.sav' near offset 0x1ac: End of ZLIB trailer (0x24d) is not file size (0x235).
3672 error: `sys-file.sav' near offset 0x21d: 72-byte ZLIB trailer specifies 1 data blocks (expected 2).
3673 ])
3674 done
3675 AT_CLEANUP
3676
3677 AT_SETUP([zcompressed data - wrong ztrailer_bias])
3678 AT_KEYWORDS([sack synthetic system file negative zlib])
3679 zcompressed_sack | sed 's/.*ztrailer_bias.*/>>i64 0<<;/' > sys-file.sack
3680 for variant in be le; do
3681   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3682   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3683 ])
3684   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x20d: ZLIB trailer bias (0) differs from file header bias (100.00).
3685 ])
3686 done
3687 AT_CLEANUP
3688
3689 AT_SETUP([zcompressed data - wrong ztrailer_zero])
3690 AT_KEYWORDS([sack synthetic system file negative zlib])
3691 zcompressed_sack | sed 's/.*ztrailer_zero.*/>>i64 100<<;/' > sys-file.sack
3692 for variant in be le; do
3693   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3694   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3695 ])
3696   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [warning: `sys-file.sav' near offset 0x215: ZLIB trailer "zero" field has nonzero value 100.
3697 ])
3698 done
3699 AT_CLEANUP
3700
3701 AT_SETUP([zcompressed data - wrong block_size])
3702 AT_KEYWORDS([sack synthetic system file negative zlib])
3703 zcompressed_sack | sed 's/.*block_size.*/>>0x1000<<;/' > sys-file.sack
3704 for variant in be le; do
3705   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3706   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3707 ])
3708   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [warning: `sys-file.sav' near offset 0x219: ZLIB trailer specifies unexpected 4096-byte block size.
3709 ])
3710 done
3711 AT_CLEANUP
3712
3713 AT_SETUP([zcompressed data - wrong n_blocks])
3714 AT_KEYWORDS([sack synthetic system file negative zlib])
3715 zcompressed_sack | sed 's/.*n_blocks.*/>>2<<;/' > sys-file.sack
3716 for variant in be le; do
3717   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3718   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3719 ])
3720   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: 48-byte ZLIB trailer specifies 2 data blocks (expected 1).
3721 ])
3722 done
3723 AT_CLEANUP
3724
3725 AT_SETUP([zcompressed data - wrong uncompressed_ofs])
3726 AT_KEYWORDS([sack synthetic system file negative zlib])
3727 zcompressed_sack | sed 's/.*uncompressed_ofs.*/i64 >>0x177<<;/' > sys-file.sack
3728 for variant in be le; do
3729   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3730   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3731 ])
3732   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reported uncompressed data offset 0x177, when 0x194 was expected.
3733 ])
3734 done
3735 AT_CLEANUP
3736
3737 AT_SETUP([zcompressed data - wrong compressed_ofs])
3738 AT_KEYWORDS([sack synthetic system file negative zlib])
3739 zcompressed_sack | sed 's/.*@%:@ compressed_ofs.*/i64 >>0x191<<;/' > sys-file.sack
3740 for variant in be le; do
3741   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3742   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3743 ])
3744   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reported compressed data offset 0x191, when 0x1ac was expected.
3745 ])
3746 done
3747 AT_CLEANUP
3748
3749 AT_SETUP([zcompressed data - compressed sizes don't add up])
3750 AT_KEYWORDS([sack synthetic system file negative zlib])
3751 AT_DATA([sys-file.sack], [dnl
3752 dnl File header.
3753 "$FL3"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
3754 2; dnl Layout code
3755 6; dnl Nominal case size
3756 2; dnl zlib compressed
3757 0; dnl Not weighted
3758 -1; dnl Unspecified number of cases.
3759 100.0; dnl Bias.
3760 "01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
3761 i8 0 *3;
3762
3763 dnl Numeric variables.
3764 2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
3765 2; 0; 0; 0; 0x050800 *2; s8 "NUM2";
3766
3767 dnl String variable.
3768 2; 4; 0; 0; 0x010400 *2; s8 "STR4";
3769 2; 8; 0; 0; 0x010800 *2; s8 "STR8";
3770 2; 15; 0; 0; 0x010f00 *2; s8 "STR15";
3771 2; -1; 0; 0; 0; 0; s8 "";
3772
3773 dnl Character encoding record.
3774 7; 20; 1; 12; "windows-1252";
3775
3776 dnl Dictionary termination record.
3777 999; 0;
3778
3779 dnl ZLIB data header.
3780 i64 0x194;    # zheader_ofs
3781 i64 0x1ac;    # ztrailer_ofs
3782 i64 72;       # ztrailer_len
3783
3784 dnl This is where the ZLIB data blocks would go, but we don't need any to
3785 dnl provoke this message so we omit them.
3786
3787 dnl ZLIB data trailer fixed header:
3788 i64 -100;     # ztrailer_bias
3789 i64 0;        # ztrailer_zero
3790 0x3ff000;     # block_size
3791 2;            # n_blocks
3792
3793 dnl ZLIB block descriptor 1:
3794 i64 0x194;    # uncompressed_ofs
3795 i64 0x1ac;    # compressed_ofs
3796 0x100000;     # uncompressed_size
3797 0x12345;      # compressed_size
3798
3799 dnl ZLIB block descriptor 2:
3800 i64 0x100194; # uncompressed_ofs
3801 i64 0x12421;  # compressed_ofs
3802 0x100000;     # uncompressed_size
3803 0x12345;      # compressed_size
3804 ])
3805 for variant in be le; do
3806   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3807   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3808 ])
3809   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [warning: `sys-file.sav' near offset 0x1c4: ZLIB block descriptor 0 reported block size 0x100000, when 0x3ff000 was expected.
3810 error: `sys-file.sav' near offset 0x1dc: ZLIB block descriptor 1 reported compressed data offset 0x12421, when 0x124f1 was expected.
3811 ])
3812 done
3813 AT_CLEANUP
3814
3815 AT_SETUP([zcompressed data - uncompressed_size > block_size])
3816 AT_KEYWORDS([sack synthetic system file negative zlib])
3817 zcompressed_sack | sed 's/.*uncompressed_size.*/>>0x400000<<;/' > sys-file.sack
3818 for variant in be le; do
3819   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3820   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3821 ])
3822   AT_CHECK([pspp -o pspp.csv sys-file.sps], [0], [warning: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reported block size 0x400000, when at most 0x3ff000 was expected.
3823 ])
3824 done
3825 AT_CLEANUP
3826
3827 AT_SETUP([zcompressed data - compression expands data too much])
3828 AT_KEYWORDS([sack synthetic system file negative zlib])
3829 zcompressed_sack | sed 's/.*uncompressed_size.*/>>50<<;/
3830 s/.*@%:@ compressed_size.*/>>100<<;/' > sys-file.sack
3831 for variant in be le; do
3832   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3833   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3834 ])
3835   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x21d: ZLIB block descriptor 0 reports compressed size 100 and uncompressed size 50.
3836 ])
3837 done
3838 AT_CLEANUP
3839
3840 AT_SETUP([zcompressed data - compressed sizes don't add up])
3841 AT_KEYWORDS([sack synthetic system file negative zlib])
3842 zcompressed_sack | sed 's/.*@%:@ compressed_size.*/>>88<<;/' > sys-file.sack
3843 for variant in be le; do
3844   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
3845   AT_DATA([sys-file.sps], [GET FILE='sys-file.sav'.
3846 ])
3847   AT_CHECK([pspp -o pspp.csv sys-file.sps], [1], [error: `sys-file.sav' near offset 0x235: ZLIB trailer is at offset 0x205 but 0x204 would be expected from block descriptors.
3848 ])
3849 done
3850 AT_CLEANUP
3851
3852 # CVE-2017-10791.
3853 # See also https://bugzilla.redhat.com/show_bug.cgi?id=1467004.
3854 # See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866890.
3855 # See also https://security-tracker.debian.org/tracker/CVE-2017-10791.
3856 # Found by team OWL337, using the collAFL fuzzer.
3857 AT_SETUP([integer overflows in long string missing values])
3858 AT_KEYWORDS([system file negative])
3859 cp $top_srcdir/tests/data/CVE-2017-10791.sav .
3860 AT_CHECK([pspp-convert -O csv -e ASCII CVE-2017-10791.sav -], [0], [], [dnl
3861 `CVE-2017-10791.sav' near offset 0x217: Extension record subtype 21 ends unexpectedly.
3862 ])
3863 AT_CLEANUP
3864
3865 # CVE-2017-10792.
3866 # See also https://bugzilla.redhat.com/show_bug.cgi?id=1467005.
3867 # See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=866890.
3868 # See also https://security-tracker.debian.org/tracker/CVE-2017-10792.
3869 # Reported by team OWL337, with fuzzer collAFL.
3870 AT_SETUP([null dereference skipping bad extension record 18])
3871 AT_KEYWORDS([system file negative])
3872 cp $top_srcdir/tests/data/CVE-2017-10792.sav .
3873 AT_CHECK([pspp-convert -O csv -e ASCII CVE-2017-10792.sav -], [0], [], [dnl
3874 `CVE-2017-10792.sav' near offset 0x1c0: Record type 7, subtype 18 has bad size 4 (expected 1).
3875 ])
3876 AT_CLEANUP