mirror of
https://github.com/lz4/lz4.git
synced 2024-12-03 06:43:43 +08:00
More tests : random flushes
This commit is contained in:
parent
0400451ac2
commit
ed4a6bf2cb
10
lz4frame.h
10
lz4frame.h
@ -44,6 +44,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/****************************************
|
||||
Note : experimental API.
|
||||
Not yet integrated within lz4 library.
|
||||
****************************************/
|
||||
|
||||
/**************************************
|
||||
Includes
|
||||
@ -58,9 +62,9 @@ typedef size_t LZ4F_errorCode_t;
|
||||
typedef enum { OK_FrameEnd = 1 } LZ4F_successCodes;
|
||||
typedef enum { OK_NoError = 0, ERROR_GENERIC = 1,
|
||||
ERROR_maxBlockSize_invalid, ERROR_blockMode_invalid, ERROR_contentChecksumFlag_invalid,
|
||||
ERROR_srcSize_tooLarge, ERROR_dstMaxSize_tooSmall,
|
||||
ERROR_allocation_failed,
|
||||
ERROR_compressionLevel_invalid,
|
||||
ERROR_allocation_failed,
|
||||
ERROR_srcSize_tooLarge, ERROR_dstMaxSize_tooSmall,
|
||||
ERROR_checksum_invalid,
|
||||
ERROR_maxCode
|
||||
} LZ4F_errorCodes; /* error codes are negative unsigned values.
|
||||
@ -80,7 +84,7 @@ typedef enum { noContentChecksum=0, contentChecksumEnabled } contentChecksum_t;
|
||||
typedef struct {
|
||||
blockSizeID_t blockSizeID; /* max64KB, max256KB, max1MB, max4MB ; 0 == default */
|
||||
blockMode_t blockMode; /* blockLinked, blockIndependent ; 0 == default */
|
||||
contentChecksum_t contentChecksumFlag; /* contentChecksumEnabled (default), noContentChecksum ; */
|
||||
contentChecksum_t contentChecksumFlag; /* noContentChecksum, contentChecksumEnabled ; 0 == default */
|
||||
unsigned reserved[3];
|
||||
} LZ4F_frameInfo_t;
|
||||
|
||||
|
@ -356,7 +356,7 @@ _output_error:
|
||||
}
|
||||
|
||||
|
||||
static const U32 srcDataLength = 4 MB;
|
||||
static const U32 srcDataLength = 9 MB; /* needs to be > 2x4MB to test large blocks */
|
||||
|
||||
int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressibility)
|
||||
{
|
||||
@ -419,11 +419,18 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi
|
||||
unsigned nbBitsSeg = FUZ_rand(&randState) % maxBits;
|
||||
size_t iSize = (FUZ_rand(&randState) & ((1<<nbBitsSeg)-1)) + 1;
|
||||
size_t oSize = oend-op;
|
||||
unsigned forceFlush = ((FUZ_rand(&randState) & 3) == 1);
|
||||
if (iSize > (size_t)(iend-ip)) iSize = iend-ip;
|
||||
result = LZ4F_compress(cCtx, op, oSize, ip, iSize, NULL);
|
||||
CHECK(LZ4F_isError(result), "Compression failed (error %i)", (int)result);
|
||||
op += result;
|
||||
ip += iSize;
|
||||
if (forceFlush)
|
||||
{
|
||||
result = LZ4F_flush(cCtx, op, oend-op, NULL);
|
||||
CHECK(LZ4F_isError(result), "Compression failed (error %i)", (int)result);
|
||||
op += result;
|
||||
}
|
||||
}
|
||||
result = LZ4F_compressEnd(cCtx, op, oend-op, NULL);
|
||||
CHECK(LZ4F_isError(result), "Compression completion failed (error %i)", (int)result);
|
||||
|
Loading…
Reference in New Issue
Block a user