From 4c7aae3a3676ca299debdcaafce57fe7c1161342 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Sun, 8 Nov 2015 14:24:59 +0100 Subject: [PATCH] fuzzer tests more HC levels --- programs/fuzzer.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/programs/fuzzer.c b/programs/fuzzer.c index 217c8292..ba402e71 100644 --- a/programs/fuzzer.c +++ b/programs/fuzzer.c @@ -297,7 +297,7 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit { size_t sampleSize, sampleStart; size_t cSize, dSize, dSupSize; - U32 sampleSizeLog, buffNb; + U32 sampleSizeLog, buffNb, cLevelMod; U64 crcOrig, crcDest; int cLevel; @@ -328,13 +328,10 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit sampleStart = FUZ_rand(&lseed) % (srcBufferSize - sampleSize); crcOrig = XXH64(srcBuffer + sampleStart, sampleSize, 0); - /* compression test */ - /* covered by HC cLevel 1 - cSize = ZSTD_compressCCtx(ctx, cBuffer, cBufferSize, srcBuffer + sampleStart, sampleSize); - CHECK(ZSTD_isError(cSize), "ZSTD_compress failed"); */ - /* HC compression test */ - cLevel = (FUZ_rand(&lseed) & 3) +1; +#define MAX(a,b) ((a)>(b)?(a):(b)) + cLevelMod = MAX(1, 38 - (int)(MAX(9, sampleSizeLog) * 2)); /* use high compression levels with small samples, for speed */ + cLevel = (FUZ_rand(&lseed) % cLevelMod) +1; cSize = ZSTD_HC_compressCCtx(hcctx, cBuffer, cBufferSize, srcBuffer + sampleStart, sampleSize, cLevel); CHECK(ZSTD_isError(cSize), "ZSTD_HC_compressCCtx failed");