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