Commit d54bd7b2658ae7cdef1276abe735613b1397a3bf

Authored by Jay Berkenbilt
1 parent df61f3a6

Add failing tests to illustrate qpdf's generation bug

qpdf/qtest/incremental.test 0 → 100644
  1 +#!/usr/bin/env perl
  2 +require 5.008;
  3 +use warnings;
  4 +use strict;
  5 +
  6 +unshift(@INC, '.');
  7 +require qpdf_test_helpers;
  8 +
  9 +chdir("qpdf") or die "chdir testdir failed: $!\n";
  10 +
  11 +require TestDriver;
  12 +
  13 +cleanup();
  14 +
  15 +my $td = new TestDriver('incremental');
  16 +
  17 +my $n_tests = 6;
  18 +
  19 +# Since the beginning but discovered at the time of releasing 11.8.0:
  20 +# qpdf doesn't delete earlier generations of an object when they are
  21 +# reused.
  22 +$td->runtest("handle delete and reuse",
  23 + {$td->COMMAND => "qpdf --qdf --static-id incremental-1.pdf a.pdf"},
  24 + {$td->STRING => "", $td->EXIT_STATUS => 0},
  25 + $td->NORMALIZE_NEWLINES);
  26 +$td->runtest("check output",
  27 + {$td->FILE => "a.pdf"},
  28 + {$td->FILE => "incremental-1-out.qdf"},
  29 + $td->NORMALIZE_NEWLINES | $td->EXPECT_FAILURE);
  30 +$td->runtest("check xref",
  31 + {$td->COMMAND => "qpdf --show-xref incremental-1.pdf"},
  32 + {$td->FILE => "incremental-1-xref.out", $td->EXIT_STATUS => 0},
  33 + $td->NORMALIZE_NEWLINES | $td->EXPECT_FAILURE);
  34 +$td->runtest("handle delete and reuse",
  35 + {$td->COMMAND => "qpdf --qdf --static-id incremental-2.pdf a.pdf"},
  36 + {$td->STRING => "", $td->EXIT_STATUS => 0},
  37 + $td->NORMALIZE_NEWLINES);
  38 +$td->runtest("check output",
  39 + {$td->FILE => "a.pdf"},
  40 + # intentionally comparing incremental-2 with incremental-1-out
  41 + {$td->FILE => "incremental-1-out.qdf"},
  42 + $td->NORMALIZE_NEWLINES | $td->EXPECT_FAILURE);
  43 +$td->runtest("check xref",
  44 + {$td->COMMAND => "qpdf --show-xref incremental-1.pdf"},
  45 + {$td->FILE => "incremental-2-xref.out", $td->EXIT_STATUS => 0},
  46 + $td->NORMALIZE_NEWLINES | $td->EXPECT_FAILURE);
  47 +
  48 +cleanup();
  49 +$td->report($n_tests);
... ...
qpdf/qtest/qpdf/incremental-1-out.qdf 0 → 100644
  1 +%PDF-1.3
  2 +%¿÷¢þ
  3 +%QDF-1.0
  4 +
  5 +%% Original object ID: 1 0
  6 +1 0 obj
  7 +<<
  8 + /Pages 2 0 R
  9 + /Type /Catalog
  10 +>>
  11 +endobj
  12 +
  13 +%% Original object ID: 2 0
  14 +2 0 obj
  15 +<<
  16 + /Count 1
  17 + /Kids [
  18 + 3 0 R
  19 + ]
  20 + /Type /Pages
  21 +>>
  22 +endobj
  23 +
  24 +%% Page 1
  25 +%% Original object ID: 3 0
  26 +3 0 obj
  27 +<<
  28 + /Contents 4 0 R
  29 + /MediaBox [
  30 + 0
  31 + 0
  32 + 612
  33 + 792
  34 + ]
  35 + /Parent 2 0 R
  36 + /Resources <<
  37 + /Font <<
  38 + /F1 5 0 R
  39 + >>
  40 + /ProcSet 6 0 R
  41 + >>
  42 + /Type /Page
  43 +>>
  44 +endobj
  45 +
  46 +%% Original object ID: 4 1
  47 +4 0 obj
  48 +[
  49 + 7 0 R
  50 +]
  51 +endobj
  52 +
  53 +%% Original object ID: 6 0
  54 +5 0 obj
  55 +<<
  56 + /BaseFont /Helvetica
  57 + /Encoding /WinAnsiEncoding
  58 + /Name /F1
  59 + /Subtype /Type1
  60 + /Type /Font
  61 +>>
  62 +endobj
  63 +
  64 +%% Original object ID: 5 0
  65 +6 0 obj
  66 +[
  67 + /PDF
  68 + /Text
  69 +]
  70 +endobj
  71 +
  72 +%% Contents for page 1
  73 +%% Original object ID: 7 0
  74 +7 0 obj
  75 +<<
  76 + /Length 8 0 R
  77 +>>
  78 +stream
  79 +BT
  80 + /F1 24 Tf
  81 + 72 720 Td
  82 + (Salad) Tj
  83 +ET
  84 +endstream
  85 +endobj
  86 +
  87 +8 0 obj
  88 +43
  89 +endobj
  90 +
  91 +xref
  92 +0 9
  93 +0000000000 65535 f
  94 +0000000052 00000 n
  95 +0000000133 00000 n
  96 +0000000242 00000 n
  97 +0000000461 00000 n
  98 +0000000516 00000 n
  99 +0000000661 00000 n
  100 +0000000746 00000 n
  101 +0000000844 00000 n
  102 +trailer <<
  103 + /Root 1 0 R
  104 + /Size 9
  105 + /ID [<31415926535897932384626433832795><31415926535897932384626433832795>]
  106 +>>
  107 +startxref
  108 +863
  109 +%%EOF
... ...
qpdf/qtest/qpdf/incremental-1-xref.out 0 → 100644
  1 +1/0: uncompressed; offset = 9
  2 +2/0: uncompressed; offset = 63
  3 +3/0: uncompressed; offset = 1069
  4 +4/1: uncompressed; offset = 948
  5 +5/0: uncompressed; offset = 403
  6 +6/0: uncompressed; offset = 438
  7 +7/0: uncompressed; offset = 974
... ...
qpdf/qtest/qpdf/incremental-1.pdf 0 → 100644
  1 +%PDF-1.3
  2 +1 0 obj
  3 +<<
  4 + /Type /Catalog
  5 + /Pages 2 0 R
  6 +>>
  7 +endobj
  8 +
  9 +2 0 obj
  10 +<<
  11 + /Type /Pages
  12 + /Kids [
  13 + 3 0 R
  14 + ]
  15 + /Count 1
  16 +>>
  17 +endobj
  18 +
  19 +3 0 obj
  20 +<<
  21 + /Type /Page
  22 + /Parent 2 0 R
  23 + /MediaBox [0 0 612 792]
  24 + /Contents 4 0 R
  25 + /Resources <<
  26 + /ProcSet 5 0 R
  27 + /Font <<
  28 + /F1 6 0 R
  29 + >>
  30 + >>
  31 +>>
  32 +endobj
  33 +
  34 +4 0 obj
  35 +<<
  36 + /Length 44
  37 +>>
  38 +stream
  39 +BT
  40 + /F1 24 Tf
  41 + 72 720 Td
  42 + (Potato) Tj
  43 +ET
  44 +endstream
  45 +endobj
  46 +
  47 +5 0 obj
  48 +[
  49 + /PDF
  50 + /Text
  51 +]
  52 +endobj
  53 +
  54 +6 0 obj
  55 +<<
  56 + /Type /Font
  57 + /Subtype /Type1
  58 + /Name /F1
  59 + /BaseFont /Helvetica
  60 + /Encoding /WinAnsiEncoding
  61 +>>
  62 +endobj
  63 +
  64 +xref
  65 +0 7
  66 +0000000000 65535 f
  67 +0000000009 00000 n
  68 +0000000063 00000 n
  69 +0000000135 00000 n
  70 +0000000307 00000 n
  71 +0000000403 00000 n
  72 +0000000438 00000 n
  73 +trailer <<
  74 + /Size 7
  75 + /Root 1 0 R
  76 +>>
  77 +startxref
  78 +556
  79 +%%EOF
  80 +
  81 +% Delete object 4 and increment generation
  82 +xref
  83 +0 1
  84 +0000000004 65535 f
  85 +4 1
  86 +0000000000 00001 f
  87 +trailer <<
  88 + /Size 7
  89 + /Root 1 0 R
  90 + /Prev 556
  91 +>>
  92 +startxref
  93 +807
  94 +%%EOF
  95 +
  96 +% Reuse object 4
  97 +4 1 obj
  98 +[ 7 0 R ]
  99 +endobj
  100 +
  101 +7 0 obj
  102 +<<
  103 + /Length 43
  104 +>>
  105 +stream
  106 +BT
  107 + /F1 24 Tf
  108 + 72 720 Td
  109 + (Salad) Tj
  110 +ET
  111 +endstream
  112 +endobj
  113 +
  114 +3 0 obj
  115 +<<
  116 + /Type /Page
  117 + /Parent 2 0 R
  118 + /MediaBox [0 0 612 792]
  119 + /Contents 4 1 R
  120 + /Resources <<
  121 + /ProcSet 5 0 R
  122 + /Font <<
  123 + /F1 6 0 R
  124 + >>
  125 + >>
  126 +>>
  127 +endobj
  128 +
  129 +xref
  130 +0 1
  131 +0000000000 65535 f
  132 +3 2
  133 +0000001069 00000 n
  134 +0000000948 00001 n
  135 +7 1
  136 +0000000974 00000 n
  137 +trailer <<
  138 + /Size 8
  139 + /Root 1 0 R
  140 + /Prev 807
  141 + /Gone 4 0 R
  142 +>>
  143 +startxref
  144 +1241
  145 +%%EOF
... ...
qpdf/qtest/qpdf/incremental-2-xref.out 0 → 100644
  1 +1/0: uncompressed; offset = 9
  2 +2/0: uncompressed; offset = 63
  3 +3/0: uncompressed; offset = 1069
  4 +4/0: uncompressed; offset = 307
  5 +5/0: uncompressed; offset = 403
  6 +6/0: uncompressed; offset = 438
  7 +7/0: uncompressed; offset = 974
... ...
qpdf/qtest/qpdf/incremental-2.pdf 0 → 100644
  1 +%PDF-1.3
  2 +1 0 obj
  3 +<<
  4 + /Type /Catalog
  5 + /Pages 2 0 R
  6 +>>
  7 +endobj
  8 +
  9 +2 0 obj
  10 +<<
  11 + /Type /Pages
  12 + /Kids [
  13 + 3 0 R
  14 + ]
  15 + /Count 1
  16 +>>
  17 +endobj
  18 +
  19 +3 0 obj
  20 +<<
  21 + /Type /Page
  22 + /Parent 2 0 R
  23 + /MediaBox [0 0 612 792]
  24 + /Contents 4 0 R
  25 + /Resources <<
  26 + /ProcSet 5 0 R
  27 + /Font <<
  28 + /F1 6 0 R
  29 + >>
  30 + >>
  31 +>>
  32 +endobj
  33 +
  34 +4 0 obj
  35 +<<
  36 + /Length 44
  37 +>>
  38 +stream
  39 +BT
  40 + /F1 24 Tf
  41 + 72 720 Td
  42 + (Potato) Tj
  43 +ET
  44 +endstream
  45 +endobj
  46 +
  47 +5 0 obj
  48 +[
  49 + /PDF
  50 + /Text
  51 +]
  52 +endobj
  53 +
  54 +6 0 obj
  55 +<<
  56 + /Type /Font
  57 + /Subtype /Type1
  58 + /Name /F1
  59 + /BaseFont /Helvetica
  60 + /Encoding /WinAnsiEncoding
  61 +>>
  62 +endobj
  63 +
  64 +xref
  65 +0 7
  66 +0000000000 65535 f
  67 +0000000009 00000 n
  68 +0000000063 00000 n
  69 +0000000135 00000 n
  70 +0000000307 00000 n
  71 +0000000403 00000 n
  72 +0000000438 00000 n
  73 +trailer <<
  74 + /Size 7
  75 + /Root 1 0 R
  76 +>>
  77 +startxref
  78 +556
  79 +%%EOF
  80 +
  81 +% Reuse object 4 without deleting first
  82 +4 1 obj
  83 +[ 7 0 R ]
  84 +endobj
  85 +
  86 +7 0 obj
  87 +<<
  88 + /Length 43
  89 +>>
  90 +stream
  91 +BT
  92 + /F1 24 Tf
  93 + 72 720 Td
  94 + (Salad) Tj
  95 +ET
  96 +endstream
  97 +endobj
  98 +
  99 +3 0 obj
  100 +<<
  101 + /Type /Page
  102 + /Parent 2 0 R
  103 + /MediaBox [0 0 612 792]
  104 + /Contents 4 1 R
  105 + /Resources <<
  106 + /ProcSet 5 0 R
  107 + /Font <<
  108 + /F1 6 0 R
  109 + >>
  110 + >>
  111 +>>
  112 +endobj
  113 +
  114 +xref
  115 +0 1
  116 +0000000000 65535 f
  117 +3 2
  118 +0000000925 00000 n
  119 +0000000804 00001 n
  120 +7 1
  121 +0000000830 00000 n
  122 +trailer <<
  123 + /Size 8
  124 + /Root 1 0 R
  125 + /Prev 556
  126 + /Gone 4 0 R
  127 +>>
  128 +startxref
  129 +1097
  130 +%%EOF
... ...