aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/keep-files-open.test
blob: 7218312f0c557fffd41d26f602eb33eea36cc870 (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
#!/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('keep-files-open');

my $n_tests = 4;

{ # local scope
    open(F, "<minimal.pdf") or die;
    local $/ = undef;
    binmode F;
    my $content = <F>;
    close(F);
    for (my $i = 1; $i <= 51; ++$i)
    {
        open(F, sprintf(">%03d-kfo.pdf", $i)) or die;
        binmode F;
        print F $content;
        close(F);
    }
}
$td->runtest("automatic disable keep files open",
             {$td->COMMAND =>
                  "qpdf --verbose --static-id --empty" .
                  " --keep-files-open-threshold=50" .
                  " --pages *kfo.pdf -- a.pdf"},
             {$td->FILE => "disable-kfo.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("don't disable keep files open",
             {$td->COMMAND =>
                  "qpdf --verbose --static-id --empty" .
                  " --pages 01*kfo.pdf -- a.pdf"},
             {$td->FILE => "enable-kfo.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("explict keep files open",
             {$td->COMMAND =>
                  "qpdf --verbose --static-id --keep-files-open=y --empty" .
                  " --pages 00?-kfo.pdf -- a.pdf"},
             {$td->FILE => "kfo-y.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);
$td->runtest("explicit keep files open = n",
             {$td->COMMAND =>
                  "qpdf --verbose --static-id --keep-files-open=n --empty" .
                  " --pages 00?-kfo.pdf -- a.pdf"},
             {$td->FILE => "kfo-n.out", $td->EXIT_STATUS => 0},
             $td->NORMALIZE_NEWLINES);

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