summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-09-06 08:47:28 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2014-09-06 08:47:28 (GMT)
commit5c32b50b94849adf7fc2b7b92260eb9e7089e85b (patch)
treebd2a73e814777d9dfbe5520d07d1c4a491288ca7
parentfd8665320fe03f9f61d438a3cc81502406859c2a (diff)
downloadlz4-5c32b50b94849adf7fc2b7b92260eb9e7089e85b.zip
lz4-5c32b50b94849adf7fc2b7b92260eb9e7089e85b.tar.gz
lz4-5c32b50b94849adf7fc2b7b92260eb9e7089e85b.tar.bz2
More tests (variation of blocksize & checksum)
fixed : checksum error on dealing with uncompressed blocks
-rw-r--r--lz4frame.c1
-rw-r--r--programs/frametest.c11
2 files changed, 8 insertions, 4 deletions
diff --git a/lz4frame.c b/lz4frame.c
index ec2af04..866c922 100644
--- a/lz4frame.c
+++ b/lz4frame.c
@@ -842,6 +842,7 @@ goto_decodeCBlockSize:
if ((size_t)(srcEnd-srcPtr) < sizeToCopy) sizeToCopy = srcEnd-srcPtr; /* not enough input to read full block */
if ((size_t)(dstEnd-dstPtr) < sizeToCopy) sizeToCopy = dstEnd - dstPtr;
memcpy(dstPtr, srcPtr, sizeToCopy);
+ if (dctxPtr->frameInfo.contentChecksumFlag) XXH32_update(&(dctxPtr->xxh), srcPtr, sizeToCopy);
srcPtr += sizeToCopy;
dstPtr += sizeToCopy;
if (sizeToCopy == dctxPtr->sizeToDecode) /* all copied */
diff --git a/programs/frametest.c b/programs/frametest.c
index 7d26bee..59666a3 100644
--- a/programs/frametest.c
+++ b/programs/frametest.c
@@ -103,7 +103,7 @@ static int g_time = 0;
*****************************************/
static int no_prompt = 0;
static char* programName;
-static int displayLevel = 3;
+static int displayLevel = 2;
/*********************************************************
@@ -340,6 +340,7 @@ int basicTests(U32 seed, int nbCycles, int startCycle, double compressibility)
if (LZ4F_isError(cSize)) goto _output_error;
DISPLAYLEVEL(3, "Compressed %i bytes into a %i bytes frame \n", (int)testSize, (int)cSize);
+ DISPLAY("Basic tests completed \n");
_end:
free(CNBuffer);
free(compressedBuffer);
@@ -364,10 +365,9 @@ int fuzzerTests(U32 seed, unsigned nbTests, int startCycle, double compressibili
void* compressedBuffer;
void* decodedBuffer;
U32 randState = seed;
- LZ4F_preferences_t prefs = { 0 };
LZ4F_decompressionContext_t dCtx;
- (void)nbTests; (void)startCycle; (void)prefs;
+ (void)startCycle;
// Create compressible test buffer
LZ4F_createDecompressionContext(&dCtx, LZ4F_VERSION);
srcBuffer = malloc(srcDataLength);
@@ -378,10 +378,13 @@ int fuzzerTests(U32 seed, unsigned nbTests, int startCycle, double compressibili
// Select components of compression test
for (testNb=0; testNb < nbTests; testNb++)
{
+ unsigned CCflag = FUZ_rand(&randState) & 1;
+ unsigned BSId = 4 + (FUZ_rand(&randState) & 3);
+ LZ4F_preferences_t prefs = { { BSId, 0, CCflag, 0,0,0 }, 0,0, 0,0,0,0 };
unsigned nbBits = (FUZ_rand(&randState) % (FUZ_highbit(srcDataLength-1) - 1)) + 1;
size_t srcSize = (FUZ_rand(&randState) & ((1<<nbBits)-1)) + 1;
size_t srcStart = FUZ_rand(&randState) % (srcDataLength - srcSize);
- size_t cSize = LZ4F_compressFrame(compressedBuffer, LZ4F_compressFrameBound(srcSize, NULL), srcBuffer+srcStart, srcSize, NULL);
+ size_t cSize = LZ4F_compressFrame(compressedBuffer, LZ4F_compressFrameBound(srcSize, &(prefs.frameInfo)), srcBuffer+srcStart, srcSize, &prefs );
U64 crcOrig = XXH64(srcBuffer+srcStart, srcSize, 1);
U64 crcRes;
LZ4F_errorCode_t err;