Commit 4ee393d1fa5424bc25952580b177f572e58920db
1 parent
7e679ab8
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.
Showing
18 changed files
with
16 additions
and
5 deletions
examples/qpdf-job.cc
| ... | ... | @@ -44,6 +44,7 @@ main(int argc, char* argv[]) |
| 44 | 44 | ->endPages() |
| 45 | 45 | ->linearize() |
| 46 | 46 | ->staticId() // for testing only |
| 47 | + ->compressStreams("n") // avoid dependency on zlib output | |
| 47 | 48 | ->checkConfiguration(); |
| 48 | 49 | j.run(); |
| 49 | 50 | std::cout << "out1 status: " << j.getExitCode() << std::endl; |
| ... | ... | @@ -63,6 +64,7 @@ main(int argc, char* argv[]) |
| 63 | 64 | "1", |
| 64 | 65 | "--", |
| 65 | 66 | "--static-id", |
| 67 | + "--compress-streams=n", // avoid dependency on zlib output | |
| 66 | 68 | nullptr}; |
| 67 | 69 | QPDFJob j; |
| 68 | 70 | j.initializeFromArgv(new_argv); |
| ... | ... | @@ -81,6 +83,7 @@ main(int argc, char* argv[]) |
| 81 | 83 | "outputFile": "out3.pdf", |
| 82 | 84 | "staticId": "", |
| 83 | 85 | "linearize": "", |
| 86 | + "compressStreams": "n", | |
| 84 | 87 | "pages": [ |
| 85 | 88 | { |
| 86 | 89 | "file": ".", | ... | ... |
examples/qpdfjob-c.c
| ... | ... | @@ -19,7 +19,7 @@ main(int argc, char* argv[]) |
| 19 | 19 | { |
| 20 | 20 | char* infile = NULL; |
| 21 | 21 | char* outfile = NULL; |
| 22 | - char const* new_argv[6]; | |
| 22 | + char const* new_argv[7]; | |
| 23 | 23 | int r = 0; |
| 24 | 24 | char* p = 0; |
| 25 | 25 | |
| ... | ... | @@ -43,7 +43,8 @@ main(int argc, char* argv[]) |
| 43 | 43 | new_argv[2] = outfile; |
| 44 | 44 | new_argv[3] = "--linearize"; |
| 45 | 45 | new_argv[4] = "--static-id"; /* for testing only */ |
| 46 | - new_argv[5] = NULL; | |
| 46 | + new_argv[5] = "--compress-streams=n"; /* avoid dependency on zlib output */ | |
| 47 | + new_argv[6] = NULL; | |
| 47 | 48 | |
| 48 | 49 | /* See qpdf-job.cc for a C++ example of using the json interface. To use that from C just like |
| 49 | 50 | * the argv one, call qpdfjob_run_from_json instead and pass the json string as a single char | ... | ... |
examples/qtest/qpdf-job/out.pdf
No preview for this file type
qpdf/qpdf-ctest.c
| ... | ... | @@ -200,6 +200,7 @@ test05(char const* infile, char const* password, char const* outfile, char const |
| 200 | 200 | qpdf_register_progress_reporter(qpdf, count_progress, (void*)&count); |
| 201 | 201 | qpdf_set_static_ID(qpdf, QPDF_TRUE); |
| 202 | 202 | qpdf_set_linearization(qpdf, QPDF_TRUE); |
| 203 | + qpdf_set_compress_streams(qpdf, QPDF_FALSE); // Don't depend on zlib | |
| 203 | 204 | qpdf_write(qpdf); |
| 204 | 205 | /* make sure progress reporter was called */ |
| 205 | 206 | assert(count > 0); | ... | ... |
qpdf/qtest/encryption-parameters.test
| ... | ... | @@ -37,7 +37,8 @@ foreach my $file (qw(short-id long-id)) |
| 37 | 37 | |
| 38 | 38 | $td->runtest("linearize $file.pdf", |
| 39 | 39 | {$td->COMMAND => |
| 40 | - "qpdf --deterministic-id --linearize $file.pdf a.pdf"}, | |
| 40 | + "qpdf --deterministic-id --compress-streams=n" . | |
| 41 | + " --linearize $file.pdf a.pdf"}, | |
| 41 | 42 | {$td->STRING => "", |
| 42 | 43 | $td->EXIT_STATUS => 0}, |
| 43 | 44 | $td->NORMALIZE_NEWLINES); | ... | ... |
qpdf/qtest/linearize-pass1.test
| ... | ... | @@ -18,6 +18,7 @@ my $n_tests = 3; |
| 18 | 18 | |
| 19 | 19 | $td->runtest("linearize pass 1 file", |
| 20 | 20 | {$td->COMMAND => "qpdf --linearize --static-id" . |
| 21 | + " --compress-streams=n" . | |
| 21 | 22 | " --linearize-pass1=b.pdf minimal.pdf a.pdf"}, |
| 22 | 23 | {$td->STRING => "", $td->EXIT_STATUS => 0}); |
| 23 | 24 | $td->runtest("check output", | ... | ... |
qpdf/qtest/pages-tree.test
| ... | ... | @@ -18,7 +18,7 @@ my $n_tests = 17; |
| 18 | 18 | |
| 19 | 19 | $td->runtest("linearize duplicated pages", |
| 20 | 20 | {$td->COMMAND => |
| 21 | - "qpdf --static-id --linearize" . | |
| 21 | + "qpdf --static-id --linearize --compress-streams=n" . | |
| 22 | 22 | " page_api_2.pdf a.pdf"}, |
| 23 | 23 | {$td->FILE => "duplicate-page-warning.out", |
| 24 | 24 | $td->EXIT_STATUS => 3}, | ... | ... |
qpdf/qtest/qpdf/c-linearized.pdf
No preview for this file type
qpdf/qtest/qpdf/extra-header-lin-newline.pdf
No preview for this file type
qpdf/qtest/qpdf/extra-header-lin-no-newline.pdf
No preview for this file type
qpdf/qtest/qpdf/linearize-duplicate-page.pdf
No preview for this file type
qpdf/qtest/qpdf/long-id-linearized.pdf
No preview for this file type
qpdf/qtest/qpdf/minimal-linearize-pass1.pdf
qpdf/qtest/qpdf/minimal-linearized.pdf
No preview for this file type
qpdf/qtest/qpdf/pages-is-page-out.pdf
No preview for this file type
qpdf/qtest/qpdf/short-id-linearized.pdf
No preview for this file type
qpdf/qtest/specific-file.test
| ... | ... | @@ -47,7 +47,8 @@ $td->runtest("check fix-qdf idempotency", |
| 47 | 47 | {$td->FILE => "a.pdf", $td->EXIT_STATUS => 0}); |
| 48 | 48 | $td->runtest("pages points to page", |
| 49 | 49 | {$td->COMMAND => |
| 50 | - "qpdf --static-id --linearize pages-is-page.pdf a.pdf"}, | |
| 50 | + "qpdf --static-id --linearize --compress-streams=n" . | |
| 51 | + " pages-is-page.pdf a.pdf"}, | |
| 51 | 52 | {$td->FILE => "pages-is-page.out", $td->EXIT_STATUS => 3}, |
| 52 | 53 | $td->NORMALIZE_NEWLINES); |
| 53 | 54 | $td->runtest("check output", | ... | ... |
qpdf/test_driver.cc
| ... | ... | @@ -1211,6 +1211,9 @@ test_32(QPDF& pdf, char const* arg2) |
| 1211 | 1211 | << "linearized: " << (linearized ? "yes" : "no") << std::endl |
| 1212 | 1212 | << "newline: " << (newline ? "yes" : "no") << std::endl; |
| 1213 | 1213 | w.setLinearization(linearized); |
| 1214 | + if (linearized) { | |
| 1215 | + w.setCompressStreams(false); // avoid dependency on zlib's output | |
| 1216 | + } | |
| 1214 | 1217 | w.setExtraHeaderText(newline ? "%% Comment with newline\n" : "%% Comment\n% No newline"); |
| 1215 | 1218 | w.write(); |
| 1216 | 1219 | } | ... | ... |