2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-10 14:12:26 +00:00
qpdf/qpdf/qtest/specific-file.test
Jay Berkenbilt 4ee393d1fa Remove compression from linearization tests where possible
By combining --linearize with --compress-streams=n, we ensure that no
new compressed data will appear in linearized output, which makes the
output independent of zlib's output. There are other tests to ensure
that linearization works correctly with compression. This commit
involves changing some test outputs and test code as well just
updating test suites.
2023-12-20 15:46:20 -05:00

69 lines
2.6 KiB
Perl

#!/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);