diff options
author | Yann Collet <yann.collet.73@gmail.com> | 2014-11-04 09:04:37 (GMT) |
---|---|---|
committer | Yann Collet <yann.collet.73@gmail.com> | 2014-11-04 09:04:37 (GMT) |
commit | 7050d4b7672f164144f0cef0a95aa68ad71cf9e6 (patch) | |
tree | 29d5bcceddadf0c5e5c44c1a41b798fa4e353c0a /programs | |
parent | 3de7f00a0b83f0f8ad861789d8da1ad697b1f05a (diff) | |
download | lz4-7050d4b7672f164144f0cef0a95aa68ad71cf9e6.zip lz4-7050d4b7672f164144f0cef0a95aa68ad71cf9e6.tar.gz lz4-7050d4b7672f164144f0cef0a95aa68ad71cf9e6.tar.bz2 |
Updated unsynchronized buffers tests
Diffstat (limited to 'programs')
-rw-r--r-- | programs/fuzzer.c | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/programs/fuzzer.c b/programs/fuzzer.c index 3a2ec34..17f7c43 100644 --- a/programs/fuzzer.c +++ b/programs/fuzzer.c @@ -663,8 +663,8 @@ _output_error: } -#define testInputSize (128 KB) -#define testCompressedSize (64 KB) +#define testInputSize (192 KB) +#define testCompressedSize (128 KB) #define ringBufferSize (8 KB) static void FUZ_unitTests(void) @@ -786,15 +786,15 @@ static void FUZ_unitTests(void) FUZ_CHECKTEST(result==0, "LZ4_compressHC_limitedOutput_continue() dictionary compression failed : result = %i", result); result = LZ4_decompress_safe_usingDict(testCompressed, testVerify, result, testCompressedSize, testInput, 64 KB); - FUZ_CHECKTEST(result!=(int)testCompressedSize, "LZ4_decompress_safe() dictionary decompression failed"); + FUZ_CHECKTEST(result!=(int)testCompressedSize, "LZ4_decompress_safe() simple dictionary decompression test failed"); crcNew = XXH64(testVerify, testCompressedSize, 0); - FUZ_CHECKTEST(crcOrig!=crcNew, "LZ4_decompress_safe() dictionary decompression corruption"); + FUZ_CHECKTEST(crcOrig!=crcNew, "LZ4_decompress_safe() simple dictionary decompression test : corruption"); // multiple HC compression test with dictionary { int result1, result2; int segSize = testCompressedSize / 2; - crcOrig = XXH64(testInput + segSize, 64 KB, 0); + crcOrig = XXH64(testInput + segSize, testCompressedSize, 0); LZ4_resetStreamHC(&sHC, 0); LZ4_loadDictHC(&sHC, testInput, segSize); result1 = LZ4_compressHC_limitedOutput_continue(&sHC, testInput + segSize, testCompressed, segSize, segSize -1); @@ -915,6 +915,48 @@ static void FUZ_unitTests(void) } } + // small decoder-side ring buffer test + { + XXH64_state_t xxhOrig; + XXH64_state_t xxhNew; + LZ4_streamDecode_t decodeState; + const U32 maxMessageSizeLog = 10; + const U32 maxMessageSizeMask = (1<<maxMessageSizeLog) - 1; + U32 messageSize = (FUZ_rand(&randState) & maxMessageSizeMask) + 1; + U32 totalMessageSize = 0; + U32 iNext = 0; + U32 dNext = 0; + const U32 dBufferSize = 64 KB + maxMessageSizeMask; + + XXH64_reset(&xxhOrig, 0); + XXH64_reset(&xxhNew, 0); + LZ4_resetStreamHC(&sHC, 0); + LZ4_setStreamDecode(&decodeState, NULL, 0); + + while (totalMessageSize < 9 MB) + { + XXH64_update(&xxhOrig, testInput + iNext, messageSize); + crcOrig = XXH64_digest(&xxhOrig); + + result = LZ4_compressHC_limitedOutput_continue(&sHC, testInput + iNext, testCompressed, messageSize, testCompressedSize-ringBufferSize); + FUZ_CHECKTEST(result==0, "LZ4_compressHC_limitedOutput_continue() compression failed"); + + result = LZ4_decompress_safe_continue(&decodeState, testCompressed, testVerify + dNext, result, messageSize); + FUZ_CHECKTEST(result!=(int)messageSize, "ringBuffer : LZ4_decompress_safe() test failed"); + + XXH64_update(&xxhNew, testVerify + dNext, messageSize); + crcNew = crcOrig = XXH64_digest(&xxhNew); + FUZ_CHECKTEST(crcOrig!=crcNew, "LZ4_decompress_safe() decompression corruption"); + + // prepare next message + dNext += messageSize; + totalMessageSize += messageSize; + messageSize = (FUZ_rand(&randState) & maxMessageSizeMask) + 1; + iNext = (FUZ_rand(&randState) & 65535); + if (dNext + messageSize > dBufferSize) dNext = 0; + } + } + // long stream test ; Warning : very long test ! if (1) { @@ -939,6 +981,9 @@ static void FUZ_unitTests(void) FUZ_displayUpdate((U32)(totalTestDone >> 20)); + if (testStart == oldStart + oldSize) // Corner case not covered by this test (LZ4_decompress_safe_usingDict() limitation) + testStart++; + XXH64_update(&crcOrigState, testInput + testStart, testSize); crcOrig = XXH64_digest(&crcOrigState); |