aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/specific-file.test
blob: 5d77720afbfd7ca5eb0c71fc4d76048853739c87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env perl
require 5.008;
use warnings;
use strict;

unshift(@INC, '.');
require qpdf_test_helpers;

chdir("qpdf") or die "chdir testdir failed: $!\n";

require TestDriver;

cleanup();

my $td = new TestDriver('specific-file');

my $n_tests = 11;

# Special PDF files that caused problems at some point

$td->runtest("damaged stream",
             {$td->COMMAND => "qpdf --check damaged-stream.pdf"},
             {$td->FILE => "damaged-stream.out", $td->EXIT_STATUS => 3},
             $td->NORMALIZE_NEWLINES);
$td->runtest("damaged stream (C)",
             {$td->COMMAND => "qpdf-ctest 2 damaged-stream.pdf '' a.pdf"},
             {$td->FILE => "damaged-stream-c-check.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("compress objstm and xref",
             {$td->COMMAND =>
                  "qpdf --static-id --stream-data=compress".
                  " --object-streams=generate minimal.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->COMMAND => "qpdf-test-compare a.pdf compress-objstm-xref.pdf"},
             {$td->FILE => "compress-objstm-xref.pdf", $td->EXIT_STATUS => 0});
$td->runtest("qdf + preserved-unreferenced + xref streams",
             {$td->COMMAND => "qpdf --qdf --preserve-unreferenced" .
                  " --static-id compress-objstm-xref.pdf a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",
             {$td->COMMAND => "qpdf-test-compare a.pdf compress-objstm-xref-qdf.pdf"},
             {$td->FILE => "compress-objstm-xref-qdf.pdf", $td->EXIT_STATUS => 0});
$td->runtest("check fix-qdf idempotency",
             {$td->COMMAND => "fix-qdf a.pdf"},
             {$td->FILE => "a.pdf", $td->EXIT_STATUS => 0});
$td->runtest("pages points to page",
             {$td->COMMAND =>
                  "qpdf --static-id --linearize --compress-streams=n" .
                  " pages-is-page.pdf a.pdf"},
             {$td->FILE => "pages-is-page.out", $td->EXIT_STATUS => 3},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "pages-is-page-out.pdf"});
$td->runtest("Acroform /DR with indirect subkey",
             {$td->COMMAND =>
                  "qpdf --static-id --empty" .
                  " --pages dr-with-indirect-item.pdf -- a.pdf"},
             {$td->STRING => "", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("check output",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "dr-with-indirect-item-out.pdf"});

cleanup();
$td->report($n_tests);