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.
This commit is contained in:
Jay Berkenbilt 2023-12-20 13:37:21 -05:00
parent 7e679ab8b6
commit 4ee393d1fa
18 changed files with 16 additions and 5 deletions

View File

@ -44,6 +44,7 @@ main(int argc, char* argv[])
->endPages()
->linearize()
->staticId() // for testing only
->compressStreams("n") // avoid dependency on zlib output
->checkConfiguration();
j.run();
std::cout << "out1 status: " << j.getExitCode() << std::endl;
@ -63,6 +64,7 @@ main(int argc, char* argv[])
"1",
"--",
"--static-id",
"--compress-streams=n", // avoid dependency on zlib output
nullptr};
QPDFJob j;
j.initializeFromArgv(new_argv);
@ -81,6 +83,7 @@ main(int argc, char* argv[])
"outputFile": "out3.pdf",
"staticId": "",
"linearize": "",
"compressStreams": "n",
"pages": [
{
"file": ".",

View File

@ -19,7 +19,7 @@ main(int argc, char* argv[])
{
char* infile = NULL;
char* outfile = NULL;
char const* new_argv[6];
char const* new_argv[7];
int r = 0;
char* p = 0;
@ -43,7 +43,8 @@ main(int argc, char* argv[])
new_argv[2] = outfile;
new_argv[3] = "--linearize";
new_argv[4] = "--static-id"; /* for testing only */
new_argv[5] = NULL;
new_argv[5] = "--compress-streams=n"; /* avoid dependency on zlib output */
new_argv[6] = NULL;
/* See qpdf-job.cc for a C++ example of using the json interface. To use that from C just like
* the argv one, call qpdfjob_run_from_json instead and pass the json string as a single char

Binary file not shown.

View File

@ -200,6 +200,7 @@ test05(char const* infile, char const* password, char const* outfile, char const
qpdf_register_progress_reporter(qpdf, count_progress, (void*)&count);
qpdf_set_static_ID(qpdf, QPDF_TRUE);
qpdf_set_linearization(qpdf, QPDF_TRUE);
qpdf_set_compress_streams(qpdf, QPDF_FALSE); // Don't depend on zlib
qpdf_write(qpdf);
/* make sure progress reporter was called */
assert(count > 0);

View File

@ -37,7 +37,8 @@ foreach my $file (qw(short-id long-id))
$td->runtest("linearize $file.pdf",
{$td->COMMAND =>
"qpdf --deterministic-id --linearize $file.pdf a.pdf"},
"qpdf --deterministic-id --compress-streams=n" .
" --linearize $file.pdf a.pdf"},
{$td->STRING => "",
$td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);

View File

@ -18,6 +18,7 @@ my $n_tests = 3;
$td->runtest("linearize pass 1 file",
{$td->COMMAND => "qpdf --linearize --static-id" .
" --compress-streams=n" .
" --linearize-pass1=b.pdf minimal.pdf a.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check output",

View File

@ -18,7 +18,7 @@ my $n_tests = 17;
$td->runtest("linearize duplicated pages",
{$td->COMMAND =>
"qpdf --static-id --linearize" .
"qpdf --static-id --linearize --compress-streams=n" .
" page_api_2.pdf a.pdf"},
{$td->FILE => "duplicate-page-warning.out",
$td->EXIT_STATUS => 3},

Binary file not shown.

View File

@ -47,7 +47,8 @@ $td->runtest("check fix-qdf idempotency",
{$td->FILE => "a.pdf", $td->EXIT_STATUS => 0});
$td->runtest("pages points to page",
{$td->COMMAND =>
"qpdf --static-id --linearize pages-is-page.pdf a.pdf"},
"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",

View File

@ -1211,6 +1211,9 @@ test_32(QPDF& pdf, char const* arg2)
<< "linearized: " << (linearized ? "yes" : "no") << std::endl
<< "newline: " << (newline ? "yes" : "no") << std::endl;
w.setLinearization(linearized);
if (linearized) {
w.setCompressStreams(false); // avoid dependency on zlib's output
}
w.setExtraHeaderText(newline ? "%% Comment with newline\n" : "%% Comment\n% No newline");
w.write();
}