summaryrefslogtreecommitdiffstats
path: root/programs/frametest.c
diff options
context:
space:
mode:
Diffstat (limited to 'programs/frametest.c')
-rw-r--r--programs/frametest.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/programs/frametest.c b/programs/frametest.c
index 3d19ef4..c7e6f45 100644
--- a/programs/frametest.c
+++ b/programs/frametest.c
@@ -78,7 +78,7 @@ typedef unsigned long long U64;
#define MB *(1U<<20)
#define GB *(1U<<30)
-static const U32 nbTestsDefault = 128 KB;
+static const U32 nbTestsDefault = 256 KB;
#define COMPRESSIBLE_NOISE_LENGTH (2 MB)
#define FUZ_COMPRESSIBILITY_DEFAULT 50
static const U32 prime1 = 2654435761U;
@@ -131,7 +131,6 @@ static U32 FUZ_GetMilliSpan(U32 nTimeStart)
}
-
# define FUZ_rotl32(x,r) ((x << r) | (x >> (32 - r)))
unsigned int FUZ_rand(unsigned int* src)
{
@@ -388,7 +387,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
LZ4F_decompressionContext_t dCtx = NULL;
LZ4F_compressionContext_t cCtx = NULL;
size_t result;
- XXH64_stateSpace_t xxh64;
+ XXH64_state_t xxh64;
# define CHECK(cond, ...) if (cond) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); goto _output_error; }
@@ -424,38 +423,39 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
size_t srcStart = FUZ_rand(&randState) % (srcDataLength - srcSize);
size_t cSize;
U64 crcOrig, crcDecoded;
+ LZ4F_preferences_t* prefsPtr = &prefs;
(void)FUZ_rand(&coreRand); // update rand seed
- prefs.frameInfo.blockMode = BMId;
- prefs.frameInfo.blockSizeID = BSId;
- prefs.frameInfo.contentChecksumFlag = CCflag;
+ prefs.frameInfo.blockMode = (blockMode_t)BMId;
+ prefs.frameInfo.blockSizeID = (blockSizeID_t)BSId;
+ prefs.frameInfo.contentChecksumFlag = (contentChecksum_t)CCflag;
prefs.autoFlush = autoflush;
+ prefs.compressionLevel = FUZ_rand(&randState) % 5;
+ if ((FUZ_rand(&randState)&0xF) == 1) prefsPtr = NULL;
DISPLAYUPDATE(2, "\r%5u ", testNb);
crcOrig = XXH64((BYTE*)srcBuffer+srcStart, (U32)srcSize, 1);
if ((FUZ_rand(&randState)&0xF) == 2)
{
- LZ4F_preferences_t* framePrefs = &prefs;
- if ((FUZ_rand(&randState)&7) == 1) framePrefs = NULL;
- cSize = LZ4F_compressFrame(compressedBuffer, LZ4F_compressFrameBound(srcSize, framePrefs), (char*)srcBuffer + srcStart, srcSize, framePrefs);
+ cSize = LZ4F_compressFrame(compressedBuffer, LZ4F_compressFrameBound(srcSize, prefsPtr), (char*)srcBuffer + srcStart, srcSize, prefsPtr);
CHECK(LZ4F_isError(cSize), "LZ4F_compressFrame failed : error %i (%s)", (int)cSize, LZ4F_getErrorName(cSize));
}
else
{
const BYTE* ip = (const BYTE*)srcBuffer + srcStart;
const BYTE* const iend = ip + srcSize;
- BYTE* op = compressedBuffer;
+ BYTE* op = (BYTE*)compressedBuffer;
BYTE* const oend = op + LZ4F_compressFrameBound(srcDataLength, NULL);
unsigned maxBits = FUZ_highbit((U32)srcSize);
- result = LZ4F_compressBegin(cCtx, op, oend-op, &prefs);
+ result = LZ4F_compressBegin(cCtx, op, oend-op, prefsPtr);
CHECK(LZ4F_isError(result), "Compression header failed (error %i)", (int)result);
op += result;
while (ip < iend)
{
unsigned nbBitsSeg = FUZ_rand(&randState) % maxBits;
size_t iSize = (FUZ_rand(&randState) & ((1<<nbBitsSeg)-1)) + 1;
- size_t oSize = oend-op;
+ size_t oSize = LZ4F_compressBound(iSize, prefsPtr);
unsigned forceFlush = ((FUZ_rand(&randState) & 3) == 1);
if (iSize > (size_t)(iend-ip)) iSize = iend-ip;
cOptions.stableSrc = ((FUZ_rand(&randState) & 3) == 1);
@@ -479,14 +479,14 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
}
{
- const BYTE* ip = compressedBuffer;
+ const BYTE* ip = (const BYTE*)compressedBuffer;
const BYTE* const iend = ip + cSize;
- BYTE* op = decodedBuffer;
+ BYTE* op = (BYTE*)decodedBuffer;
BYTE* const oend = op + srcDataLength;
unsigned maxBits = FUZ_highbit((U32)cSize);
unsigned nonContiguousDst = (FUZ_rand(&randState) & 3) == 1;
nonContiguousDst += FUZ_rand(&randState) & nonContiguousDst; /* 0=>0; 1=>1,2 */
- XXH64_resetState(&xxh64, 1);
+ XXH64_reset(&xxh64, 1);
while (ip < iend)
{
unsigned nbBitsI = (FUZ_rand(&randState) % (maxBits-1)) + 1;
@@ -510,7 +510,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
if (nonContiguousDst==2) op = decodedBuffer; // overwritten destination
}
CHECK(result != 0, "Frame decompression failed (error %i)", (int)result);
- crcDecoded = XXH64_intermediateDigest(&xxh64);
+ crcDecoded = XXH64_digest(&xxh64);
if (crcDecoded != crcOrig) locateBuffDiff((BYTE*)srcBuffer+srcStart, decodedBuffer, srcSize, nonContiguousDst);
CHECK(crcDecoded != crcOrig, "Decompression corruption");
}
@@ -598,6 +598,11 @@ int main(int argc, char** argv)
argument++;
displayLevel--;
break;
+ case 'p': /* pause at the end */
+ argument++;
+ pause = 1;
+ break;
+
case 'i':
argument++;
nbTests=0;
@@ -629,7 +634,7 @@ int main(int argc, char** argv)
argument++;
}
break;
- case 'p': /* compressibility % */
+ case 'P': /* compressibility % */
argument++;
proba=0;
while ((*argument>='0') && (*argument<='9'))
@@ -641,10 +646,6 @@ int main(int argc, char** argv)
if (proba<0) proba=0;
if (proba>100) proba=100;
break;
- case 'P': /* pause at the end */
- argument++;
- pause = 1;
- break;
default:
;
return FUZ_usage();