Commit b72a38bf5ff3adf9bf02046b1106e1b524afa922

Authored by Jay Berkenbilt
1 parent d0e99f19

Reorganize some test cases

Too many test cases were "miscellaneous".
qpdf/qtest/qpdf.test
@@ -239,8 +239,8 @@ foreach my $d (@bug_tests) @@ -239,8 +239,8 @@ foreach my $d (@bug_tests)
239 } 239 }
240 show_ntests(); 240 show_ntests();
241 # ---------- 241 # ----------
242 -$td->notify("--- Miscellaneous Tests ---");  
243 -$n_tests += 99; 242 +$td->notify("--- Library version ---");
  243 +$n_tests += 2;
244 244
245 $td->runtest("qpdf version", 245 $td->runtest("qpdf version",
246 {$td->COMMAND => "qpdf --version"}, 246 {$td->COMMAND => "qpdf --version"},
@@ -252,6 +252,11 @@ $td->runtest("C API: qpdf version", @@ -252,6 +252,11 @@ $td->runtest("C API: qpdf version",
252 $td->EXIT_STATUS => 0}, 252 $td->EXIT_STATUS => 0},
253 $td->NORMALIZE_NEWLINES); 253 $td->NORMALIZE_NEWLINES);
254 254
  255 +show_ntests();
  256 +# ----------
  257 +$td->notify("--- Linearize pass1 file ---");
  258 +$n_tests += 3;
  259 +
255 $td->runtest("linearize pass 1 file", 260 $td->runtest("linearize pass 1 file",
256 {$td->COMMAND => "qpdf --linearize --static-id" . 261 {$td->COMMAND => "qpdf --linearize --static-id" .
257 " --linearize-pass1=b.pdf minimal.pdf a.pdf"}, 262 " --linearize-pass1=b.pdf minimal.pdf a.pdf"},
@@ -263,6 +268,11 @@ $td->runtest("check pass1 file", @@ -263,6 +268,11 @@ $td->runtest("check pass1 file",
263 {$td->FILE => "b.pdf"}, 268 {$td->FILE => "b.pdf"},
264 {$td->FILE => "minimal-linearize-pass1.pdf"}); 269 {$td->FILE => "minimal-linearize-pass1.pdf"});
265 270
  271 +show_ntests();
  272 +# ----------
  273 +$td->notify("--- Tokenizer ---");
  274 +$n_tests += 4;
  275 +
266 $td->runtest("tokenizer with no ignorable", 276 $td->runtest("tokenizer with no ignorable",
267 {$td->COMMAND => "test_tokenizer -no-ignorable tokens.pdf"}, 277 {$td->COMMAND => "test_tokenizer -no-ignorable tokens.pdf"},
268 {$td->FILE => "tokens-no-ignorable.out", $td->EXIT_STATUS => 0}, 278 {$td->FILE => "tokens-no-ignorable.out", $td->EXIT_STATUS => 0},
@@ -278,19 +288,42 @@ $td->runtest("tokenizer with max_len", @@ -278,19 +288,42 @@ $td->runtest("tokenizer with max_len",
278 {$td->FILE => "tokens-maxlen.out", $td->EXIT_STATUS => 0}, 288 {$td->FILE => "tokens-maxlen.out", $td->EXIT_STATUS => 0},
279 $td->NORMALIZE_NEWLINES); 289 $td->NORMALIZE_NEWLINES);
280 290
  291 +$td->runtest("ignore bad token",
  292 + {$td->COMMAND =>
  293 + "qpdf --show-xref bad-token-startxref.pdf"},
  294 + {$td->FILE => "bad-token-startxref.out",
  295 + $td->EXIT_STATUS => 0},
  296 + $td->NORMALIZE_NEWLINES);
  297 +
  298 +show_ntests();
  299 +# ----------
  300 +$td->notify("--- Numbers and strings ---");
  301 +$n_tests += 3;
  302 +
281 foreach (my $i = 1; $i <= 3; ++$i) 303 foreach (my $i = 1; $i <= 3; ++$i)
282 { 304 {
283 - $td->runtest("misc tests",  
284 - {$td->COMMAND => "test_driver 5 misc-$i.pdf"},  
285 - {$td->FILE => "misc-$i.out", $td->EXIT_STATUS => 0}, 305 + $td->runtest("numbers and strings",
  306 + {$td->COMMAND => "test_driver 5 numeric-and-string-$i.pdf"},
  307 + {$td->FILE => "numeric-and-string-$i.out",
  308 + $td->EXIT_STATUS => 0},
286 $td->NORMALIZE_NEWLINES); 309 $td->NORMALIZE_NEWLINES);
287 } 310 }
288 311
  312 +show_ntests();
  313 +# ----------
  314 +$td->notify("--- Stream data ---");
  315 +$n_tests += 1;
  316 +
289 $td->runtest("get stream data", 317 $td->runtest("get stream data",
290 {$td->COMMAND => "test_driver 11 stream-data.pdf"}, 318 {$td->COMMAND => "test_driver 11 stream-data.pdf"},
291 {$td->FILE => "test11.out", $td->EXIT_STATUS => 0}, 319 {$td->FILE => "test11.out", $td->EXIT_STATUS => 0},
292 $td->NORMALIZE_NEWLINES); 320 $td->NORMALIZE_NEWLINES);
293 321
  322 +show_ntests();
  323 +# ----------
  324 +$td->notify("--- Decode parameter problems ---");
  325 +$n_tests += 4;
  326 +
294 # Make sure we ignore decode parameters that we don't understand 327 # Make sure we ignore decode parameters that we don't understand
295 $td->runtest("unknown decode parameters", 328 $td->runtest("unknown decode parameters",
296 {$td->COMMAND => "qpdf --check fax-decode-parms.pdf"}, 329 {$td->COMMAND => "qpdf --check fax-decode-parms.pdf"},
@@ -298,6 +331,25 @@ $td-&gt;runtest(&quot;unknown decode parameters&quot;, @@ -298,6 +331,25 @@ $td-&gt;runtest(&quot;unknown decode parameters&quot;,
298 $td->EXIT_STATUS => 0}, 331 $td->EXIT_STATUS => 0},
299 $td->NORMALIZE_NEWLINES); 332 $td->NORMALIZE_NEWLINES);
300 333
  334 +$td->runtest("ignore broken decode parms with no filters",
  335 + {$td->COMMAND => "qpdf --check broken-decode-parms-no-filter.pdf"},
  336 + {$td->FILE => "broken-decode-parms-no-filter.out",
  337 + $td->EXIT_STATUS => 0},
  338 + $td->NORMALIZE_NEWLINES);
  339 +
  340 +$td->runtest("stream with indirect decode parms",
  341 + {$td->COMMAND =>
  342 + "qpdf --static-id indirect-decode-parms.pdf a.pdf"},
  343 + {$td->STRING => "", $td->EXIT_STATUS => 0});
  344 +$td->runtest("check file",
  345 + {$td->FILE => "a.pdf"},
  346 + {$td->FILE => "indirect-decode-parms-out.pdf"});
  347 +
  348 +show_ntests();
  349 +# ----------
  350 +$td->notify("--- Cross reference streams ---");
  351 +$n_tests += 3;
  352 +
301 # Handle xref stream with more entries than reported (bug 2872265) 353 # Handle xref stream with more entries than reported (bug 2872265)
302 $td->runtest("xref with short size", 354 $td->runtest("xref with short size",
303 {$td->COMMAND => "qpdf --show-xref xref-with-short-size.pdf"}, 355 {$td->COMMAND => "qpdf --show-xref xref-with-short-size.pdf"},
@@ -315,6 +367,11 @@ $td-&gt;runtest(&quot;show new xref stream&quot;, @@ -315,6 +367,11 @@ $td-&gt;runtest(&quot;show new xref stream&quot;,
315 $td->EXIT_STATUS => 0}, 367 $td->EXIT_STATUS => 0},
316 $td->NORMALIZE_NEWLINES); 368 $td->NORMALIZE_NEWLINES);
317 369
  370 +show_ntests();
  371 +# ----------
  372 +$td->notify("--- Multiple levels of indirection ---");
  373 +$n_tests += 2;
  374 +
318 # Handle file with object stream containing an unreferenced object 375 # Handle file with object stream containing an unreferenced object
319 # that in turn contains an indirect scalar (bug 2974522). 376 # that in turn contains an indirect scalar (bug 2974522).
320 $td->runtest("unreferenced indirect scalar", 377 $td->runtest("unreferenced indirect scalar",
@@ -328,6 +385,11 @@ $td-&gt;runtest(&quot;check output&quot;, @@ -328,6 +385,11 @@ $td-&gt;runtest(&quot;check output&quot;,
328 {$td->FILE => "a.qdf"}, 385 {$td->FILE => "a.qdf"},
329 {$td->FILE => "unreferenced-indirect-scalar.out"}); 386 {$td->FILE => "unreferenced-indirect-scalar.out"});
330 387
  388 +show_ntests();
  389 +# ----------
  390 +$td->notify("--- ID and Encryption Parameter Issues ---");
  391 +$n_tests += 12;
  392 +
331 # Encrypt files whose /ID strings are other than 32 bytes long (bug 393 # Encrypt files whose /ID strings are other than 32 bytes long (bug
332 # 2991412). Also linearize these files, which was reported in a 394 # 2991412). Also linearize these files, which was reported in a
333 # separate bug by email. 395 # separate bug by email.
@@ -364,13 +426,28 @@ foreach my $file (qw(short-id long-id)) @@ -364,13 +426,28 @@ foreach my $file (qw(short-id long-id))
364 $td->NORMALIZE_NEWLINES); 426 $td->NORMALIZE_NEWLINES);
365 } 427 }
366 428
367 -# Handle file with invalid xref table and object 0 as a regular object  
368 -# (bug 3159950).  
369 -$td->runtest("check obj0.pdf",  
370 - {$td->COMMAND => "qpdf --check obj0.pdf"},  
371 - {$td->FILE => "obj0-check.out",  
372 - $td->EXIT_STATUS => 3},  
373 - $td->NORMALIZE_NEWLINES); 429 +# A user provided a file that was missing /ID in its trailer even
  430 +# though it is encrypted and also has a space instead of a newline
  431 +# after its xref keyword. This file has those same properties.
  432 +$td->runtest("check broken file",
  433 + {$td->COMMAND => "qpdf --check invalid-id-xref.pdf"},
  434 + {$td->FILE => "invalid-id-xref.out", $td->EXIT_STATUS => 3},
  435 + $td->NORMALIZE_NEWLINES);
  436 +
  437 +# A file was emailed privately with issue 96. short-O-U.pdf was
  438 +# created by copying encryption parameters from that file. It exhibits
  439 +# the same behavior as the original file.
  440 +$td->runtest("short /O or /U",
  441 + {$td->COMMAND =>
  442 + "qpdf --password=19723102477 --check short-O-U.pdf"},
  443 + {$td->FILE => "short-O-U.out",
  444 + $td->EXIT_STATUS => 0},
  445 + $td->NORMALIZE_NEWLINES);
  446 +
  447 +show_ntests();
  448 +# ----------
  449 +$td->notify("--- Min/force version ---");
  450 +$n_tests += 7;
374 451
375 # Min/Force version 452 # Min/Force version
376 $td->runtest("set min version", 453 $td->runtest("set min version",
@@ -410,6 +487,11 @@ $td-&gt;runtest(&quot;C check version 2&quot;, @@ -410,6 +487,11 @@ $td-&gt;runtest(&quot;C check version 2&quot;,
410 $td->EXIT_STATUS => 0}, 487 $td->EXIT_STATUS => 0},
411 $td->NORMALIZE_NEWLINES); 488 $td->NORMALIZE_NEWLINES);
412 489
  490 +show_ntests();
  491 +# ----------
  492 +$td->notify("--- Filter abbreviations ---");
  493 +$n_tests += 2;
  494 +
413 # Stream filter abbreviations from table H.1 495 # Stream filter abbreviations from table H.1
414 $td->runtest("stream filter abbreviations", 496 $td->runtest("stream filter abbreviations",
415 {$td->COMMAND => "qpdf --static-id filter-abbreviation.pdf a.pdf"}, 497 {$td->COMMAND => "qpdf --static-id filter-abbreviation.pdf a.pdf"},
@@ -420,12 +502,27 @@ $td-&gt;runtest(&quot;check output&quot;, @@ -420,12 +502,27 @@ $td-&gt;runtest(&quot;check output&quot;,
420 {$td->FILE => "a.pdf"}, 502 {$td->FILE => "a.pdf"},
421 {$td->FILE => "filter-abbreviation.out"}); 503 {$td->FILE => "filter-abbreviation.out"});
422 504
  505 +show_ntests();
  506 +# ----------
  507 +$td->notify("--- Invalid objects ---");
  508 +$n_tests += 2;
  509 +
423 $td->runtest("empty object", 510 $td->runtest("empty object",
424 {$td->COMMAND => "qpdf -show-object=7,0 empty-object.pdf"}, 511 {$td->COMMAND => "qpdf -show-object=7,0 empty-object.pdf"},
425 {$td->FILE => "empty-object.out", 512 {$td->FILE => "empty-object.out",
426 $td->EXIT_STATUS => 3}, 513 $td->EXIT_STATUS => 3},
427 $td->NORMALIZE_NEWLINES); 514 $td->NORMALIZE_NEWLINES);
428 515
  516 +$td->runtest("object with zero offset",
  517 + {$td->COMMAND => "qpdf --check zero-offset.pdf"},
  518 + {$td->FILE => "zero-offset.out", $td->EXIT_STATUS => 3},
  519 + $td->NORMALIZE_NEWLINES);
  520 +
  521 +show_ntests();
  522 +# ----------
  523 +$td->notify("--- Error/output rediction ---");
  524 +$n_tests += 2;
  525 +
429 $td->runtest("error/output redirection to null", 526 $td->runtest("error/output redirection to null",
430 {$td->COMMAND => "test_driver 12 linearized-and-warnings.pdf"}, 527 {$td->COMMAND => "test_driver 12 linearized-and-warnings.pdf"},
431 {$td->FILE => "linearized-and-warnings-1.out", 528 {$td->FILE => "linearized-and-warnings-1.out",
@@ -438,6 +535,11 @@ $td-&gt;runtest(&quot;error/output redirection to strings&quot;, @@ -438,6 +535,11 @@ $td-&gt;runtest(&quot;error/output redirection to strings&quot;,
438 $td->EXIT_STATUS => 0}, 535 $td->EXIT_STATUS => 0},
439 $td->NORMALIZE_NEWLINES); 536 $td->NORMALIZE_NEWLINES);
440 537
  538 +show_ntests();
  539 +# ----------
  540 +$td->notify("--- Line terminators for stream ---");
  541 +$n_tests += 2;
  542 +
441 $td->runtest("odd terminators for stream keyword", 543 $td->runtest("odd terminators for stream keyword",
442 {$td->COMMAND => 544 {$td->COMMAND =>
443 "qpdf --qdf --static-id" . 545 "qpdf --qdf --static-id" .
@@ -449,6 +551,11 @@ $td-&gt;runtest(&quot;check output&quot;, @@ -449,6 +551,11 @@ $td-&gt;runtest(&quot;check output&quot;,
449 {$td->FILE => "a.qdf"}, 551 {$td->FILE => "a.qdf"},
450 {$td->FILE => "stream-line-enders.qdf"}); 552 {$td->FILE => "stream-line-enders.qdf"});
451 553
  554 +show_ntests();
  555 +# ----------
  556 +$td->notify("--- Swap and replace ---");
  557 +$n_tests += 3;
  558 +
452 $td->runtest("swap and replace", 559 $td->runtest("swap and replace",
453 {$td->COMMAND => "test_driver 14 test14-in.pdf"}, 560 {$td->COMMAND => "test_driver 14 test14-in.pdf"},
454 {$td->FILE => "test14.out", 561 {$td->FILE => "test14.out",
@@ -457,12 +564,20 @@ $td-&gt;runtest(&quot;swap and replace&quot;, @@ -457,12 +564,20 @@ $td-&gt;runtest(&quot;swap and replace&quot;,
457 $td->runtest("check output", 564 $td->runtest("check output",
458 {$td->FILE => "a.pdf"}, 565 {$td->FILE => "a.pdf"},
459 {$td->FILE => "test14-out.pdf"}); 566 {$td->FILE => "test14-out.pdf"});
460 -# Test 14 also exercises writing to memory without static ID. 567 +
  568 +# Most of the test suite uses static or deterministic ID. This test
  569 +# case exercises regular ID generation. Test 14 also exercises writing
  570 +# to memory without static ID.
461 $td->runtest("check non-static ID version", 571 $td->runtest("check non-static ID version",
462 {$td->COMMAND => "sh ./diff-ignore-ID-version a.pdf b.pdf"}, 572 {$td->COMMAND => "sh ./diff-ignore-ID-version a.pdf b.pdf"},
463 {$td->STRING => "okay\n", $td->EXIT_STATUS => 0}, 573 {$td->STRING => "okay\n", $td->EXIT_STATUS => 0},
464 $td->NORMALIZE_NEWLINES); 574 $td->NORMALIZE_NEWLINES);
465 575
  576 +show_ntests();
  577 +# ----------
  578 +$td->notify("--- Key functions, C API ---");
  579 +$n_tests += 4;
  580 +
466 $td->runtest("C API info key functions", 581 $td->runtest("C API info key functions",
467 {$td->COMMAND => "qpdf-ctest 16 minimal.pdf '' a.pdf"}, 582 {$td->COMMAND => "qpdf-ctest 16 minimal.pdf '' a.pdf"},
468 {$td->FILE => "c-info1.out", 583 {$td->FILE => "c-info1.out",
@@ -483,6 +598,11 @@ $td-&gt;runtest(&quot;check output&quot;, @@ -483,6 +598,11 @@ $td-&gt;runtest(&quot;check output&quot;,
483 {$td->FILE => "c-info-out.pdf"}); 598 {$td->FILE => "c-info-out.pdf"});
484 unlink "a.pdf" or die; 599 unlink "a.pdf" or die;
485 600
  601 +show_ntests();
  602 +# ----------
  603 +$td->notify("--- Object copying ---");
  604 +$n_tests += 7;
  605 +
486 $td->runtest("shallow copy an array", 606 $td->runtest("shallow copy an array",
487 {$td->COMMAND => "test_driver 20 shallow_array.pdf"}, 607 {$td->COMMAND => "test_driver 20 shallow_array.pdf"},
488 {$td->STRING => "test 20 done\n", $td->EXIT_STATUS => 0}, 608 {$td->STRING => "test 20 done\n", $td->EXIT_STATUS => 0},
@@ -510,6 +630,12 @@ $td-&gt;runtest(&quot;detect foreign object in write&quot;, @@ -510,6 +630,12 @@ $td-&gt;runtest(&quot;detect foreign object in write&quot;,
510 " copy-foreign-objects-in.pdf minimal.pdf"}, 630 " copy-foreign-objects-in.pdf minimal.pdf"},
511 {$td->FILE => "foreign-in-write.out", $td->EXIT_STATUS => 0}, 631 {$td->FILE => "foreign-in-write.out", $td->EXIT_STATUS => 0},
512 $td->NORMALIZE_NEWLINES); 632 $td->NORMALIZE_NEWLINES);
  633 +
  634 +show_ntests();
  635 +# ----------
  636 +$td->notify("--- Parsing ---");
  637 +$n_tests += 17;
  638 +
513 $td->runtest("parse objects from string", 639 $td->runtest("parse objects from string",
514 {$td->COMMAND => "test_driver 31 minimal.pdf"}, # file not used 640 {$td->COMMAND => "test_driver 31 minimal.pdf"}, # file not used
515 {$td->FILE => "parse-object.out", $td->EXIT_STATUS => 0}, 641 {$td->FILE => "parse-object.out", $td->EXIT_STATUS => 0},
@@ -538,17 +664,7 @@ $td-&gt;runtest(&quot;check output&quot;, @@ -538,17 +664,7 @@ $td-&gt;runtest(&quot;check output&quot;,
538 $td->runtest("check output", 664 $td->runtest("check output",
539 {$td->FILE => "d.pdf"}, 665 {$td->FILE => "d.pdf"},
540 {$td->FILE => "extra-header-lin-newline.pdf"}); 666 {$td->FILE => "extra-header-lin-newline.pdf"});
541 -$td->runtest("output to custom pipeline",  
542 - {$td->COMMAND => "test_driver 33 minimal.pdf"},  
543 - {$td->STRING => "test 33 done\n", $td->EXIT_STATUS => 0},  
544 - $td->NORMALIZE_NEWLINES);  
545 -$td->runtest("check output",  
546 - {$td->FILE => "a.pdf"},  
547 - {$td->FILE => "custom-pipeline.pdf"});  
548 -$td->runtest("object with zero offset",  
549 - {$td->COMMAND => "qpdf --check zero-offset.pdf"},  
550 - {$td->FILE => "zero-offset.out", $td->EXIT_STATUS => 3},  
551 - $td->NORMALIZE_NEWLINES); 667 +
552 # leading-junk also has a space instead of a newline after xref 668 # leading-junk also has a space instead of a newline after xref
553 $td->runtest("check file with leading junk", 669 $td->runtest("check file with leading junk",
554 {$td->COMMAND => "qpdf --check leading-junk.pdf"}, 670 {$td->COMMAND => "qpdf --check leading-junk.pdf"},
@@ -575,6 +691,46 @@ $td-&gt;runtest(&quot;content stream errors&quot;, @@ -575,6 +691,46 @@ $td-&gt;runtest(&quot;content stream errors&quot;,
575 $td->EXIT_STATUS => 2}, 691 $td->EXIT_STATUS => 2},
576 $td->NORMALIZE_NEWLINES); 692 $td->NORMALIZE_NEWLINES);
577 693
  694 +$td->runtest("ensure arguments to R are direct",
  695 + {$td->COMMAND => "qpdf --check indirect-r-arg.pdf"},
  696 + {$td->FILE => "indirect-r-arg.out", $td->EXIT_STATUS => 3},
  697 + $td->NORMALIZE_NEWLINES);
  698 +$td->runtest("no trailing space in xref table",
  699 + {$td->COMMAND => "qpdf --check no-space-in-xref.pdf"},
  700 + {$td->FILE => "no-space-in-xref.out", $td->EXIT_STATUS => 0},
  701 + $td->NORMALIZE_NEWLINES);
  702 +
  703 +# An array is split across multiple content streams starting object
  704 +# 42. This was reported in github issue 73. The file is modified from
  705 +# that example.
  706 +$td->runtest("parse split content stream",
  707 + {$td->COMMAND => "qpdf --check split-content-stream.pdf"},
  708 + {$td->FILE => "split-content-stream.out", $td->EXIT_STATUS => 0},
  709 + $td->NORMALIZE_NEWLINES);
  710 +$td->runtest("split content stream errors",
  711 + {$td->COMMAND => "qpdf --check split-content-stream-errors.pdf"},
  712 + {$td->FILE => "split-content-stream-errors.out",
  713 + $td->EXIT_STATUS => 3},
  714 + $td->NORMALIZE_NEWLINES);
  715 +
  716 +show_ntests();
  717 +# ----------
  718 +$td->notify("--- Custom Pipeline ---");
  719 +$n_tests += 2;
  720 +
  721 +$td->runtest("output to custom pipeline",
  722 + {$td->COMMAND => "test_driver 33 minimal.pdf"},
  723 + {$td->STRING => "test 33 done\n", $td->EXIT_STATUS => 0},
  724 + $td->NORMALIZE_NEWLINES);
  725 +$td->runtest("check output",
  726 + {$td->FILE => "a.pdf"},
  727 + {$td->FILE => "custom-pipeline.pdf"});
  728 +
  729 +show_ntests();
  730 +# ----------
  731 +$td->notify("--- Object stream cases ---");
  732 +$n_tests += 3;
  733 +
578 # The file override-compressed-object.pdf contains an object stream 734 # The file override-compressed-object.pdf contains an object stream
579 # with four strings in it. The file is then appended. The appended 735 # with four strings in it. The file is then appended. The appended
580 # section overrides one of the four strings with a string in another 736 # section overrides one of the four strings with a string in another
@@ -595,24 +751,11 @@ $td-&gt;runtest(&quot;check file&quot;, @@ -595,24 +751,11 @@ $td-&gt;runtest(&quot;check file&quot;,
595 {$td->FILE => "a.pdf"}, 751 {$td->FILE => "a.pdf"},
596 {$td->FILE => "gen1.qdf"}); 752 {$td->FILE => "gen1.qdf"});
597 753
598 -# A user provided a file that was missing /ID in its trailer even  
599 -# though it is encrypted and also has a space instead of a newline  
600 -# after its xref keyword. This file has those same properties.  
601 -$td->runtest("check broken file",  
602 - {$td->COMMAND => "qpdf --check invalid-id-xref.pdf"},  
603 - {$td->FILE => "invalid-id-xref.out", $td->EXIT_STATUS => 3},  
604 - $td->NORMALIZE_NEWLINES); 754 +show_ntests();
  755 +# ----------
  756 +$td->notify("--- Bound checks ---");
  757 +$n_tests += 3;
605 758
606 -$td->runtest("show number of pages",  
607 - {$td->COMMAND =>  
608 - "qpdf --show-npages 20-pages.pdf --password=user"},  
609 - {$td->STRING => "20\n", $td->EXIT_STATUS => 0},  
610 - $td->NORMALIZE_NEWLINES);  
611 -$td->runtest("ignore broken decode parms with no filters",  
612 - {$td->COMMAND => "qpdf --check broken-decode-parms-no-filter.pdf"},  
613 - {$td->FILE => "broken-decode-parms-no-filter.out",  
614 - $td->EXIT_STATUS => 0},  
615 - $td->NORMALIZE_NEWLINES);  
616 $td->runtest("bounds check linearization data 1", 759 $td->runtest("bounds check linearization data 1",
617 {$td->COMMAND => "qpdf --check linearization-bounds-1.pdf"}, 760 {$td->COMMAND => "qpdf --check linearization-bounds-1.pdf"},
618 {$td->FILE => "linearization-bounds-1.out", 761 {$td->FILE => "linearization-bounds-1.out",
@@ -631,13 +774,10 @@ $td-&gt;runtest(&quot;sanity check array size&quot;, @@ -631,13 +774,10 @@ $td-&gt;runtest(&quot;sanity check array size&quot;,
631 $td->EXIT_STATUS => 2}, 774 $td->EXIT_STATUS => 2},
632 $td->NORMALIZE_NEWLINES); 775 $td->NORMALIZE_NEWLINES);
633 776
634 -$td->runtest("stream with indirect decode parms",  
635 - {$td->COMMAND =>  
636 - "qpdf --static-id indirect-decode-parms.pdf a.pdf"},  
637 - {$td->STRING => "", $td->EXIT_STATUS => 0});  
638 -$td->runtest("check file",  
639 - {$td->FILE => "a.pdf"},  
640 - {$td->FILE => "indirect-decode-parms-out.pdf"}); 777 +show_ntests();
  778 +# ----------
  779 +$td->notify("--- Page errors ---");
  780 +$n_tests += 3;
641 781
642 $td->runtest("handle page no with contents", 782 $td->runtest("handle page no with contents",
643 {$td->COMMAND => "qpdf --show-pages page-no-content.pdf"}, 783 {$td->COMMAND => "qpdf --show-pages page-no-content.pdf"},
@@ -647,31 +787,23 @@ $td-&gt;runtest(&quot;no type key for page nodes&quot;, @@ -647,31 +787,23 @@ $td-&gt;runtest(&quot;no type key for page nodes&quot;,
647 {$td->COMMAND => "qpdf --check no-pages-types.pdf"}, 787 {$td->COMMAND => "qpdf --check no-pages-types.pdf"},
648 {$td->FILE => "no-pages-types.out", $td->EXIT_STATUS => 0}, 788 {$td->FILE => "no-pages-types.out", $td->EXIT_STATUS => 0},
649 $td->NORMALIZE_NEWLINES); 789 $td->NORMALIZE_NEWLINES);
650 -$td->runtest("ensure arguments to R are direct",  
651 - {$td->COMMAND => "qpdf --check indirect-r-arg.pdf"},  
652 - {$td->FILE => "indirect-r-arg.out", $td->EXIT_STATUS => 3},  
653 - $td->NORMALIZE_NEWLINES);  
654 $td->runtest("detect loops in pages structure", 790 $td->runtest("detect loops in pages structure",
655 {$td->COMMAND => "qpdf --check pages-loop.pdf"}, 791 {$td->COMMAND => "qpdf --check pages-loop.pdf"},
656 {$td->FILE => "pages-loop.out", $td->EXIT_STATUS => 2}, 792 {$td->FILE => "pages-loop.out", $td->EXIT_STATUS => 2},
657 $td->NORMALIZE_NEWLINES); 793 $td->NORMALIZE_NEWLINES);
658 -$td->runtest("no trailing space in xref table",  
659 - {$td->COMMAND => "qpdf --check no-space-in-xref.pdf"},  
660 - {$td->FILE => "no-space-in-xref.out", $td->EXIT_STATUS => 0},  
661 - $td->NORMALIZE_NEWLINES);  
662 794
663 -# An array is split across multiple content streams starting object  
664 -# 42. This was reported in github issue 73. The file is modified from  
665 -# that example.  
666 -$td->runtest("parse split content stream",  
667 - {$td->COMMAND => "qpdf --check split-content-stream.pdf"},  
668 - {$td->FILE => "split-content-stream.out", $td->EXIT_STATUS => 0},  
669 - $td->NORMALIZE_NEWLINES);  
670 -$td->runtest("split content stream errors",  
671 - {$td->COMMAND => "qpdf --check split-content-stream-errors.pdf"},  
672 - {$td->FILE => "split-content-stream-errors.out",  
673 - $td->EXIT_STATUS => 3},  
674 - $td->NORMALIZE_NEWLINES); 795 +show_ntests();
  796 +# ----------
  797 +$td->notify("--- Xref ---");
  798 +$n_tests += 5;
  799 +
  800 +# Handle file with invalid xref table and object 0 as a regular object
  801 +# (bug 3159950).
  802 +$td->runtest("check obj0.pdf",
  803 + {$td->COMMAND => "qpdf --check obj0.pdf"},
  804 + {$td->FILE => "obj0-check.out",
  805 + $td->EXIT_STATUS => 3},
  806 + $td->NORMALIZE_NEWLINES);
675 807
676 # Demonstrate show-xref after check and not after check to illustrate 808 # Demonstrate show-xref after check and not after check to illustrate
677 # that it can dump the real xref or the recovered xref. 809 # that it can dump the real xref or the recovered xref.
@@ -692,11 +824,6 @@ $td-&gt;runtest(&quot;dump corrected bad xref&quot;, @@ -692,11 +824,6 @@ $td-&gt;runtest(&quot;dump corrected bad xref&quot;,
692 $td->NORMALIZE_NEWLINES); 824 $td->NORMALIZE_NEWLINES);
693 unlink "args"; 825 unlink "args";
694 826
695 -$td->runtest("don't overwrite self",  
696 - {$td->COMMAND => "(echo a.pdf; echo a.pdf) | qpdf \@-"},  
697 - {$td->REGEXP => "input file and output file are the same.*",  
698 - $td->EXIT_STATUS => 2});  
699 -  
700 $td->runtest("combine show and --pages", 827 $td->runtest("combine show and --pages",
701 {$td->COMMAND => 828 {$td->COMMAND =>
702 "qpdf --empty --pages minimal.pdf -- --show-pages"}, 829 "qpdf --empty --pages minimal.pdf -- --show-pages"},
@@ -704,35 +831,21 @@ $td-&gt;runtest(&quot;combine show and --pages&quot;, @@ -704,35 +831,21 @@ $td-&gt;runtest(&quot;combine show and --pages&quot;,
704 $td->EXIT_STATUS => 0}, 831 $td->EXIT_STATUS => 0},
705 $td->NORMALIZE_NEWLINES); 832 $td->NORMALIZE_NEWLINES);
706 833
707 -$td->runtest("ignore bad token",  
708 - {$td->COMMAND =>  
709 - "qpdf --show-xref bad-token-startxref.pdf"},  
710 - {$td->FILE => "bad-token-startxref.out",  
711 - $td->EXIT_STATUS => 0},  
712 - $td->NORMALIZE_NEWLINES);  
713 -  
714 -$td->runtest("recoverable xref errors", 834 +$td->runtest("show number of pages",
715 {$td->COMMAND => 835 {$td->COMMAND =>
716 - "qpdf --check --show-xref xref-errors.pdf"},  
717 - {$td->FILE => "xref-errors.out",  
718 - $td->EXIT_STATUS => 3}, 836 + "qpdf --show-npages 20-pages.pdf --password=user"},
  837 + {$td->STRING => "20\n", $td->EXIT_STATUS => 0},
719 $td->NORMALIZE_NEWLINES); 838 $td->NORMALIZE_NEWLINES);
720 839
721 -# A file was emailed privately with issue 96. short-O-U.pdf was  
722 -# created by copying encryption parameters from that file. It exhibits  
723 -# the same behavior as the original file.  
724 -$td->runtest("short /O or /U",  
725 - {$td->COMMAND =>  
726 - "qpdf --password=19723102477 --check short-O-U.pdf"},  
727 - {$td->FILE => "short-O-U.out",  
728 - $td->EXIT_STATUS => 0},  
729 - $td->NORMALIZE_NEWLINES); 840 +show_ntests();
  841 +# ----------
  842 +$td->notify("--- Overwrite self ---");
  843 +$n_tests += 1;
730 844
731 -$td->runtest("stream with tiff predictor",  
732 - {$td->COMMAND => "qpdf --check tiff-predictor.pdf"},  
733 - {$td->FILE => "tiff-predictor.out",  
734 - $td->EXIT_STATUS => 0},  
735 - $td->NORMALIZE_NEWLINES); 845 +$td->runtest("don't overwrite self",
  846 + {$td->COMMAND => "(echo a.pdf; echo a.pdf) | qpdf \@-"},
  847 + {$td->REGEXP => "input file and output file are the same.*",
  848 + $td->EXIT_STATUS => 2});
736 849
737 show_ntests(); 850 show_ntests();
738 # ---------- 851 # ----------
@@ -917,7 +1030,7 @@ show_ntests(); @@ -917,7 +1030,7 @@ show_ntests();
917 # ---------- 1030 # ----------
918 $td->notify("--- Rotate Pages ---"); 1031 $td->notify("--- Rotate Pages ---");
919 $n_tests += 2; 1032 $n_tests += 2;
920 -# XXX do absolute, positive, and negative on ranges that include 1033 +# Do absolute, positive, and negative on ranges that include
921 # inherited and non-inherited. 1034 # inherited and non-inherited.
922 # Pages 11-15 inherit /Rotate 90 1035 # Pages 11-15 inherit /Rotate 90
923 # Pages 1 and 2 have explicit /Rotate 270 1036 # Pages 1 and 2 have explicit /Rotate 270
@@ -1262,7 +1375,7 @@ $td-&gt;runtest(&quot;C API: no recovery&quot;, @@ -1262,7 +1375,7 @@ $td-&gt;runtest(&quot;C API: no recovery&quot;,
1262 show_ntests(); 1375 show_ntests();
1263 # ---------- 1376 # ----------
1264 $td->notify("--- Recovery Tests ---"); 1377 $td->notify("--- Recovery Tests ---");
1265 -$n_tests += @badfiles + 6; 1378 +$n_tests += @badfiles + 7;
1266 1379
1267 # Recovery tests. These are mostly after-the-fact -- when recovery 1380 # Recovery tests. These are mostly after-the-fact -- when recovery
1268 # was implemented, some degree of recovery was possible on many of the 1381 # was implemented, some degree of recovery was possible on many of the
@@ -1324,6 +1437,13 @@ $td-&gt;runtest(&quot;check with C API&quot;, @@ -1324,6 +1437,13 @@ $td-&gt;runtest(&quot;check with C API&quot;,
1324 $td->EXIT_STATUS => 0}, 1437 $td->EXIT_STATUS => 0},
1325 $td->NORMALIZE_NEWLINES); 1438 $td->NORMALIZE_NEWLINES);
1326 1439
  1440 +$td->runtest("recoverable xref errors",
  1441 + {$td->COMMAND =>
  1442 + "qpdf --check --show-xref xref-errors.pdf"},
  1443 + {$td->FILE => "xref-errors.out",
  1444 + $td->EXIT_STATUS => 3},
  1445 + $td->NORMALIZE_NEWLINES);
  1446 +
1327 show_ntests(); 1447 show_ntests();
1328 # ---------- 1448 # ----------
1329 $td->notify("--- Basic Parsing Tests ---"); 1449 $td->notify("--- Basic Parsing Tests ---");
@@ -2474,8 +2594,8 @@ show_ntests(); @@ -2474,8 +2594,8 @@ show_ntests();
2474 2594
2475 2595
2476 # ---------- 2596 # ----------
2477 -$td->notify("--- PNG filtering Tests ---");  
2478 -$n_tests += 2; 2597 +$td->notify("--- Specialized filtering Tests ---");
  2598 +$n_tests += 3;
2479 $n_compare_pdfs += 1; 2599 $n_compare_pdfs += 1;
2480 2600
2481 # The PDF file was submitted on bug #83 on github. All the PNG filters 2601 # The PDF file was submitted on bug #83 on github. All the PNG filters
@@ -2493,6 +2613,12 @@ $td-&gt;runtest(&quot;check output&quot;, @@ -2493,6 +2613,12 @@ $td-&gt;runtest(&quot;check output&quot;,
2493 {$td->FILE => "png-filters-decoded.pdf"}); 2613 {$td->FILE => "png-filters-decoded.pdf"});
2494 compare_pdfs("png-filters.pdf", "a.pdf"); 2614 compare_pdfs("png-filters.pdf", "a.pdf");
2495 2615
  2616 +$td->runtest("stream with tiff predictor",
  2617 + {$td->COMMAND => "qpdf --check tiff-predictor.pdf"},
  2618 + {$td->FILE => "tiff-predictor.out",
  2619 + $td->EXIT_STATUS => 0},
  2620 + $td->NORMALIZE_NEWLINES);
  2621 +
2496 show_ntests(); 2622 show_ntests();
2497 # ---------- 2623 # ----------
2498 $td->notify("--- fix-qdf Tests ---"); 2624 $td->notify("--- fix-qdf Tests ---");
qpdf/qtest/qpdf/misc-1.out renamed to qpdf/qtest/qpdf/numeric-and-string-1.out
qpdf/qtest/qpdf/misc-1.pdf renamed to qpdf/qtest/qpdf/numeric-and-string-1.pdf
No preview for this file type
qpdf/qtest/qpdf/misc-2.out renamed to qpdf/qtest/qpdf/numeric-and-string-2.out
qpdf/qtest/qpdf/misc-2.pdf renamed to qpdf/qtest/qpdf/numeric-and-string-2.pdf
No preview for this file type
qpdf/qtest/qpdf/misc-3.out renamed to qpdf/qtest/qpdf/numeric-and-string-3.out
qpdf/qtest/qpdf/misc-3.pdf renamed to qpdf/qtest/qpdf/numeric-and-string-3.pdf