summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <yann.collet.73@gmail.com>2014-09-07 10:04:29 (GMT)
committerYann Collet <yann.collet.73@gmail.com>2014-09-07 10:04:29 (GMT)
commitcdececa38dbc45df93a71007781988af789108e8 (patch)
treee52baf32ca249eba03e1af068a410a6806420ad5
parent535120bbe3ebedb5ad5f53bb179242624e7c2828 (diff)
downloadlz4-cdececa38dbc45df93a71007781988af789108e8.zip
lz4-cdececa38dbc45df93a71007781988af789108e8.tar.gz
lz4-cdececa38dbc45df93a71007781988af789108e8.tar.bz2
Added : variable dstBuffer size decompression test
-rw-r--r--programs/frametest.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/programs/frametest.c b/programs/frametest.c
index e582e4a..acd2c1d 100644
--- a/programs/frametest.c
+++ b/programs/frametest.c
@@ -393,11 +393,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, int startTest, double compressibilit
size_t result;
DISPLAYUPDATE(2, "\r%5i ", testNb);
-
- result = LZ4F_compressFrame(compressedBuffer, LZ4F_compressFrameBound(srcSize, &(prefs.frameInfo)), srcBuffer+srcStart, srcSize, &prefs );
- CHECK(LZ4F_isError(result), "Compression failed (error %i)", (int)result);
crcOrig = XXH64(srcBuffer+srcStart, srcSize, 1);
- cSize = result;
{
const BYTE* ip = srcBuffer + srcStart;
@@ -428,6 +424,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, int startTest, double compressibilit
op += result;
result = LZ4F_freeCompressionContext(cctx);
CHECK(LZ4F_isError(result), "deallocation failed (error %i)", (int)result);
+ cSize = op-(BYTE*)compressedBuffer;
}
{
@@ -439,10 +436,12 @@ int fuzzerTests(U32 seed, unsigned nbTests, int startTest, double compressibilit
unsigned maxBits = FUZ_highbit(cSize);
while (ip < iend)
{
- unsigned nbBitsSeg = FUZ_rand(&segRand) % maxBits;
- size_t iSize = (FUZ_rand(&segRand) & ((1<<nbBitsSeg)-1)) + 1;
- size_t oSize = oend-op;
+ unsigned nbBitsI = FUZ_rand(&segRand) % maxBits;
+ unsigned nbBitsO = FUZ_rand(&segRand) % maxBits;
+ size_t iSize = (FUZ_rand(&segRand) & ((1<<nbBitsI)-1)) + 1;
+ size_t oSize = (FUZ_rand(&segRand) & ((1<<nbBitsO)-1)) + 1;
if (iSize > (size_t)(iend-ip)) iSize = iend-ip;
+ if (oSize > (size_t)(oend-op)) oSize = oend-op;
result = LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, NULL);
CHECK(LZ4F_isError(result), "Decompression failed (error %i)", (int)result);
op += oSize;