diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2015-03-16 18:19:39 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2015-03-16 18:19:39 (GMT) |
commit | 2a02455fdfb7250ef629a3ffde5258e95df06e7b (patch) | |
tree | cb11624d5b44c48293c7bb2ee0b5835ed55375df /programs/frametest.c | |
parent | 3a6832497ba02607dd4ede3a3fd30911e06f037e (diff) | |
download | lz4-2a02455fdfb7250ef629a3ffde5258e95df06e7b.zip lz4-2a02455fdfb7250ef629a3ffde5258e95df06e7b.tar.gz lz4-2a02455fdfb7250ef629a3ffde5258e95df06e7b.tar.bz2 |
minor refactoring
Diffstat (limited to 'programs/frametest.c')
-rw-r--r-- | programs/frametest.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/programs/frametest.c b/programs/frametest.c index be2be76..62b6fa4 100644 --- a/programs/frametest.c +++ b/programs/frametest.c @@ -388,7 +388,7 @@ int basicTests(U32 seed, double compressibility) BYTE* op = (BYTE*)decodedBuffer; BYTE* const oend = (BYTE*)decodedBuffer + COMPRESSIBLE_NOISE_LENGTH; BYTE* ip = (BYTE*)compressedBuffer; - BYTE* const iend = (BYTE*)compressedBuffer + cSize + 8; + BYTE* iend = (BYTE*)compressedBuffer + cSize + 8; LZ4F_errorCode_t errorCode = LZ4F_createDecompressionContext(&dCtx, LZ4F_VERSION); if (LZ4F_isError(errorCode)) goto _output_error; @@ -411,6 +411,25 @@ int basicTests(U32 seed, double compressibility) } DISPLAYLEVEL(3, "Skipped %i bytes \n", (int)decodedBufferSize); + /* generate zero-size skippable frame */ + FUZ_writeLE32(ip, LZ4F_MAGIC_SKIPPABLE_START+1); + FUZ_writeLE32(ip+4, 0); + iend = ip+8; + + DISPLAYLEVEL(3, "random segment sizes : \n"); + while (ip < iend) + { + unsigned nbBits = FUZ_rand(&randState) % maxBits; + size_t iSize = (FUZ_rand(&randState) & ((1<<nbBits)-1)) + 1; + size_t oSize = oend-op; + if (iSize > (size_t)(iend-ip)) iSize = iend-ip; + errorCode = LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, NULL); + if (LZ4F_isError(errorCode)) goto _output_error; + op += oSize; + ip += iSize; + } + DISPLAYLEVEL(3, "Skipped %i bytes \n", (int)decodedBufferSize); + errorCode = LZ4F_freeDecompressionContext(dCtx); if (LZ4F_isError(errorCode)) goto _output_error; } @@ -509,7 +528,7 @@ int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressi DISPLAYUPDATE(2, "\r%5u ", testNb); crcOrig = XXH64((BYTE*)srcBuffer+srcStart, srcSize, 1); - if ((FUZ_rand(&randState) & 0xFFF) == 3) + if ((FUZ_rand(&randState) & 0xFFF) == 0) { /* create a skippable frame (rare case) */ BYTE* op = (BYTE*)compressedBuffer; |