summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Collet <Cyan4973@users.noreply.github.com>2016-12-28 23:44:40 (GMT)
committerGitHub <noreply@github.com>2016-12-28 23:44:40 (GMT)
commit8c4de60d0f871f8e81986b2c61b70e1bcb8b97fd (patch)
tree449787dd6756fc32d0e460243a6b830015cb5d69 /tests
parent581da2bf8096fcfeea18baf5d606ffb36737583c (diff)
parentd2b51c22d300ff67ef3cd91b905a4c35ff876515 (diff)
downloadlz4-8c4de60d0f871f8e81986b2c61b70e1bcb8b97fd.zip
lz4-8c4de60d0f871f8e81986b2c61b70e1bcb8b97fd.tar.gz
lz4-8c4de60d0f871f8e81986b2c61b70e1bcb8b97fd.tar.bz2
Merge pull request #295 from inikep/opt-parser
Opt parser
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile15
-rw-r--r--tests/fuzzer.c37
2 files changed, 33 insertions, 19 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 1b92718..97fa782 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -277,7 +277,20 @@ test-lz4-testmode: lz4 datagen
$(LZ4) -fm file1-dne file2-dne && false || true
$(LZ4) -fm file1-dne file2-dne && false || true
-test-lz4: lz4 datagen test-lz4-basic test-lz4-multiple test-lz4-sparse \
+test-lz4-opt-parser: lz4 datagen
+ @echo "\n ---- test opt-parser ----"
+ ./datagen -g16KB | $(LZ4) -12 | $(LZ4) -t
+ ./datagen -P10 | $(LZ4) -12B4 | $(LZ4) -t
+ ./datagen -g256K | $(LZ4) -12B4D | $(LZ4) -t
+ ./datagen -g512K -P25 | $(LZ4) -12BD | $(LZ4) -t
+ ./datagen -g1M | $(LZ4) -12B5 | $(LZ4) -t
+ ./datagen -g2M -P99 | $(LZ4) -11B4D | $(LZ4) -t
+ ./datagen -g4M | $(LZ4) -11vq | $(LZ4) -qt
+ ./datagen -g8M | $(LZ4) -11B4 | $(LZ4) -t
+ ./datagen -g16M -P90 | $(LZ4) -11B5 | $(LZ4) -t
+ ./datagen -g32M -P10 | $(LZ4) -11B5D | $(LZ4) -t
+
+test-lz4: lz4 datagen test-lz4-opt-parser test-lz4-basic test-lz4-multiple test-lz4-sparse \
test-lz4-frame-concatenation test-lz4-testmode test-lz4-contentSize \
test-lz4-hugefile
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index ff02e0c..b129c96 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -303,6 +303,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
int const blockStart = FUZ_rand(&randState) % (COMPRESSIBLE_NOISE_LENGTH - blockSize);
int const dictSizeRand = FUZ_rand(&randState) % FUZ_MAX_DICT_SIZE;
int const dictSize = MIN(dictSizeRand, blockStart);
+ int const compressionLevel = FUZ_rand(&randState) % (LZ4HC_CLEVEL_MAX+1);
char* const block = ((char*)CNBuffer) + blockStart;
const char* dict = block - dictSize;
int compressedSize, HCcompressedSize;
@@ -349,18 +350,18 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
/* Test compression HC */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_HC(block, compressedBuffer, blockSize, (int)compressedBufferSize, 9);
+ ret = LZ4_compress_HC(block, compressedBuffer, blockSize, (int)compressedBufferSize, compressionLevel);
FUZ_CHECKTEST(ret==0, "LZ4_compressHC() failed");
HCcompressedSize = ret;
/* Test compression HC using external state */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, (int)compressedBufferSize, 9);
+ ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, (int)compressedBufferSize, compressionLevel);
FUZ_CHECKTEST(ret==0, "LZ4_compressHC_withStateHC() failed");
/* Test compression using external state */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_fast_extState(stateLZ4, block, compressedBuffer, blockSize, (int)compressedBufferSize, 9);
+ ret = LZ4_compress_fast_extState(stateLZ4, block, compressedBuffer, blockSize, (int)compressedBufferSize, 8);
FUZ_CHECKTEST(ret==0, "LZ4_compress_withState() failed");
/* Test compression */
@@ -466,12 +467,12 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
/* Test HC compression with output size being exactly what's necessary (should work) */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_HC(block, compressedBuffer, blockSize, HCcompressedSize, 9);
+ ret = LZ4_compress_HC(block, compressedBuffer, blockSize, HCcompressedSize, compressionLevel);
FUZ_CHECKTEST(ret==0, "LZ4_compressHC_limitedOutput() failed despite sufficient space");
/* Test HC compression with output size being exactly what's necessary (should work) */
FUZ_DISPLAYTEST;
- ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, HCcompressedSize, 9);
+ ret = LZ4_compress_HC_extStateHC(stateLZ4HC, block, compressedBuffer, blockSize, HCcompressedSize, compressionLevel);
FUZ_CHECKTEST(ret==0, "LZ4_compressHC_limitedOutput_withStateHC() failed despite sufficient space");
/* Test compression with missing bytes into output buffer => must fail */
@@ -491,7 +492,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
if (missingBytes >= HCcompressedSize) missingBytes = HCcompressedSize-1;
missingBytes += !missingBytes; /* avoid special case missingBytes==0 */
compressedBuffer[HCcompressedSize-missingBytes] = 0;
- ret = LZ4_compress_HC(block, compressedBuffer, blockSize, HCcompressedSize-missingBytes, 9);
+ ret = LZ4_compress_HC(block, compressedBuffer, blockSize, HCcompressedSize-missingBytes, compressionLevel);
FUZ_CHECKTEST(ret, "LZ4_compressHC_limitedOutput should have failed (output buffer too small by %i byte)", missingBytes);
FUZ_CHECKTEST(compressedBuffer[HCcompressedSize-missingBytes], "LZ4_compressHC_limitedOutput overran output buffer ! (%i missingBytes)", missingBytes)
}
@@ -592,7 +593,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
FUZ_DISPLAYTEST;
dict -= (FUZ_rand(&randState) & 7); /* even bigger separation */
if (dict < (char*)CNBuffer) dict = (char*)CNBuffer;
- LZ4_resetStreamHC (&LZ4dictHC, FUZ_rand(&randState) & 0x7);
+ LZ4_resetStreamHC (&LZ4dictHC, compressionLevel);
LZ4_loadDictHC(&LZ4dictHC, dict, dictSize);
blockContinueCompressedSize = LZ4_compress_HC_continue(&LZ4dictHC, block, compressedBuffer, blockSize, (int)compressedBufferSize);
FUZ_CHECKTEST(blockContinueCompressedSize==0, "LZ4_compressHC_continue failed");
@@ -600,7 +601,7 @@ static int FUZ_test(U32 seed, U32 nbCycles, const U32 startCycle, const double c
FUZ_DISPLAYTEST;
LZ4_loadDictHC(&LZ4dictHC, dict, dictSize);
ret = LZ4_compress_HC_continue(&LZ4dictHC, block, compressedBuffer, blockSize, blockContinueCompressedSize-1);
- FUZ_CHECKTEST(ret>0, "LZ4_compressHC_limitedOutput_continue using ExtDict should fail : one missing byte for output buffer");
+ FUZ_CHECKTEST(ret>0, "LZ4_compressHC_limitedOutput_continue using ExtDict should fail : one missing byte for output buffer (%i != %i)", ret, blockContinueCompressedSize);
FUZ_DISPLAYTEST;
LZ4_loadDictHC(&LZ4dictHC, dict, dictSize);
@@ -655,7 +656,7 @@ _output_error:
#define testCompressedSize (128 KB)
#define ringBufferSize (8 KB)
-static void FUZ_unitTests(void)
+static void FUZ_unitTests(int compressionLevel)
{
const unsigned testNb = 0;
const unsigned seed = 0;
@@ -750,7 +751,7 @@ static void FUZ_unitTests(void)
/* simple HC compression test */
crcOrig = XXH64(testInput, testCompressedSize, 0);
- LZ4_resetStreamHC(&sHC, 0);
+ LZ4_resetStreamHC(&sHC, compressionLevel);
result = LZ4_compress_HC_continue(&sHC, testInput, testCompressed, testCompressedSize, testCompressedSize-1);
FUZ_CHECKTEST(result==0, "LZ4_compressHC_limitedOutput_continue() compression failed");
@@ -761,7 +762,7 @@ static void FUZ_unitTests(void)
/* simple dictionary HC compression test */
crcOrig = XXH64(testInput + 64 KB, testCompressedSize, 0);
- LZ4_resetStreamHC(&sHC, 0);
+ LZ4_resetStreamHC(&sHC, compressionLevel);
LZ4_loadDictHC(&sHC, testInput, 64 KB);
result = LZ4_compress_HC_continue(&sHC, testInput + 64 KB, testCompressed, testCompressedSize, testCompressedSize-1);
FUZ_CHECKTEST(result==0, "LZ4_compressHC_limitedOutput_continue() dictionary compression failed : result = %i", result);
@@ -775,7 +776,7 @@ static void FUZ_unitTests(void)
{ int result1, result2;
int segSize = testCompressedSize / 2;
crcOrig = XXH64(testInput + segSize, testCompressedSize, 0);
- LZ4_resetStreamHC(&sHC, 0);
+ LZ4_resetStreamHC(&sHC, compressionLevel);
LZ4_loadDictHC(&sHC, testInput, segSize);
result1 = LZ4_compress_HC_continue(&sHC, testInput + segSize, testCompressed, segSize, segSize -1);
FUZ_CHECKTEST(result1==0, "LZ4_compressHC_limitedOutput_continue() dictionary compression failed : result = %i", result1);
@@ -792,7 +793,7 @@ static void FUZ_unitTests(void)
/* remote dictionary HC compression test */
crcOrig = XXH64(testInput + 64 KB, testCompressedSize, 0);
- LZ4_resetStreamHC(&sHC, 0);
+ LZ4_resetStreamHC(&sHC, compressionLevel);
LZ4_loadDictHC(&sHC, testInput, 32 KB);
result = LZ4_compress_HC_continue(&sHC, testInput + 64 KB, testCompressed, testCompressedSize, testCompressedSize-1);
FUZ_CHECKTEST(result==0, "LZ4_compressHC_limitedOutput_continue() remote dictionary failed : result = %i", result);
@@ -813,7 +814,7 @@ static void FUZ_unitTests(void)
int segSize = (FUZ_rand(&randState) & 8191);
int segNb = 1;
- LZ4_resetStreamHC(&sHC, 0);
+ LZ4_resetStreamHC(&sHC, compressionLevel);
LZ4_loadDictHC(&sHC, dict, dictSize);
XXH64_reset(&crcOrigState, 0);
@@ -859,7 +860,7 @@ static void FUZ_unitTests(void)
XXH64_reset(&xxhOrig, 0);
XXH64_reset(&xxhNew, 0);
- LZ4_resetStreamHC(&sHC, 0);
+ LZ4_resetStreamHC(&sHC, compressionLevel);
LZ4_setStreamDecode(&decodeState, NULL, 0);
while (iNext + messageSize < testCompressedSize) {
@@ -901,7 +902,7 @@ static void FUZ_unitTests(void)
XXH64_reset(&xxhOrig, 0);
XXH64_reset(&xxhNew, 0);
- LZ4_resetStreamHC(&sHC, 0);
+ LZ4_resetStreamHC(&sHC, compressionLevel);
LZ4_setStreamDecode(&decodeState, NULL, 0);
#define BSIZE1 65537
@@ -956,7 +957,7 @@ static void FUZ_unitTests(void)
}
}
- printf("All unit tests completed successfully \n");
+ printf("All unit tests completed successfully compressionLevel=%d \n", compressionLevel);
return;
_output_error:
exit(1);
@@ -1102,7 +1103,7 @@ int main(int argc, const char** argv)
if (proba!=FUZ_COMPRESSIBILITY_DEFAULT) printf("Compressibility : %i%%\n", proba);
- if ((seedset==0) && (testNb==0)) FUZ_unitTests();
+ if ((seedset==0) && (testNb==0)) { FUZ_unitTests(LZ4HC_CLEVEL_DEFAULT); FUZ_unitTests(LZ4HC_CLEVEL_OPT_MIN); }
if (nbTests<=0) nbTests=1;