diff options
author | Yann Collet <cyan@fb.com> | 2022-07-15 11:05:43 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2022-07-15 11:05:43 (GMT) |
commit | 35d58a5ea7fccef9fd08fce6a5f5e6efda7daa57 (patch) | |
tree | 7e9ca36ae186874a52c87524c4d493cae8d70c5c /tests/decompress-partial-usingDict.c | |
parent | 1d17532d70d0b93032de4ada17c1787ee8939f15 (diff) | |
download | lz4-35d58a5ea7fccef9fd08fce6a5f5e6efda7daa57.zip lz4-35d58a5ea7fccef9fd08fce6a5f5e6efda7daa57.tar.gz lz4-35d58a5ea7fccef9fd08fce6a5f5e6efda7daa57.tar.bz2 |
fix decompress-partial-usingDict.c
The recently added test decompress-partial-usingDict
tends to fail for unknown reasons,
more frequently under the combination for clang-9 + `-mx32`.
There is a suspicion that the test is using too much stack.
Fixing that, + adding traces, to get more information if it fails again.
Diffstat (limited to 'tests/decompress-partial-usingDict.c')
-rw-r--r-- | tests/decompress-partial-usingDict.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/tests/decompress-partial-usingDict.c b/tests/decompress-partial-usingDict.c index cfcb971..8b85106 100644 --- a/tests/decompress-partial-usingDict.c +++ b/tests/decompress-partial-usingDict.c @@ -1,6 +1,7 @@ -#include "stdio.h" -#include "string.h" -#include "stdlib.h" +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <assert.h> #include "lz4.h" const char source[] = @@ -33,27 +34,35 @@ int main(void) size_t const smallSize = 1024; size_t const largeSize = 64 * 1024 - 1; char cmpBuffer[BUFFER_SIZE]; - char buffer[BUFFER_SIZE + largeSize]; + char* const buffer = (char*)malloc(BUFFER_SIZE + largeSize); char* outBuffer = buffer + largeSize; char* const dict = (char*)malloc(largeSize); char* const largeDict = dict; char* const smallDict = dict + largeSize - smallSize; - int cmpSize; int i; + int cmpSize; + + printf("starting test decompress-partial-usingDict : \n"); + assert(buffer != NULL); + assert(dict != NULL); cmpSize = LZ4_compress_default(source, cmpBuffer, srcLen, BUFFER_SIZE); for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, NULL, 0); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with no dict error \n"); return -1; } } - + for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, outBuffer - smallSize, smallSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with small prefix error \n"); return -1; } @@ -61,7 +70,9 @@ int main(void) for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, buffer, largeSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with large prefix error \n"); return -1; } @@ -69,7 +80,9 @@ int main(void) for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, smallDict, smallSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with small external dict error \n"); return -1; } @@ -77,7 +90,9 @@ int main(void) for (i = cmpSize; i < cmpSize + 10; ++i) { int result = LZ4_decompress_safe_partial_usingDict(cmpBuffer, outBuffer, i, srcLen, BUFFER_SIZE, largeDict, largeSize); - if ((result < 0) || (result != srcLen) || memcmp(source, outBuffer, srcLen)) { + if ( (result < 0) + || (result != srcLen) + || memcmp(source, outBuffer, (size_t)srcLen) ) { printf("test decompress-partial-usingDict with large external dict error \n"); return -1; } |