aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf/qtest/fix-qdf.test
blob: 96f42367977903dcc826e9cb8dad23cfdb4e82a8 (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
#!/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('fix-qdf');

my $n_tests = 5;

for (my $n = 1; $n <= 2; ++$n)
{
    $td->runtest("fix-qdf $n",
                 {$td->COMMAND => "fix-qdf fix$n.qdf"},
                 {$td->FILE => "fix$n.qdf.out",
                  $td->EXIT_STATUS => 0});

    $td->runtest("identity fix-qdf $n",
                 {$td->COMMAND => "fix-qdf fix$n.qdf.out"},
                 {$td->FILE => "fix$n.qdf.out",
                  $td->EXIT_STATUS => 0});
}
if (! (($^O eq 'MSWin32') || ($^O eq 'Win32') || ($^O eq 'msys')))
{
    # The pipe tests are unstable on Windows. It has not been
    # determined whether this is because the code doesn't work or the
    # tests don't work, but as of September 2023, I think it works
    # with MSVC and not with mingw. Fixing fix-qdf to read from pipes
    # on Windows is not a high priority, but patches are welcome.
    $n_tests += 4;
    for (my $n = 1; $n <= 2; ++$n)
    {
        $td->runtest("fix-qdf $n from pipe",
                     {$td->COMMAND => "cat fix$n.qdf | fix-qdf "},
                     {$td->FILE => "fix$n.qdf.out",
                          $td->EXIT_STATUS => 0});

        $td->runtest("identity fix-qdf $n",
                     {$td->COMMAND => "fix-qdf fix$n.qdf.out"},
                     {$td->FILE => "fix$n.qdf.out",
                          $td->EXIT_STATUS => 0});
}
    }
$td->runtest("fix-qdf with big object stream", # > 255 objects in a stream
             {$td->COMMAND => "fix-qdf big-ostream.pdf"},
             {$td->FILE => "big-ostream.pdf",
              $td->EXIT_STATUS => 0});

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