sys-file-reader: Accept document records with no document lines.
[pspp] / tests / data / sys-file-reader.at
index e23917884efacd75deeadef5f254c82a0f6dfbdf..be4782284c0ef8c0a87d0994088c0fd7fe00e34c 100644 (file)
@@ -584,6 +584,53 @@ num1
 done
 AT_CLEANUP
 
+AT_SETUP([empty document record])
+AT_KEYWORDS([sack synthetic system file positive])
+AT_DATA([sys-file.sack], [dnl
+dnl File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; dnl Layout code
+1; dnl Nominal case size
+0; dnl Not compressed
+0; dnl Not weighted 
+1; dnl 1 case.
+100.0; dnl Bias.
+"01 Jan 11"; "20:53:52"; s64 "PSPP synthetic test file";
+i8 0 *3;
+
+dnl Numeric variable, no label or missing values.
+2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
+
+dnl Machine integer info record.
+7; 3; 4; 8; 1; 2; 3; -1; 1; 1; ENDIAN; 1252;
+
+dnl Document record.
+6; 0;
+
+dnl Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+dnl Dictionary termination record.
+999; 0;
+
+dnl Data.
+1.0;
+])
+for variant in be le; do
+  AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
+  AT_DATA([sys-file.sps], [dnl
+GET FILE='sys-file.sav'.
+LIST.
+])
+  AT_CHECK([pspp -o pspp.csv sys-file.sps])
+  AT_CHECK([cat pspp.csv], [0], [dnl
+Table: Data List
+num1
+1
+])
+done
+AT_CLEANUP
+
 AT_SETUP([multiple response sets])
 AT_KEYWORDS([sack synthetic system file positive])
 AT_DATA([sys-file.sack], [dnl
@@ -2213,36 +2260,6 @@ done
 AT_CLEANUP
 
 
-AT_SETUP([empty document record])
-AT_KEYWORDS([sack synthetic system file negative])
-AT_DATA([sys-file.sack], [dnl
-dnl File header.
-"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
-2; 2; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
-
-dnl Numeric variable, no label or missing values.
-2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
-
-dnl Empty document record.
-6; >>0<<;
-
-dnl Dictionary termination record.
-999; 0;
-
-dnl Data.
-1.0;
-])
-for variant in be le; do
-  AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
-  AT_DATA([sys-file.sps], [dnl
-GET FILE='sys-file.sav'.
-])
-  AT_CHECK([pspp -O format=csv sys-file.sps], [1], [dnl
-error: `sys-file.sav' near offset 0xd4: Number of document lines (0) must be greater than 0 and less than 26843545.
-])
-done
-AT_CLEANUP
-
 AT_SETUP([extension record too large])
 AT_KEYWORDS([sack synthetic system file negative])
 AT_DATA([sys-file.sack], [dnl
@@ -3896,9 +3913,9 @@ AT_CLEANUP
 # See also https://security-tracker.debian.org/tracker/CVE-2017-10791.
 # Found by team OWL337, using the collAFL fuzzer.
 AT_SETUP([integer overflows in long string missing values])
+AT_KEYWORDS([system file negative])
 cp $top_srcdir/tests/data/CVE-2017-10791.sav .
-AT_CHECK([pspp-convert -O csv CVE-2017-10791.sav -], [0], [], [dnl
-`CVE-2017-10791.sav': This system file does not indicate its own character encoding.  Using default encoding ANSI_X3.4-1968.  For best results, specify an encoding explicitly.  Use SYSFILE INFO with ENCODING="DETECT" to analyze the possible encodings.
+AT_CHECK([pspp-convert -O csv -e ASCII CVE-2017-10791.sav -], [0], [], [dnl
 `CVE-2017-10791.sav' near offset 0x217: Extension record subtype 21 ends unexpectedly.
 ])
 AT_CLEANUP
@@ -3909,9 +3926,9 @@ AT_CLEANUP
 # See also https://security-tracker.debian.org/tracker/CVE-2017-10792.
 # Reported by team OWL337, with fuzzer collAFL.
 AT_SETUP([null dereference skipping bad extension record 18])
+AT_KEYWORDS([system file negative])
 cp $top_srcdir/tests/data/CVE-2017-10792.sav .
-AT_CHECK([pspp-convert -O csv CVE-2017-10792.sav -], [0], [], [dnl
+AT_CHECK([pspp-convert -O csv -e ASCII CVE-2017-10792.sav -], [0], [], [dnl
 `CVE-2017-10792.sav' near offset 0x1c0: Record type 7, subtype 18 has bad size 4 (expected 1).
-`CVE-2017-10792.sav': This system file does not indicate its own character encoding.  Using default encoding ANSI_X3.4-1968.  For best results, specify an encoding explicitly.  Use SYSFILE INFO with ENCODING="DETECT" to analyze the possible encodings.
 ])
 AT_CLEANUP