[fuzzer] Check ZSTD_initStaticCDict() for every level
This commit is contained in:
parent
ab3346af07
commit
9c8c69e41a
@ -763,28 +763,31 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
DISPLAYLEVEL(3, "OK \n");
|
DISPLAYLEVEL(3, "OK \n");
|
||||||
|
|
||||||
DISPLAYLEVEL(3, "test%3i : compress with static CDict : ", testNb++);
|
DISPLAYLEVEL(3, "test%3i : compress with static CDict : ", testNb++);
|
||||||
{ ZSTD_compressionParameters const cParams = ZSTD_getCParams(1, CNBuffSize, dictSize);
|
{ int const maxLevel = ZSTD_maxCLevel();
|
||||||
size_t const cdictSize = ZSTD_estimateCDictSize_advanced(dictSize, cParams, ZSTD_dlm_byCopy);
|
int level;
|
||||||
void* const cdictBuffer = malloc(cdictSize);
|
for (level = 1; level <= maxLevel; ++level) {
|
||||||
if (cdictBuffer==NULL) goto _output_error;
|
ZSTD_compressionParameters const cParams = ZSTD_getCParams(level, CNBuffSize, dictSize);
|
||||||
{ const ZSTD_CDict* const cdict = ZSTD_initStaticCDict(
|
size_t const cdictSize = ZSTD_estimateCDictSize_advanced(dictSize, cParams, ZSTD_dlm_byCopy);
|
||||||
cdictBuffer, cdictSize,
|
void* const cdictBuffer = malloc(cdictSize);
|
||||||
dictBuffer, dictSize,
|
if (cdictBuffer==NULL) goto _output_error;
|
||||||
ZSTD_dlm_byCopy, ZSTD_dm_auto,
|
{ const ZSTD_CDict* const cdict = ZSTD_initStaticCDict(
|
||||||
cParams);
|
cdictBuffer, cdictSize,
|
||||||
if (cdict == NULL) {
|
dictBuffer, dictSize,
|
||||||
DISPLAY("ZSTD_initStaticCDict failed ");
|
ZSTD_dlm_byCopy, ZSTD_dm_auto,
|
||||||
goto _output_error;
|
cParams);
|
||||||
}
|
if (cdict == NULL) {
|
||||||
cSize = ZSTD_compress_usingCDict(cctx,
|
DISPLAY("ZSTD_initStaticCDict failed ");
|
||||||
compressedBuffer, compressedBufferSize,
|
goto _output_error;
|
||||||
CNBuffer, CNBuffSize, cdict);
|
}
|
||||||
if (ZSTD_isError(cSize)) {
|
cSize = ZSTD_compress_usingCDict(cctx,
|
||||||
DISPLAY("ZSTD_compress_usingCDict failed ");
|
compressedBuffer, compressedBufferSize,
|
||||||
goto _output_error;
|
CNBuffer, MIN(10 KB, CNBuffSize), cdict);
|
||||||
} }
|
if (ZSTD_isError(cSize)) {
|
||||||
free(cdictBuffer);
|
DISPLAY("ZSTD_compress_usingCDict failed ");
|
||||||
}
|
goto _output_error;
|
||||||
|
} }
|
||||||
|
free(cdictBuffer);
|
||||||
|
} }
|
||||||
DISPLAYLEVEL(3, "OK (%u bytes : %.2f%%)\n", (U32)cSize, (double)cSize/CNBuffSize*100);
|
DISPLAYLEVEL(3, "OK (%u bytes : %.2f%%)\n", (U32)cSize, (double)cSize/CNBuffSize*100);
|
||||||
|
|
||||||
DISPLAYLEVEL(3, "test%3i : ZSTD_compress_usingCDict_advanced, no contentSize, no dictID : ", testNb++);
|
DISPLAYLEVEL(3, "test%3i : ZSTD_compress_usingCDict_advanced, no contentSize, no dictID : ", testNb++);
|
||||||
|
Loading…
Reference in New Issue
Block a user