Added CLI tests for --no-check, fixed ignore checksum logic
This commit is contained in:
@@ -447,7 +447,7 @@ static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t he
|
|||||||
RETURN_ERROR_IF(dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID),
|
RETURN_ERROR_IF(dctx->fParams.dictID && (dctx->dictID != dctx->fParams.dictID),
|
||||||
dictionary_wrong, "");
|
dictionary_wrong, "");
|
||||||
#endif
|
#endif
|
||||||
if (dctx->fParams.checksumFlag) XXH64_reset(&dctx->xxhState, 0);
|
if (dctx->fParams.checksumFlag && !dctx->forceIgnoreChecksum) XXH64_reset(&dctx->xxhState, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1010,10 +1010,13 @@ size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, c
|
|||||||
|
|
||||||
case ZSTDds_checkChecksum:
|
case ZSTDds_checkChecksum:
|
||||||
assert(srcSize == 4); /* guaranteed by dctx->expected */
|
assert(srcSize == 4); /* guaranteed by dctx->expected */
|
||||||
{ U32 const h32 = (U32)XXH64_digest(&dctx->xxhState);
|
{
|
||||||
|
if (!dctx->forceIgnoreChecksum) {
|
||||||
|
U32 const h32 = (U32)XXH64_digest(&dctx->xxhState);
|
||||||
U32 const check32 = MEM_readLE32(src);
|
U32 const check32 = MEM_readLE32(src);
|
||||||
DEBUGLOG(4, "ZSTD_decompressContinue: checksum : calculated %08X :: %08X read", (unsigned)h32, (unsigned)check32);
|
DEBUGLOG(4, "ZSTD_decompressContinue: checksum : calculated %08X :: %08X read", (unsigned)h32, (unsigned)check32);
|
||||||
RETURN_ERROR_IF(check32 != h32, checksum_wrong, "");
|
RETURN_ERROR_IF(check32 != h32, checksum_wrong, "");
|
||||||
|
}
|
||||||
dctx->expected = 0;
|
dctx->expected = 0;
|
||||||
dctx->stage = ZSTDds_getFrameHeaderSize;
|
dctx->stage = ZSTDds_getFrameHeaderSize;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
+1
-1
@@ -1755,7 +1755,7 @@ static dRess_t FIO_createDResources(FIO_prefs_t* const prefs, const char* dictFi
|
|||||||
EXM_THROW(60, "Error: %s : can't create ZSTD_DStream", strerror(errno));
|
EXM_THROW(60, "Error: %s : can't create ZSTD_DStream", strerror(errno));
|
||||||
CHECK( ZSTD_DCtx_setMaxWindowSize(ress.dctx, prefs->memLimit) );
|
CHECK( ZSTD_DCtx_setMaxWindowSize(ress.dctx, prefs->memLimit) );
|
||||||
if (!prefs->checksumFlag)
|
if (!prefs->checksumFlag)
|
||||||
CHECK( ZSTD_DCtx_setForceIgnoreChecksum(ress.dctx, 1 /* ZSTD_d_ignoreChecksum */));
|
CHECK( ZSTD_DCtx_setForceIgnoreChecksum(ress.dctx, ZSTD_d_ignoreChecksum));
|
||||||
ress.srcBufferSize = ZSTD_DStreamInSize();
|
ress.srcBufferSize = ZSTD_DStreamInSize();
|
||||||
ress.srcBuffer = malloc(ress.srcBufferSize);
|
ress.srcBuffer = malloc(ress.srcBufferSize);
|
||||||
ress.dstBufferSize = ZSTD_DStreamOutSize();
|
ress.dstBufferSize = ZSTD_DStreamOutSize();
|
||||||
|
|||||||
@@ -260,6 +260,11 @@ zstd tmp -c --compress-literals --fast=1 | zstd -t
|
|||||||
zstd tmp -c --compress-literals -19 | zstd -t
|
zstd tmp -c --compress-literals -19 | zstd -t
|
||||||
zstd -b --fast=1 -i0e1 tmp --compress-literals
|
zstd -b --fast=1 -i0e1 tmp --compress-literals
|
||||||
zstd -b --fast=1 -i0e1 tmp --no-compress-literals
|
zstd -b --fast=1 -i0e1 tmp --no-compress-literals
|
||||||
|
println "test: --no-check for decompression"
|
||||||
|
zstd -f tmp --check
|
||||||
|
zstd -f tmp -o tmp1.zst --no-check
|
||||||
|
zstd -d -f tmp.zst --no-check
|
||||||
|
zstd -d -f tmp1.zst --no-check
|
||||||
|
|
||||||
println "\n===> zstdgrep tests"
|
println "\n===> zstdgrep tests"
|
||||||
ln -sf "$ZSTD_BIN" zstdcat
|
ln -sf "$ZSTD_BIN" zstdcat
|
||||||
|
|||||||
Reference in New Issue
Block a user