upgraded zbufftest to also test advanced frame parameters no/checksum no/dictID
parent
38a0215b53
commit
83c3f4427c
|
@ -32,9 +32,9 @@
|
||||||
#ifndef ZSTD_BUFFERED_STATIC_H
|
#ifndef ZSTD_BUFFERED_STATIC_H
|
||||||
#define ZSTD_BUFFERED_STATIC_H
|
#define ZSTD_BUFFERED_STATIC_H
|
||||||
|
|
||||||
/* The objects defined into this file should be considered experimental.
|
/* The objects defined into this file must be considered experimental.
|
||||||
* They are not labelled stable, as their prototype may change in the future.
|
* Their prototype may change in future versions.
|
||||||
* You can use them for tests, provide feedback, or if you can endure risk of future changes.
|
* Never use them with a dynamic library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
|
@ -65,10 +65,13 @@ ZSTDLIB_API ZBUFF_DCtx* ZBUFF_createDCtx_advanced(ZSTD_customMem customMem);
|
||||||
/* *************************************
|
/* *************************************
|
||||||
* Advanced Streaming functions
|
* Advanced Streaming functions
|
||||||
***************************************/
|
***************************************/
|
||||||
ZSTDLIB_API size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* cctx,
|
ZSTDLIB_API size_t ZBUFF_compressInit_advanced(ZBUFF_CCtx* zbc,
|
||||||
const void* dict, size_t dictSize,
|
const void* dict, size_t dictSize,
|
||||||
ZSTD_parameters params, U64 pledgedSrcSize);
|
ZSTD_parameters params, U64 pledgedSrcSize);
|
||||||
|
|
||||||
|
|
||||||
|
/* internal util function */
|
||||||
|
|
||||||
MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
|
MEM_STATIC size_t ZBUFF_limitCopy(void* dst, size_t dstCapacity, const void* src, size_t srcSize)
|
||||||
{
|
{
|
||||||
size_t length = ZBUFF_MIN(dstCapacity, srcSize);
|
size_t length = ZBUFF_MIN(dstCapacity, srcSize);
|
||||||
|
|
|
@ -346,8 +346,8 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
||||||
FUZ_rand(&coreSeed);
|
FUZ_rand(&coreSeed);
|
||||||
lseed = coreSeed ^ prime1;
|
lseed = coreSeed ^ prime1;
|
||||||
|
|
||||||
/* state total reset */
|
/* states full reset (unsynchronized) */
|
||||||
/* some problems only happen when states are re-used in a specific order */
|
/* some issues only happen when reusing states in a specific sequence of parameters */
|
||||||
if ((FUZ_rand(&lseed) & 0xFF) == 131) { ZBUFF_freeCCtx(zc); zc = ZBUFF_createCCtx(); }
|
if ((FUZ_rand(&lseed) & 0xFF) == 131) { ZBUFF_freeCCtx(zc); zc = ZBUFF_createCCtx(); }
|
||||||
if ((FUZ_rand(&lseed) & 0xFF) == 132) { ZBUFF_freeDCtx(zd); zd = ZBUFF_createDCtx(); }
|
if ((FUZ_rand(&lseed) & 0xFF) == 132) { ZBUFF_freeDCtx(zd); zd = ZBUFF_createDCtx(); }
|
||||||
|
|
||||||
|
@ -370,15 +370,22 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
||||||
{ U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
{ U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
U32 const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (testLog/3))) + 1;
|
U32 const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (testLog/3))) + 1;
|
||||||
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
||||||
/* random dictionary selection */
|
|
||||||
{ size_t dictStart;
|
|
||||||
dictSize = (FUZ_rand(&lseed)==1) ? FUZ_randomLength(&lseed, maxSampleLog) : 0;
|
dictSize = (FUZ_rand(&lseed)==1) ? FUZ_randomLength(&lseed, maxSampleLog) : 0;
|
||||||
dictStart = FUZ_rand(&lseed) % (srcBufferSize - dictSize);
|
/* random dictionary selection */
|
||||||
|
{ size_t const dictStart = FUZ_rand(&lseed) % (srcBufferSize - dictSize);
|
||||||
dict = srcBuffer + dictStart;
|
dict = srcBuffer + dictStart;
|
||||||
}
|
}
|
||||||
{ size_t const initError = ZBUFF_compressInitDictionary(zc, dict, dictSize, cLevel);
|
{ ZSTD_compressionParameters cPar = ZSTD_getCParams(cLevel, 0, dictSize);
|
||||||
|
U32 const checksum = FUZ_rand(&lseed) & 1;
|
||||||
|
U32 const noDictIDFlag = FUZ_rand(&lseed) & 1;
|
||||||
|
ZSTD_frameParameters const fPar = { 0, checksum, noDictIDFlag };
|
||||||
|
ZSTD_parameters params;
|
||||||
|
ZSTD_adjustCParams(&cPar, 0, dictSize);
|
||||||
|
params.cParams = cPar;
|
||||||
|
params.fParams = fPar;
|
||||||
|
{ size_t const initError = ZBUFF_compressInit_advanced(zc, dict, dictSize, params, 0);
|
||||||
CHECK (ZBUFF_isError(initError),"init error : %s", ZBUFF_getErrorName(initError));
|
CHECK (ZBUFF_isError(initError),"init error : %s", ZBUFF_getErrorName(initError));
|
||||||
} }
|
} } }
|
||||||
|
|
||||||
/* multi-segments compression test */
|
/* multi-segments compression test */
|
||||||
XXH64_reset(&xxhState, 0);
|
XXH64_reset(&xxhState, 0);
|
||||||
|
|
Loading…
Reference in New Issue