summaryrefslogtreecommitdiffstats
path: root/programs
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2016-09-05 13:49:55 (GMT)
committerYann Collet <cyan@fb.com>2016-09-05 13:49:55 (GMT)
commitc8a78dba1fc21f64dec72cf217c21fe8784c42bf (patch)
tree691951a9e57227337f4d53bbe6e469313c7fd7a2 /programs
parent53515b05e66b203bc44ed374fee12bae97737e02 (diff)
downloadlz4-c8a78dba1fc21f64dec72cf217c21fe8784c42bf.zip
lz4-c8a78dba1fc21f64dec72cf217c21fe8784c42bf.tar.gz
lz4-c8a78dba1fc21f64dec72cf217c21fe8784c42bf.tar.bz2
datagen depends on lz4.h for version string
Diffstat (limited to 'programs')
-rw-r--r--programs/datagencli.c7
-rw-r--r--programs/frametest.c15
2 files changed, 12 insertions, 10 deletions
diff --git a/programs/datagencli.c b/programs/datagencli.c
index 7b2b140..2fbcc50 100644
--- a/programs/datagencli.c
+++ b/programs/datagencli.c
@@ -29,6 +29,7 @@
**************************************/
#include <stdio.h> /* fprintf, stderr */
#include "datagen.h" /* RDG_generate */
+#include "lz4.h" /* LZ4_VERSION_STRING */
/**************************************
@@ -53,10 +54,6 @@
/**************************************
* Constants
**************************************/
-#ifndef LZ4_VERSION
-# define LZ4_VERSION "r1"
-#endif
-
#define KB *(1 <<10)
#define MB *(1 <<20)
#define GB *(1U<<30)
@@ -182,7 +179,7 @@ int main(int argc, char** argv)
}
}
- DISPLAYLEVEL(4, "Data Generator %s \n", LZ4_VERSION);
+ DISPLAYLEVEL(4, "Data Generator %s \n", LZ4_VERSION_STRING);
DISPLAYLEVEL(3, "Seed = %u \n", seed);
if (proba!=COMPRESSIBILITY_DEFAULT) DISPLAYLEVEL(3, "Compressibility : %i%%\n", (U32)(proba*100));
diff --git a/programs/frametest.c b/programs/frametest.c
index d9f2566..e8f6975 100644
--- a/programs/frametest.c
+++ b/programs/frametest.c
@@ -591,7 +591,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
size_t srcStart = FUZ_rand(&randState) % (srcDataLength - srcSize);
U64 frameContentSize = ((FUZ_rand(&randState) & 0xF) == 1) ? srcSize : 0;
size_t cSize;
- U64 crcOrig, crcDecoded;
+ U64 crcOrig;
LZ4F_preferences_t* prefsPtr = &prefs;
(void)FUZ_rand(&coreRand); /* update seed */
@@ -654,24 +654,29 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
{ const BYTE* ip = (const BYTE*)compressedBuffer;
const BYTE* const iend = ip + cSize;
+ DISPLAY("cSize : %u ; srcSize : %u \n", (U32)cSize, (U32)srcDataLength);
BYTE* op = (BYTE*)decodedBuffer;
BYTE* const oend = op + srcDataLength;
size_t totalOut = 0;
unsigned maxBits = FUZ_highbit((U32)cSize);
- unsigned nonContiguousDst = (FUZ_rand(&randState) & 3) == 1;
+ unsigned nonContiguousDst = (FUZ_rand(&randState) & 3) == 1; /* 0 : contiguous; 1 : non-contiguous; 2 : dst overwritten */
nonContiguousDst += FUZ_rand(&randState) & nonContiguousDst; /* 0=>0; 1=>1,2 */
XXH64_reset(&xxh64, 1);
if (maxBits < 3) maxBits = 3;
while (ip < iend) {
- unsigned nbBitsI = (FUZ_rand(&randState) % (maxBits-1)) + 1;
- unsigned nbBitsO = (FUZ_rand(&randState) % (maxBits)) + 1;
+ unsigned const nbBitsI = (FUZ_rand(&randState) % (maxBits-1)) + 1;
+ unsigned const nbBitsO = (FUZ_rand(&randState) % (maxBits)) + 1;
size_t iSize = (FUZ_rand(&randState) & ((1<<nbBitsI)-1)) + 1;
size_t oSize = (FUZ_rand(&randState) & ((1<<nbBitsO)-1)) + 2;
if (iSize > (size_t)(iend-ip)) iSize = iend-ip;
if (oSize > (size_t)(oend-op)) oSize = oend-op;
dOptions.stableDst = FUZ_rand(&randState) & 1;
if (nonContiguousDst==2) dOptions.stableDst = 0;
+ DISPLAY("in : %u / %u ; out : %u / %u \n", (U32)iSize, (U32)(iend-ip), (U32)oSize, (U32)(oend-op));
+ if (iSize == 107662)
+ iSize += !iSize;
result = LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, &dOptions);
+ DISPLAY("consumed : %u ; generated : %u ; hint : %u \n", (U32)iSize, (U32)oSize, (U32)result);
if (result == (size_t)-LZ4F_ERROR_contentChecksum_invalid)
locateBuffDiff((BYTE*)srcBuffer+srcStart, decodedBuffer, srcSize, nonContiguousDst);
CHECK(LZ4F_isError(result), "Decompression failed (error %i:%s)", (int)result, LZ4F_getErrorName((LZ4F_errorCode_t)result));
@@ -684,7 +689,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
}
CHECK(result != 0, "Frame decompression failed (error %i)", (int)result);
if (totalOut) { /* otherwise, it's a skippable frame */
- crcDecoded = XXH64_digest(&xxh64);
+ U64 const crcDecoded = XXH64_digest(&xxh64);
if (crcDecoded != crcOrig) locateBuffDiff((BYTE*)srcBuffer+srcStart, decodedBuffer, srcSize, nonContiguousDst);
CHECK(crcDecoded != crcOrig, "Decompression corruption");
}