aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/deterministic-id.test
blob: 9aeb7f38105e829cc8b74629873da03fa9eca759 (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
#!/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('deterministic-id');

my $n_tests = 11;

foreach my $d ('nn', 'ny', 'yn', 'yy')
{
    my $linearize = ($d =~ m/^y/);
    my $ostream = ($d =~ m/y$/);
    $td->runtest("deterministic ID: linearize/ostream=$d",
                 {$td->COMMAND =>
                      "qpdf -deterministic-id" .
                      ($linearize ? " -linearize" : "") .
                      " -object-streams=" . ($ostream ? "generate" : "disable") .
                      " deterministic-id-in.pdf a.pdf"},
                 {$td->STRING => "",
                  $td->EXIT_STATUS => 0});
    $td->runtest("compare files",
                 {$td->FILE => "a.pdf"},
                 {$td->FILE => "deterministic-id-$d.pdf"});
}

$td->runtest("deterministic ID with encryption",
             {$td->COMMAND => "qpdf -deterministic-id encrypted-with-images.pdf a.pdf"},
             {$td->STRING => "qpdf: INTERNAL ERROR: QPDFWriter::generateID" .
                  " has no data for deterministic ID." .
                  "  This may happen if deterministic ID and" .
                  " file encryption are requested together.\n",
              $td->EXIT_STATUS => 2},
             $td->NORMALIZE_NEWLINES);
$td->runtest("deterministic ID (C API)",
             {$td->COMMAND =>
                  "qpdf-ctest 19 deterministic-id-in.pdf '' a.pdf"},
             {$td->STRING => "C test 19 done\n",
                  $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("compare files",
             {$td->FILE => "a.pdf"},
             {$td->FILE => "deterministic-id-nn.pdf"});

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