From: Vsevolod Stakhov Date: Fri, 5 Dec 2025 16:31:16 +0000 (+0000) Subject: [Test] Use size ranges for gzip tests to support zlib-ng X-Git-Tag: 3.14.2~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ace9d7878921e762161efee748787de88251777;p=thirdparty%2Frspamd.git [Test] Use size ranges for gzip tests to support zlib-ng Fedora 40+ uses zlib-ng which produces slightly different compressed sizes than standard zlib. Instead of checking exact sizes, use reasonable ranges that accommodate both implementations. --- diff --git a/test/rspamd_cxx_unit_utils.hxx b/test/rspamd_cxx_unit_utils.hxx index 1dea7af9d7..5b0874b1ee 100644 --- a/test/rspamd_cxx_unit_utils.hxx +++ b/test/rspamd_cxx_unit_utils.hxx @@ -94,12 +94,15 @@ TEST_SUITE("rspamd_utils") rspamd_fstring_t *fstr; // Test empty data compression + // Note: gzip has 10-byte header + 8-byte trailer = 18 bytes minimum + // Different zlib implementations (zlib vs zlib-ng) may produce slightly different sizes SUBCASE("Empty data") { fstr = rspamd_fstring_new_init("", 0); gboolean result = rspamd_fstring_gzip(&fstr); CHECK(result == TRUE); - CHECK(fstr->len == 20); + CHECK(fstr->len >= 18);// gzip minimum overhead + CHECK(fstr->len <= 24);// reasonable upper bound for empty data result = rspamd_fstring_gunzip(&fstr); CHECK(result == TRUE); CHECK(fstr->len == 0); @@ -111,7 +114,9 @@ TEST_SUITE("rspamd_utils") fstr = RSPAMD_FSTRING_LIT("helohelo"); gboolean result = rspamd_fstring_gzip(&fstr); CHECK(result == TRUE); - CHECK(fstr->len == 26); + // Compressed size varies by zlib implementation (zlib: 26, zlib-ng: 28) + CHECK(fstr->len >= 24); + CHECK(fstr->len <= 32); result = rspamd_fstring_gunzip(&fstr); CHECK(result == TRUE); CHECK(memcmp(fstr->str, "helohelo", fstr->len) == 0); @@ -127,7 +132,9 @@ TEST_SUITE("rspamd_utils") } gboolean result = rspamd_fstring_gzip(&fstr); CHECK(result == TRUE); - CHECK(fstr->len == 49); + // Highly compressible data, compressed size varies by implementation + CHECK(fstr->len >= 40); + CHECK(fstr->len <= 60); result = rspamd_fstring_gunzip(&fstr); CHECK(result == TRUE); CHECK(memcmp(fstr->str, "helohelo", sizeof("helohelo") - 1) == 0);