]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
fix test
authorYann Collet <cyan@fb.com>
Wed, 16 Oct 2024 19:55:52 +0000 (12:55 -0700)
committerYann Collet <cyan@fb.com>
Thu, 17 Oct 2024 16:37:23 +0000 (09:37 -0700)
a margin of 4 is insufficient to guarantee compression success.

tests/zstreamtest.c

index 8625b4a23730d1bb84de0011d6da939252847d71..2c25adf3ca3d62eb993a0da976b16af64d1687bc 100644 (file)
@@ -758,7 +758,7 @@ static int basicUnitTests(U32 seed, double compressibility, int bigTests)
         }
         streaming2KSize = ZSTD_sizeof_DCtx(dctx);
         CHECK_Z(streaming2KSize);
-        
+
         CHECK_Z(ZSTD_DCtx_reset(dctx, ZSTD_reset_session_and_parameters));
         inBuff.pos = 0;
         outBuff.pos = 0;
@@ -769,7 +769,7 @@ static int basicUnitTests(U32 seed, double compressibility, int bigTests)
         }
         streamingSize = ZSTD_sizeof_DCtx(dctx);
         CHECK_Z(streamingSize);
-        
+
         CHECK_Z(ZSTD_DCtx_setParameter(dctx, ZSTD_d_maxBlockSize, 1024));
         inBuff.pos = 0;
         outBuff.pos = 0;
@@ -884,7 +884,8 @@ static int basicUnitTests(U32 seed, double compressibility, int bigTests)
         DISPLAYLEVEL(3, "test%3i : ZSTD_compress2() uses stable input and output : ", testNb++);
         CHECK_Z(cSize = ZSTD_compress2(cctx, compressedBuffer, compressedBufferSize, CNBuffer, CNBufferSize));
         CHECK(!(cSize < ZSTD_compressBound(CNBufferSize)), "cSize too large for test");
-        CHECK_Z(cSize = ZSTD_compress2(cctx, compressedBuffer, cSize + 4, CNBuffer, CNBufferSize));
+        /* check that compression fits with just a 8-bytes margin */
+        CHECK_Z(cSize = ZSTD_compress2(cctx, compressedBuffer, cSize+8, CNBuffer, CNBufferSize));
         CHECK_Z(cctxSize1 = ZSTD_sizeof_CCtx(cctx));
         /* @cctxSize2 : sizeof_CCtx when doing full streaming (no stable in/out) */
         {   ZSTD_CCtx* const cctx2 = ZSTD_createCCtx();
@@ -2503,7 +2504,7 @@ static int basicUnitTests(U32 seed, double compressibility, int bigTests)
         // Validate
         CHECK(outBuf.pos != srcSize, "decompressed size must match");
         CHECK(memcmp(src, val, srcSize) != 0, "decompressed data must match");
-        
+
         // Cleanup
         free(src); free(dst); free(val);
         ZSTD_freeCCtx(cctx);