From 513ed692342ce2d98d4d505ade3d7b5d329d6c65 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Tue, 19 Dec 2023 08:05:33 -0500 Subject: [PATCH] zlib-flate: make test work with alternative zlib --- zlib-flate/qtest/1.compressed-1 | Bin 193 -> 0 bytes zlib-flate/qtest/1.compressed-9 | Bin 193 -> 0 bytes zlib-flate/qtest/zf.test | 39 ++++++++++++++++++++++++++------ 3 files changed, 32 insertions(+), 7 deletions(-) delete mode 100644 zlib-flate/qtest/1.compressed-1 delete mode 100644 zlib-flate/qtest/1.compressed-9 diff --git a/zlib-flate/qtest/1.compressed-1 b/zlib-flate/qtest/1.compressed-1 deleted file mode 100644 index 11150cf303b0b51084896f1816e2d7e3f0bc0644..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 193 zcmV;y06zbC0VR(ya>OtQMSGv(cWIoxMJ8pMy#OoWmDaM@2o#NPA8a=a%;&!kKQ%D= zTPg^aH-;r{jFSI2df%AwD`V&lxF_BbbF3fc`pS4q%kjz6)g`VwvkfA2++T`i0#@qA{(D-4OtQMSGv(cWIoxMJ8pMy#OoWmDaM@2o#NPA8a=a%;&!kKQ%D= zTPg^aH-;r{jFSI2df%AwD`V&lxF_BbbF3fc`pS4q%kjz6)g`VwvkfA2++T`i0#@qA{(D-4; +close(F); + +open(F, ">a.uncompressed") or die; +for (my $i = 0; $i < 100; $i++) +{ + print F $unc; +} +close(F); + foreach my $level ('', '=1', '=9') { my $f = $level; $f =~ s/=/-/; $td->runtest("compress", {$td->COMMAND => - "zlib-flate -compress$level < 1.uncompressed"}, - {$td->FILE => "1.compressed$f", - $td->EXIT_STATUS => 0}); + "zlib-flate -compress$level < a.uncompressed > a.$level"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); $td->runtest("uncompress", - {$td->COMMAND => "zlib-flate -uncompress < 1.compressed"}, - {$td->FILE => "1.uncompressed", - $td->EXIT_STATUS => 0}); + {$td->COMMAND => "zlib-flate -uncompress < a.$level"}, + {$td->FILE => "a.uncompressed", $td->EXIT_STATUS => 0}); } +my $size1 = (stat("a.=1"))[7]; +my $size9 = (stat("a.=9"))[7]; +$td->runtest("higher compression is smaller", + {$td->STRING => ($size9 < $size1 ? "YES\n" : "$size9 $size1\n")}, + {$td->STRING => "YES\n"}); + $td->runtest("error", {$td->COMMAND => "zlib-flate -uncompress < 1.uncompressed"}, {$td->REGEXP => "flate: inflate: data: .*\n", @@ -36,4 +54,11 @@ $td->runtest("corrupted input", $td->EXIT_STATUS => 3}, $td->NORMALIZE_NEWLINES); -$td->report(8); +$td->report(9); + +cleanup(); + +sub cleanup +{ + system("rm -f a.*"); +}