From: Stella Lau Date: Mon, 21 Aug 2017 08:59:08 +0000 (-0700) Subject: Disable tests and refactor X-Git-Tag: fuzz-corpora2~29^2^2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f181f33bdf4f6664ec60c88a5567bb2c9dadea15;p=thirdparty%2Fzstd.git Disable tests and refactor --- diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index 1cccca286..8b8419a4c 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -221,6 +221,7 @@ typedef struct seqDef_s { U16 matchLength; } seqDef; + typedef struct { seqDef* sequencesStart; seqDef* sequences; @@ -240,7 +241,6 @@ struct ZSTD_CCtx_params_s { ZSTD_frameParameters fParams; int compressionLevel; - U32 forceWindow; /* force back-references to respect limit of 1<seqStore); } -#if 0 -// TODO: get rid of this function -static ZSTD_parameters ZSTD_getParamsFromCCtxParams(const ZSTD_CCtx_params cctxParams) -{ - ZSTD_parameters params; - params.cParams = cctxParams.cParams; - params.fParams = cctxParams.fParams; - return params; -} -#endif - -#if 0 -// TODO: get rid of this function too -static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromParams(ZSTD_parameters params) { - ZSTD_CCtx_params cctxParams; - memset(&cctxParams, 0, sizeof(ZSTD_CCtx_params)); - cctxParams.cParams = params.cParams; - cctxParams.fParams = params.fParams; - return cctxParams; -} -#endif -// TODO: get rid of this function too +/* TODO: get rid of this function if possible*/ static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams( ZSTD_compressionParameters cParams) { @@ -234,12 +220,6 @@ static ZSTD_CCtx_params ZSTD_makeCCtxParamsFromCParams( cctxParams.cParams = cParams; return cctxParams; } -#if 0 -// TODO: get rid of this function -static ZSTD_parameters ZSTD_getParamsFromCCtx(const ZSTD_CCtx* cctx) { - return ZSTD_getParamsFromCCtxParams(cctx->appliedParams); -} -#endif /* older variant; will be deprecated */ size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned value) @@ -261,7 +241,6 @@ size_t ZSTD_setCCtxParameter(ZSTD_CCtx* cctx, ZSTD_CCtxParameter param, unsigned #define ZSTD_CLEVEL_CUSTOM 999 -#if 0 static void ZSTD_cLevelToCParams(ZSTD_CCtx* cctx) { if (cctx->requestedParams.compressionLevel==ZSTD_CLEVEL_CUSTOM) return; @@ -270,7 +249,6 @@ static void ZSTD_cLevelToCParams(ZSTD_CCtx* cctx) cctx->pledgedSrcSizePlusOne-1, 0); cctx->requestedParams.compressionLevel = ZSTD_CLEVEL_CUSTOM; } -#endif ZSTD_CCtx_params* ZSTD_createCCtxParams(void) { @@ -290,27 +268,15 @@ size_t ZSTD_resetCCtxParams(ZSTD_CCtx_params* params) return 0; } -size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* params, - ZSTD_compressionParameters cParams) +size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params) { - memset(params, 0, sizeof(ZSTD_CCtx_params)); - params->cParams = cParams; - params->compressionLevel = ZSTD_CLEVEL_CUSTOM; + memset(cctxParams, 0, sizeof(ZSTD_CCtx_params)); + cctxParams->cParams = params.cParams; + cctxParams->fParams = params.fParams; + cctxParams->compressionLevel = ZSTD_CLEVEL_CUSTOM; return 0; } -ZSTD_CCtx_params* ZSTD_createAndInitCCtxParams( - int compressionLevel, unsigned long long estimatedSrcSize, - size_t dictSize) -{ - ZSTD_CCtx_params* params = ZSTD_createCCtxParams(); - if (params == NULL) { return NULL; } - ZSTD_initCCtxParams(params, ZSTD_getCParams( - compressionLevel, estimatedSrcSize, dictSize)); - params->compressionLevel = ZSTD_CLEVEL_CUSTOM; - return params; -} - size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params) { if (params == NULL) { return 0; } @@ -318,8 +284,6 @@ size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params) return 0; } - - static void ZSTD_cLevelToCCtxParams(ZSTD_CCtx_params* params) { if (params->compressionLevel == ZSTD_CLEVEL_CUSTOM) return; @@ -341,6 +305,10 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v switch(param) { case ZSTD_p_compressionLevel: + if (value == 0) return 0; + if (cctx->cdict) return ERROR(stage_wrong); + return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value); + case ZSTD_p_windowLog: case ZSTD_p_hashLog: case ZSTD_p_chainLog: @@ -350,6 +318,7 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v case ZSTD_p_compressionStrategy: if (value == 0) return 0; /* special value : 0 means "don't change anything" */ if (cctx->cdict) return ERROR(stage_wrong); + ZSTD_cLevelToCParams(cctx); return ZSTD_CCtxParam_setParameter(&cctx->requestedParams, param, value); case ZSTD_p_contentSizeFlag: @@ -396,11 +365,12 @@ size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned v if (cctx->requestedParams.nbThreads <= 1) return ERROR(parameter_unsupported); assert(cctx->mtctx != NULL); return ZSTDMT_setMTCtxParameter(cctx->mtctx, ZSTDMT_p_overlapSectionLog, value); - +#if 0 case ZSTD_p_test : DEBUGLOG(2, "Setting test parameter = %u", value); cctx->requestedParams.testParam = (value > 0); return 0; +#endif default: return ERROR(parameter_unsupported); } @@ -477,12 +447,13 @@ size_t ZSTD_CCtxParam_setParameter( params->fParams.checksumFlag = value > 0; return 0; - case ZSTD_p_dictIDFlag : + case ZSTD_p_dictIDFlag : /* When applicable, dictionary's dictID is provided in frame header (default:1) */ DEBUGLOG(5, "set dictIDFlag = %u", (value>0)); params->fParams.noDictIDFlag = (value == 0); return 0; case ZSTD_p_dictMode : + /* restrict dictionary mode to "rawContent" or "fullDict" only */ ZSTD_STATIC_ASSERT((U32)ZSTD_dm_fullDict > (U32)ZSTD_dm_rawContent); if (value > (unsigned)ZSTD_dm_fullDict) { return ERROR(parameter_outOfBound); @@ -491,6 +462,7 @@ size_t ZSTD_CCtxParam_setParameter( return 0; case ZSTD_p_refDictContent : + /* dictionary content will be referenced, instead of copied */ params->dictContentByRef = value > 0; return 0; @@ -516,16 +488,18 @@ size_t ZSTD_CCtxParam_setParameter( if (params->nbThreads <= 1) { return ERROR(parameter_unsupported); } params->overlapSizeLog = value; return 0; - +#if 0 case ZSTD_p_test : DEBUGLOG(2, "setting opaque: ZSTD_p_test: %u", value); params->testParam = (value > 0); return 0; +#endif default: return ERROR(parameter_unsupported); } } +#if 0 static void ZSTD_debugPrintCCtxParams(ZSTD_CCtx_params* params) { DEBUGLOG(2, "======CCtxParams======"); @@ -551,19 +525,24 @@ static void ZSTD_debugPrintCCtxParams(ZSTD_CCtx_params* params) params->nbThreads, params->jobSize, params->overlapSizeLog); +#if 0 DEBUGLOG(2, "testParam: %u", params->testParam); +#endif } +#endif -// This function should probably be updated whenever ZSTD_CCtx_params is updated. -ZSTDLIB_API size_t ZSTD_CCtx_applyCCtxParams(ZSTD_CCtx* cctx, ZSTD_CCtx_params* params) +/** + * This function should be updated whenever ZSTD_CCtx_params is updated. + * Parameters are copied manually before the dictionary is loaded. + * The multithreading parameters jobSize and overlapSizeLog are set only if + * nbThreads >= 1. + */ +size_t ZSTD_CCtx_applyCCtxParams(ZSTD_CCtx* cctx, ZSTD_CCtx_params* params) { if (params == NULL) { return ERROR(GENERIC); } if (cctx->cdict) { return ERROR(stage_wrong); } - DEBUGLOG(2, "Applying cctx params\n"); - ZSTD_debugPrintCCtxParams(params); - /* Assume the compression and frame parameters are validated */ cctx->requestedParams.cParams = params->cParams; cctx->requestedParams.fParams = params->fParams; @@ -585,8 +564,10 @@ ZSTDLIB_API size_t ZSTD_CCtx_applyCCtxParams(ZSTD_CCtx* cctx, ZSTD_CCtx_params* cctx, ZSTD_p_overlapSizeLog, params->overlapSizeLog) ); } - /* Copy test parameter */ +#if 0 + /* Copy test parameter */ cctx->requestedParams.testParam = params->testParam; +#endif return 0; } @@ -3247,7 +3228,6 @@ size_t ZSTD_compressContinue (ZSTD_CCtx* cctx, size_t ZSTD_getBlockSize(const ZSTD_CCtx* cctx) { - // TODO: Applied params compression level okay? Gets overwritten U32 const cLevel = cctx->appliedParams.compressionLevel; ZSTD_compressionParameters cParams = (cLevel == ZSTD_CLEVEL_CUSTOM) ? cctx->appliedParams.cParams : @@ -3710,7 +3690,8 @@ static size_t ZSTD_initCDict_internal_opaque(ZSTD_CDict* cdict, } cdict->dictContentSize = dictSize; - /* Frame parameters should be zero? */ + /* TODO: do the frame parameters need to be zero? + * does nbThreads need to be zero? */ CHECK_F( ZSTD_compressBegin_internal(cdict->refContext, cdict->dictContent, dictSize, NULL, @@ -3748,9 +3729,6 @@ static ZSTD_CDict* ZSTD_createCDict_advanced_opaque( { ZSTD_CDict* const cdict = (ZSTD_CDict*)ZSTD_malloc(sizeof(ZSTD_CDict), customMem); ZSTD_CCtx* const cctx = ZSTD_createCCtx_advanced(customMem); - /* Initialize to 0 to preserve semantics */ - ZSTD_frameParameters const fParams = { 0, 0, 0 }; - params.fParams = fParams; if (!cdict || !cctx) { ZSTD_free(cdict, customMem); @@ -3759,7 +3737,6 @@ static ZSTD_CDict* ZSTD_createCDict_advanced_opaque( } cdict->refContext = cctx; - if (ZSTD_isError( ZSTD_initCDict_internal_opaque( cdict, dictBuffer, dictSize, @@ -3777,8 +3754,6 @@ ZSTD_CDict* ZSTD_createCDict_advanced(const void* dictBuffer, size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_customMem customMem) { ZSTD_CCtx_params cctxParams = ZSTD_makeCCtxParamsFromCParams(cParams); - ZSTD_frameParameters const fParams = { 0, 0, 0 }; - cctxParams.fParams = fParams; cctxParams.dictMode = dictMode; cctxParams.dictContentByRef = byReference; return ZSTD_createCDict_advanced_opaque(dictBuffer, dictSize, cctxParams, customMem); @@ -3837,6 +3812,7 @@ ZSTD_CDict* ZSTD_initStaticCDict_advanced_opaque( cdict->refContext = ZSTD_initStaticCCtx(ptr, cctxSize); params->dictContentByRef = 1; + /* What if nbThreads > 1? */ if (ZSTD_isError( ZSTD_initCDict_internal_opaque(cdict, dict, dictSize, *params) )) return NULL; @@ -3970,11 +3946,10 @@ size_t ZSTD_CStreamOutSize(void) static size_t ZSTD_resetCStream_internal_opaque( ZSTD_CStream* zcs, - const void* dict, size_t dictSize, ZSTD_dictMode_e dictMode, + const void* dict, size_t dictSize, const ZSTD_CDict* cdict, ZSTD_CCtx_params params, unsigned long long pledgedSrcSize) { - params.dictMode = dictMode; DEBUGLOG(4, "ZSTD_resetCStream_internal"); /* params are supposed to be fully validated at this point */ assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams))); @@ -4004,8 +3979,7 @@ static size_t ZSTD_resetCStream_internal(ZSTD_CStream* zcs, ZSTD_CCtx_params cctxParams = zcs->requestedParams; cctxParams.cParams = params.cParams; cctxParams.fParams = params.fParams; - cctxParams.dictMode = dictMode; - return ZSTD_resetCStream_internal_opaque(zcs, dict, dictSize, dictMode, + return ZSTD_resetCStream_internal_opaque(zcs, dict, dictSize, cdict, cctxParams, pledgedSrcSize); } #endif @@ -4018,14 +3992,15 @@ size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize) if (params.compressionLevel != ZSTD_CLEVEL_CUSTOM) { params.cParams = ZSTD_getCParams(params.compressionLevel, pledgedSrcSize, 0 /* dictSize */); } - return ZSTD_resetCStream_internal_opaque(zcs, NULL, 0, params.dictMode, zcs->cdict, params, pledgedSrcSize); + return ZSTD_resetCStream_internal_opaque(zcs, NULL, 0, zcs->cdict, params, pledgedSrcSize); } -size_t ZSTD_initCStream_internal_opaque(ZSTD_CStream* zcs, - const void* dict, size_t dictSize, - const ZSTD_CDict* cdict, - ZSTD_CCtx_params params, - unsigned long long pledgedSrcSize) +size_t ZSTD_initCStream_internal_opaque( + ZSTD_CStream* zcs, + const void* dict, size_t dictSize, + const ZSTD_CDict* cdict, + ZSTD_CCtx_params params, + unsigned long long pledgedSrcSize) { assert(!ZSTD_isError(ZSTD_checkCParams(params.cParams))); assert(!((dict) && (cdict))); /* either dict or cdict, not both */ @@ -4038,8 +4013,8 @@ size_t ZSTD_initCStream_internal_opaque(ZSTD_CStream* zcs, } ZSTD_freeCDict(zcs->cdictLocal); zcs->cdictLocal = ZSTD_createCDict_advanced(dict, dictSize, - zcs->requestedParams.dictContentByRef, - zcs->requestedParams.dictMode, + params.dictContentByRef, + params.dictMode, params.cParams, zcs->customMem); zcs->cdict = zcs->cdictLocal; if (zcs->cdictLocal == NULL) return ERROR(memory_allocation); @@ -4055,8 +4030,7 @@ size_t ZSTD_initCStream_internal_opaque(ZSTD_CStream* zcs, zcs->requestedParams = params; return ZSTD_resetCStream_internal_opaque( - zcs, NULL, 0, zcs->requestedParams.dictMode, zcs->cdict, - params, pledgedSrcSize); + zcs, NULL, 0, zcs->cdict, params, pledgedSrcSize); } #if 0 @@ -4339,7 +4313,7 @@ size_t ZSTD_compress_generic (ZSTD_CCtx* cctx, } else #endif { - CHECK_F( ZSTD_resetCStream_internal_opaque(cctx, prefix, prefixSize, params.dictMode, cctx->cdict, params, cctx->pledgedSrcSizePlusOne-1) ); + CHECK_F( ZSTD_resetCStream_internal_opaque(cctx, prefix, prefixSize, cctx->cdict, params, cctx->pledgedSrcSizePlusOne-1) ); } } /* compression stage */ diff --git a/lib/compress/zstdmt_compress.c b/lib/compress/zstdmt_compress.c index 1296cd316..76a062f04 100644 --- a/lib/compress/zstdmt_compress.c +++ b/lib/compress/zstdmt_compress.c @@ -186,6 +186,10 @@ static void ZSTDMT_releaseBuffer(ZSTDMT_bufferPool* bufPool, buffer_t buf) ZSTD_free(buf.start, bufPool->cMem); } +/** + * TODO + * Resets parameters to zero for jobs? + */ static void ZSTDMT_zeroCCtxParams(ZSTD_CCtx_params* params) { params->forceWindow = 0; @@ -778,7 +782,6 @@ size_t ZSTDMT_initCStream_internal_opaque( } - /** ZSTDMT_initCStream_internal() : * internal usage only */ size_t ZSTDMT_initCStream_internal(ZSTDMT_CCtx* zcs, diff --git a/lib/compress/zstdmt_compress.h b/lib/compress/zstdmt_compress.h index 0b478b735..843a240aa 100644 --- a/lib/compress/zstdmt_compress.h +++ b/lib/compress/zstdmt_compress.h @@ -69,15 +69,6 @@ ZSTDLIB_API size_t ZSTDMT_compress_advanced(ZSTDMT_CCtx* mtctx, const ZSTD_CDict* cdict, ZSTD_parameters const params, unsigned overlapLog); -#if 0 -ZSTDLIB_API size_t ZSTDMT_compress_advanced_opaque( - ZSTDMT_CCtx* mtctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const ZSTD_CDict* cdict, - ZSTD_CCtx_params* const params, - unsigned overlapLog); -#endif ZSTDLIB_API size_t ZSTDMT_initCStream_advanced(ZSTDMT_CCtx* mtctx, const void* dict, size_t dictSize, /* dict can be released after init, a local copy is preserved within zcs */ diff --git a/lib/zstd.h b/lib/zstd.h index eb2a857fe..f02f28c82 100644 --- a/lib/zstd.h +++ b/lib/zstd.h @@ -510,7 +510,7 @@ ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void); * It will also consider src size to be arbitrarily "large", which is worst case. * If srcSize is known to always be small, ZSTD_estimateCStreamSize_advanced() can provide a tighter estimation. * ZSTD_estimateCStreamSize_advanced() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel. - * TODO: ZSTD_estimateCStreamSize_advanced_opaque + * TODO: ZSTD_estimateCStreamSize_advanced_opaque() * Note : CStream estimation is only correct for single-threaded compression. * ZSTD_DStream memory budget depends on window Size. * This information can be passed manually, using ZSTD_estimateDStreamSize, @@ -527,7 +527,7 @@ ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t sr /*! ZSTD_estimate?DictSize() : * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict(). * ZSTD_estimateCStreamSize_advanced() makes it possible to control precisely compression parameters, like ZSTD_createCDict_advanced(). - * TODO: ZSTD_estimateCDictSize_advanced_opaque(), can set by reference + * TODO: ZSTD_estimateCDictSize_advanced_opaque() * Note : dictionary created "byReference" are smaller */ ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel); ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, unsigned byReference); @@ -615,11 +615,9 @@ ZSTDLIB_API ZSTD_CDict* ZSTD_initStaticCDict_advanced_opaque( ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void); ZSTDLIB_API size_t ZSTD_resetCCtxParams(ZSTD_CCtx_params* params); -ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createAndInitCCtxParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize); -ZSTDLIB_API size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* params, ZSTD_compressionParameters cParams); +ZSTDLIB_API size_t ZSTD_initCCtxParams(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params); ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); - /*! ZSTD_getCParams() : * @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. * `estimatedSrcSize` value is optional, select 0 if not known */ @@ -647,7 +645,6 @@ ZSTDLIB_API size_t ZSTD_compress_advanced (ZSTD_CCtx* cctx, const void* dict,size_t dictSize, ZSTD_parameters params); - /*! ZSTD_compress_usingCDict_advanced() : * Same as ZSTD_compress_usingCDict(), with fine-tune control over frame parameters */ ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx, @@ -1003,7 +1000,9 @@ typedef enum { /* advanced parameters - may not remain available after API update */ ZSTD_p_forceMaxWindow=1100, /* Force back-reference distances to remain < windowSize, * even when referencing into Dictionary content (default:0) */ +#if 0 ZSTD_p_test, +#endif } ZSTD_cParameter; @@ -1014,8 +1013,9 @@ typedef enum { * @result : 0, or an error code (which can be tested with ZSTD_isError()). */ ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, unsigned value); +/* TODO */ ZSTDLIB_API size_t ZSTD_CCtxParam_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, unsigned value); - +/* TODO */ ZSTDLIB_API size_t ZSTD_CCtx_applyCCtxParams(ZSTD_CCtx* cctx, ZSTD_CCtx_params* params); /*! ZSTD_CCtx_setPledgedSrcSize() : diff --git a/programs/Makefile b/programs/Makefile index a192716a6..2460a091f 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -47,8 +47,7 @@ DEBUGFLAGS = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \ -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \ -Wredundant-decls -ZSTD_DEBUG_FLAGS = -g -DZSTD_DEBUG=2 -CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) $(ZSTD_DEBUG_FLAGS) +CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) diff --git a/programs/fileio.c b/programs/fileio.c index b32dd83e0..1fb249d6b 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -213,9 +213,10 @@ void FIO_setOverlapLog(unsigned overlapLog){ DISPLAYLEVEL(2, "Setting overlapLog is useless in single-thread mode \n"); g_overlapLog = overlapLog; } +#if 0 static U32 g_testParamFlag = 0; void FIO_setTestParamFlag(unsigned testParamFlag) { g_testParamFlag = testParamFlag; } - +#endif /*-************************************* * Functions @@ -413,9 +414,10 @@ static cRess_t FIO_createCResources(const char* dictFileName, int cLevel, CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_p_nbThreads, g_nbThreads) ); /* dictionary */ CHECK( ZSTD_CCtx_loadDictionary(ress.cctx, dictBuffer, dictBuffSize) ); - +#if 0 /* Test */ CHECK( ZSTD_CCtx_setParameter(ress.cctx, ZSTD_p_test, g_testParamFlag) ); +#endif } #elif defined(ZSTD_MULTITHREAD) { ZSTD_parameters params = ZSTD_getParams(cLevel, srcSize, dictBuffSize); diff --git a/programs/fileio.h b/programs/fileio.h index 9d9167df9..497e122e1 100644 --- a/programs/fileio.h +++ b/programs/fileio.h @@ -56,6 +56,9 @@ void FIO_setMemLimit(unsigned memLimit); void FIO_setNbThreads(unsigned nbThreads); void FIO_setBlockSize(unsigned blockSize); void FIO_setOverlapLog(unsigned overlapLog); +#if 0 +void FIO_setTestParamFlag(unsigned testParamFlag); +#endif /*-************************************* diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 88d4e1524..5e95e4268 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -430,7 +430,9 @@ int main(int argCount, const char* argv[]) if (!strcmp(argument, "--keep")) { FIO_setRemoveSrcFile(0); continue; } if (!strcmp(argument, "--rm")) { FIO_setRemoveSrcFile(1); continue; } if (!strcmp(argument, "--priority=rt")) { setRealTimePrio = 1; continue; } +#if 0 if (!strcmp(argument, "--testParam")) { FIO_setTestParamFlag(1); continue; } +#endif #ifdef ZSTD_GZCOMPRESS if (!strcmp(argument, "--format=gzip")) { suffix = GZ_EXTENSION; FIO_setCompressionType(FIO_gzipCompression); continue; } #endif diff --git a/tests/Makefile b/tests/Makefile index 55de2f58a..e815f5850 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -25,7 +25,7 @@ PRGDIR = ../programs PYTHON ?= python3 TESTARTEFACT := versionsTest namespaceTest -DEBUGLEVEL= 2 +DEBUGLEVEL= 1 DEBUGFLAGS= -g -DZSTD_DEBUG=$(DEBUGLEVEL) CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \ -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR) @@ -169,10 +169,9 @@ datagen : $(PRGDIR)/datagen.c datagencli.c roundTripCrash : $(ZSTD_FILES) roundTripCrash.c $(CC) $(FLAGS) $^ -o $@$(EXT) -OPAQUEFILES := $(ZSTD_FILES) $(ZDICT_FILES) roundTripCrashOpaque.c -roundTripCrashOpaque : LDFLAGS += $(MULTITHREAD_CPP) -roundTripCrashOpaque : LDFLAGS += $(MULTITHREAD_LD) -roundTripCrashOpaque : $(OPAQUEFILES) +cctxParamRoundTrip : LDFLAGS += $(MULTITHREAD_CPP) +cctxParamRoundTrip : LDFLAGS += $(MULTITHREAD_LD) +cctxParamRoundTrip : $(ZSTD_FILES) cctxParamRoundTrip.c $(CC) $(FLAGS) $^ -o $@$(EXT) longmatch : $(ZSTD_FILES) longmatch.c diff --git a/tests/roundTripCrashOpaque.c b/tests/cctxParamRoundTrip.c similarity index 98% rename from tests/roundTripCrashOpaque.c rename to tests/cctxParamRoundTrip.c index f9b6e7f83..45a57a151 100644 --- a/tests/roundTripCrashOpaque.c +++ b/tests/cctxParamRoundTrip.c @@ -38,13 +38,16 @@ fprintf(stderr, \ "Error=> %s: %s", \ #f, ZSTD_getErrorName(err)); \ - exit(1); \ + crash(1); \ } } /** roundTripTest() : * Compresses `srcBuff` into `compressedBuff`, * then decompresses `compressedBuff` into `resultBuff`. +* +* Parameters are currently set manually. +* * @return : result of decompression, which should be == `srcSize` * or an error code if either compression or decompression fails. * Note : `compressedBuffCapacity` should be `>= ZSTD_compressBound(srcSize)` diff --git a/tests/fullbench.c b/tests/fullbench.c index 0c41aa3d5..45ef2b6a3 100644 --- a/tests/fullbench.c +++ b/tests/fullbench.c @@ -136,10 +136,8 @@ size_t local_ZSTD_compressStream(void* dst, size_t dstCapacity, void* buff2, con buffIn.src = src; buffIn.size = srcSize; buffIn.pos = 0; - ZSTD_compressStream(g_cstream, &buffOut, &buffIn); ZSTD_endStream(g_cstream, &buffOut); - return buffOut.pos; } @@ -385,13 +383,11 @@ static size_t benchMem(const void* src, size_t srcSize, U32 benchNb) const BYTE* ip = dstBuff; const BYTE* iend; size_t frameHeaderSize, cBlockSize; - ZSTD_compress(dstBuff, dstBuffSize, src, srcSize, 1); /* it would be better to use direct block compression here */ g_cSize = ZSTD_compress(dstBuff, dstBuffSize, src, srcSize, 1); frameHeaderSize = ZSTD_getFrameHeader(&zfp, dstBuff, ZSTD_frameHeaderSize_min); if (frameHeaderSize==0) frameHeaderSize = ZSTD_frameHeaderSize_min; ip += frameHeaderSize; /* Skip frame Header */ - cBlockSize = ZSTD_getcBlockSize(ip, dstBuffSize, &bp); /* Get 1st block type */ if (bp.blockType != bt_compressed) { DISPLAY("ZSTD_decodeSeqHeaders : impossible to test on this sample (not compressible)\n"); @@ -399,7 +395,6 @@ static size_t benchMem(const void* src, size_t srcSize, U32 benchNb) } iend = ip + ZSTD_blockHeaderSize + cBlockSize; /* End of first block */ ip += ZSTD_blockHeaderSize; /* skip block header */ - ZSTD_decompressBegin(g_zdc); ip += ZSTD_decodeLiteralsBlock(g_zdc, ip, iend-ip); /* skip literal segment */ g_cSize = iend-ip; diff --git a/tests/zstreamtest.c b/tests/zstreamtest.c index 0281a406d..ce50925a1 100644 --- a/tests/zstreamtest.c +++ b/tests/zstreamtest.c @@ -1655,9 +1655,9 @@ static int fuzzerTests_newAPI_opaque(U32 seed, U32 nbTests, unsigned startTest, } if (FUZ_rand(&lseed) & 1) CHECK_Z (ZSTD_CCtxParam_setParameter(cctxParams, ZSTD_p_forceMaxWindow, FUZ_rand(&lseed) & 1) ); - +#if 0 if (FUZ_rand(&lseed) & 1) CHECK_Z (ZSTD_CCtxParam_setParameter(cctxParams, ZSTD_p_test, FUZ_rand(&lseed) & 1) ); - +#endif /* Apply parameters */