/tests programs compiled with LZ4_DEBUG=1

to enable assert() within /lib
This commit is contained in:
Yann Collet 2017-12-22 11:54:43 +01:00
parent 8a9c8e7324
commit fdde4311fb
2 changed files with 20 additions and 21 deletions

View File

@ -35,11 +35,12 @@ PRGDIR := ../programs
TESTDIR := versionsTest TESTDIR := versionsTest
PYTHON ?= python3 PYTHON ?= python3
DEBUGFLAGS = -g -DLZ4_DEBUG=1
CFLAGS ?= -O3 # can select custom optimization flags. For example : CFLAGS=-O2 make CFLAGS ?= -O3 # can select custom optimization flags. For example : CFLAGS=-O2 make
CFLAGS += -g -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \ CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \ -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
-Wpointer-arith -Wstrict-aliasing=1 -Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(MOREFLAGS) CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
CPPFLAGS:= -I$(LZ4DIR) -I$(PRGDIR) -DXXH_NAMESPACE=LZ4_ CPPFLAGS:= -I$(LZ4DIR) -I$(PRGDIR) -DXXH_NAMESPACE=LZ4_
FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)

View File

@ -898,7 +898,6 @@ static void FUZ_unitTests(int compressionLevel)
} }
dict = dst; dict = dst;
//dict = testInput + segStart;
dictSize = segSize; dictSize = segSize;
dst += segSize + 1; dst += segSize + 1;
@ -972,28 +971,27 @@ static void FUZ_unitTests(int compressionLevel)
#define BSIZE2 16435 #define BSIZE2 16435
/* first block */ /* first block */
messageSize = BSIZE1;
XXH64_update(&xxhOrig, testInput + iNext, messageSize);
crcOrig = XXH64_digest(&xxhOrig);
messageSize = BSIZE1; result = LZ4_compress_HC_continue(&sHC, testInput + iNext, testCompressed, messageSize, testCompressedSize-ringBufferSize);
XXH64_update(&xxhOrig, testInput + iNext, messageSize); FUZ_CHECKTEST(result==0, "LZ4_compressHC_limitedOutput_continue() compression failed");
crcOrig = XXH64_digest(&xxhOrig);
result = LZ4_compress_HC_continue(&sHC, testInput + iNext, testCompressed, messageSize, testCompressedSize-ringBufferSize); result = LZ4_decompress_safe_continue(&decodeState, testCompressed, testVerify + dNext, result, messageSize);
FUZ_CHECKTEST(result==0, "LZ4_compressHC_limitedOutput_continue() compression failed"); FUZ_CHECKTEST(result!=(int)messageSize, "64K D.ringBuffer : LZ4_decompress_safe() test failed");
result = LZ4_decompress_safe_continue(&decodeState, testCompressed, testVerify + dNext, result, messageSize); XXH64_update(&xxhNew, testVerify + dNext, messageSize);
FUZ_CHECKTEST(result!=(int)messageSize, "64K D.ringBuffer : LZ4_decompress_safe() test failed"); { U64 const crcNew = XXH64_digest(&xxhNew);
FUZ_CHECKTEST(crcOrig!=crcNew, "LZ4_decompress_safe() decompression corruption"); }
XXH64_update(&xxhNew, testVerify + dNext, messageSize); /* prepare next message */
{ U64 const crcNew = XXH64_digest(&xxhNew); dNext += messageSize;
FUZ_CHECKTEST(crcOrig!=crcNew, "LZ4_decompress_safe() decompression corruption"); } totalMessageSize += messageSize;
messageSize = BSIZE2;
/* prepare next message */ iNext = 132000;
dNext += messageSize; memcpy(testInput + iNext, testInput + 8, messageSize);
totalMessageSize += messageSize; if (dNext > dBufferSize) dNext = 0;
messageSize = BSIZE2;
iNext = 132000;
memcpy(testInput + iNext, testInput + 8, messageSize);
if (dNext > dBufferSize) dNext = 0;
while (totalMessageSize < 9 MB) { while (totalMessageSize < 9 MB) {
XXH64_update(&xxhOrig, testInput + iNext, messageSize); XXH64_update(&xxhOrig, testInput + iNext, messageSize);