summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile83
-rw-r--r--tests/datagencli.c20
-rw-r--r--tests/frametest.c33
-rw-r--r--tests/fullbench.c63
-rw-r--r--tests/fuzzer.c64
5 files changed, 106 insertions, 157 deletions
diff --git a/tests/Makefile b/tests/Makefile
index e58d449..97fa782 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -38,12 +38,12 @@ VOID := /dev/null
TESTDIR := versionsTest
PYTHON ?= python3
-CFLAGS ?= -O3 # can select custom flags. For example : CFLAGS="-O2 -g" make
+CFLAGS ?= -O3 # can select custom optimization flags. For example : CFLAGS=-O2 make
CFLAGS += -g -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow -Wswitch-enum \
-Wdeclaration-after-statement -Wstrict-prototypes \
-Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(MOREFLAGS)
-CPPFLAGS:= -I$(LIBDIR) -DXXH_NAMESPACE=LZ4_
+CPPFLAGS:= -I$(LIBDIR) -I$(PRGDIR) -DXXH_NAMESPACE=LZ4_
FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
@@ -120,15 +120,21 @@ versionsTest:
#------------------------------------------------------------------------
-#make install is validated only for Linux, OSX, kFreeBSD, Hurd and
-#FreeBSD targets
-ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD))
+#make test is validated only for Linux, OSX, kFreeBSD, FreeBSD, Hurd and
+#Solaris targets
+ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
MD5:=md5sum
ifneq (,$(filter $(shell uname), Darwin ))
MD5:=md5 -r
endif
+DIFF:=diff
+ifneq (,$(filter $(shell uname),SunOS))
+DIFF:=gdiff
+endif
+
+
test: test-lz4 test-lz4c test-fasttest test-frametest test-fullbench test-fuzzer
test32: CFLAGS+=-m32
@@ -138,18 +144,18 @@ test-lz4-sparse: lz4 datagen
@echo "\n ---- test sparse file support ----"
./datagen -g5M -P100 > tmpSrc
$(LZ4) -B4D tmpSrc | $(LZ4) -dv --sparse > tmpB4
- diff -s tmpSrc tmpB4
+ $(DIFF) -s tmpSrc tmpB4
$(LZ4) -B5D tmpSrc | $(LZ4) -dv --sparse > tmpB5
- diff -s tmpSrc tmpB5
+ $(DIFF) -s tmpSrc tmpB5
$(LZ4) -B6D tmpSrc | $(LZ4) -dv --sparse > tmpB6
- diff -s tmpSrc tmpB6
+ $(DIFF) -s tmpSrc tmpB6
$(LZ4) -B7D tmpSrc | $(LZ4) -dv --sparse > tmpB7
- diff -s tmpSrc tmpB7
+ $(DIFF) -s tmpSrc tmpB7
$(LZ4) tmpSrc | $(LZ4) -dv --no-sparse > tmpNoSparse
- diff -s tmpSrc tmpNoSparse
+ $(DIFF) -s tmpSrc tmpNoSparse
ls -ls tmp*
./datagen -s1 -g1200007 -P100 | $(LZ4) | $(LZ4) -dv --sparse > tmpOdd # Odd size file (to generate non-full last block)
- ./datagen -s1 -g1200007 -P100 | diff -s - tmpOdd
+ ./datagen -s1 -g1200007 -P100 | $(DIFF) -s - tmpOdd
ls -ls tmpOdd
@$(RM) tmp*
@echo "\n Compatibility with Console :"
@@ -163,7 +169,7 @@ test-lz4-sparse: lz4 datagen
$(LZ4) -d -v tmpC tmpR
$(LZ4) -d -v tmpC >> tmpR
ls -ls tmp*
- diff tmp2M tmpR
+ $(DIFF) tmp2M tmpR
@$(RM) tmp*
test-lz4-contentSize: lz4 datagen
@@ -171,13 +177,13 @@ test-lz4-contentSize: lz4 datagen
./datagen -g15M > tmp
$(LZ4) -v tmp | $(LZ4) -t
$(LZ4) -v --content-size tmp | $(LZ4) -d > tmp2
- diff -s tmp tmp2
+ $(DIFF) -s tmp tmp2
# test large size [2-4] GB
- @./datagen -g3G -P100 | $(LZ4) --verbose | $(LZ4) --decompress --force --sparse - tmp
+ @./datagen -g3G -P100 | $(LZ4) -vv | $(LZ4) --decompress --force --sparse - tmp
@ls -ls tmp
@./datagen -g3G -P100 | $(LZ4) --quiet --content-size | $(LZ4) --verbose --decompress --force --sparse - tmp2
@ls -ls tmp2
- diff -s tmp tmp2
+ $(DIFF) -s tmp tmp2
@$(RM) tmp*
test-lz4-frame-concatenation: lz4 datagen
@@ -206,20 +212,44 @@ test-lz4-multiple: lz4 datagen
$(LZ4) -f -m tmp1 notHere tmp2; echo $$?
@$(RM) tmp*
-test-lz4-basic: lz4 datagen
+unlz4:
+ @$(MAKE) -C $(PRGDIR) $@ CFLAGS="$(CFLAGS)"
+
+lz4cat:
+ @$(MAKE) -C $(PRGDIR) $@ CFLAGS="$(CFLAGS)"
+
+test-lz4-basic: lz4 datagen unlz4 lz4cat
@echo "\n ---- test lz4 basic compression/decompression ----"
./datagen -g0 | $(LZ4) -v | $(LZ4) -t
./datagen -g16KB | $(LZ4) -9 | $(LZ4) -t
./datagen -g20KB > tmpSrc
- $(LZ4) < tmpSrc | $(LZ4) -d > tmpRes
- diff -q tmpSrc tmpRes
+ $(LZ4) < tmpSrc | $(LZ4) -d > tmpRes
+ $(DIFF) -q tmpSrc tmpRes
$(LZ4) --no-frame-crc < tmpSrc | $(LZ4) -d > tmpRes
- diff -q tmpSrc tmpRes
+ $(DIFF) -q tmpSrc tmpRes
./datagen | $(LZ4) | $(LZ4) -t
./datagen -g6M -P99 | $(LZ4) -9BD | $(LZ4) -t
./datagen -g17M | $(LZ4) -9v | $(LZ4) -qt
./datagen -g33M | $(LZ4) --no-frame-crc | $(LZ4) -t
./datagen -g256MB | $(LZ4) -vqB4D | $(LZ4) -t
+ @echo "hello world" > tmp
+ $(LZ4) --rm -f tmp
+ ls -ls tmp && false || true # must fail (--rm)
+ ls -ls tmp.lz4
+ $(PRGDIR)/lz4cat tmp.lz4 # must display hello world
+ ls -ls tmp.lz4
+ $(PRGDIR)/unlz4 --rm tmp.lz4
+ ls -ls tmp
+ ls -ls tmp.lz4 && false || true # must fail (--rm)
+ ls -ls tmp.lz4.lz4 && false || true # must fail (unlz4)
+ $(PRGDIR)/lz4cat tmp # pass-through mode
+ ls -ls tmp
+ ls -ls tmp.lz4 && false || true # must fail (lz4cat)
+ $(LZ4) tmp # creates tmp.lz4
+ $(PRGDIR)/lz4cat < tmp.lz4 > tmp3 # checks lz4cat works with stdin (#285)
+ $(DIFF) -q tmp tmp3
+ $(PRGDIR)/lz4cat < tmp > tmp2 # checks lz4cat works with stdin (#285)
+ $(DIFF) -q tmp tmp2
@$(RM) tmp*
test-lz4-hugefile: lz4 datagen
@@ -247,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/datagencli.c b/tests/datagencli.c
index 0b78d37..c985197 100644
--- a/tests/datagencli.c
+++ b/tests/datagencli.c
@@ -27,31 +27,13 @@
/**************************************
* Includes
**************************************/
+#include "util.h" /* U32 */
#include <stdio.h> /* fprintf, stderr */
#include "datagen.h" /* RDG_generate */
#include "lz4.h" /* LZ4_VERSION_STRING */
/**************************************
-* Basic Types
-**************************************/
-#if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */
-# include <stdint.h>
- typedef uint8_t BYTE;
- typedef uint16_t U16;
- typedef uint32_t U32;
- typedef int32_t S32;
- typedef uint64_t U64;
-#else
- typedef unsigned char BYTE;
- typedef unsigned short U16;
- typedef unsigned int U32;
- typedef signed int S32;
- typedef unsigned long long U64;
-#endif
-
-
-/**************************************
* Constants
**************************************/
#define KB *(1 <<10)
diff --git a/tests/frametest.c b/tests/frametest.c
index a99728f..e2e0f86 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -35,6 +35,7 @@
/*-************************************
* Includes
**************************************/
+#include "util.h" /* U32 */
#include <stdlib.h> /* malloc, free */
#include <stdio.h> /* fprintf */
#include <string.h> /* strcmp */
@@ -45,25 +46,6 @@
#include "xxhash.h" /* XXH64 */
-/*-************************************
-* Basic Types
-**************************************/
-#if !defined(__VMS) && (defined (__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */) )
-# include <stdint.h>
-typedef uint8_t BYTE;
-typedef uint16_t U16;
-typedef uint32_t U32;
-typedef int32_t S32;
-typedef uint64_t U64;
-#else
-typedef unsigned char BYTE;
-typedef unsigned short U16;
-typedef unsigned int U32;
-typedef signed int S32;
-typedef unsigned long long U64;
-#endif
-
-
/* unoptimized version; solves endianess & alignment issues */
static void FUZ_writeLE32 (void* dstVoidPtr, U32 value32)
{
@@ -110,7 +92,7 @@ static clock_t g_clockTime = 0;
*****************************************/
static U32 no_prompt = 0;
static U32 displayLevel = 2;
-static U32 pause = 0;
+static U32 use_pause = 0;
/*-*******************************************************
@@ -204,6 +186,13 @@ int basicTests(U32 seed, double compressibility)
FUZ_fillCompressibleNoiseBuffer(CNBuffer, COMPRESSIBLE_NOISE_LENGTH, compressibility, &randState);
crcOrig = XXH64(CNBuffer, COMPRESSIBLE_NOISE_LENGTH, 1);
+ /* LZ4F_compressBound() : special case : srcSize == 0 */
+ DISPLAYLEVEL(3, "LZ4F_compressBound(0) = ");
+ { size_t const cBound = LZ4F_compressBound(0, NULL);
+ if (cBound < 64 KB) goto _output_error;
+ DISPLAYLEVEL(3, " %u \n", (U32)cBound);
+ }
+
/* Special case : null-content frame */
testSize = 0;
DISPLAYLEVEL(3, "LZ4F_compressFrame, compress null content : \n");
@@ -723,7 +712,7 @@ _end:
free(compressedBuffer);
free(decodedBuffer);
- if (pause) {
+ if (use_pause) {
DISPLAY("press enter to finish \n");
(void)getchar();
}
@@ -795,7 +784,7 @@ int main(int argc, const char** argv)
break;
case 'p': /* pause at the end */
argument++;
- pause = 1;
+ use_pause = 1;
break;
case 'i':
diff --git a/tests/fullbench.c b/tests/fullbench.c
index 7d54492..f489392 100644
--- a/tests/fullbench.c
+++ b/tests/fullbench.c
@@ -23,20 +23,6 @@
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
*/
-/**************************************
-* Compiler Options
-**************************************/
-/* Disable some Visual warning messages */
-#define _CRT_SECURE_NO_WARNINGS
-#define _CRT_SECURE_NO_DEPRECATE /* VS2005 */
-
-/* Unix Large Files support (>4GB) */
-#if (defined(__sun__) && (!defined(__LP64__))) // Sun Solaris 32-bits requires specific definitions
-# define _LARGEFILE_SOURCE
-# define _FILE_OFFSET_BITS 64
-#elif ! defined(__LP64__) // No point defining Large file for 64 bit
-# define _LARGEFILE64_SOURCE
-#endif
// S_ISREG & gettimeofday() are not supported by MSVC
#if defined(_MSC_VER) || defined(_WIN32)
@@ -47,8 +33,10 @@
/**************************************
* Includes
**************************************/
+#include "platform.h" /* _CRT_SECURE_NO_WARNINGS, Large Files support */
+#include "util.h" /* U32, UTIL_getFileSize */
#include <stdlib.h> /* malloc, free */
-#include <stdio.h> /* fprintf, fopen, ftello64 */
+#include <stdio.h> /* fprintf, fopen, ftello */
#include <sys/types.h> /* stat64 */
#include <sys/stat.h> /* stat64 */
#include <string.h> /* strcmp */
@@ -62,34 +50,6 @@
/**************************************
-* Compiler Options
-**************************************/
-/* S_ISREG & gettimeofday() are not supported by MSVC */
-#if !defined(S_ISREG)
-# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
-#endif
-
-
-/**************************************
-* Basic Types
-**************************************/
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */
-# include <stdint.h>
- typedef uint8_t BYTE;
- typedef uint16_t U16;
- typedef uint32_t U32;
- typedef int32_t S32;
- typedef uint64_t U64;
-#else
- typedef unsigned char BYTE;
- typedef unsigned short U16;
- typedef unsigned int U32;
- typedef signed int S32;
- typedef unsigned long long U64;
-#endif
-
-
-/**************************************
* Constants
**************************************/
#define PROGRAM_DESCRIPTION "LZ4 speed analyzer"
@@ -194,21 +154,6 @@ static size_t BMK_findMaxMem(U64 requiredMem)
}
-static U64 BMK_GetFileSize(const char* infilename)
-{
- int r;
-#if defined(_MSC_VER)
- struct _stat64 statbuf;
- r = _stat64(infilename, &statbuf);
-#else
- struct stat statbuf;
- r = stat(infilename, &statbuf);
-#endif
- if (r || !S_ISREG(statbuf.st_mode)) return 0; /* No good... */
- return (U64)statbuf.st_size;
-}
-
-
/*********************************************************
* Benchmark function
*********************************************************/
@@ -398,7 +343,7 @@ int fullSpeedBench(const char** fileNamesTable, int nbFiles)
if (inFile==NULL) { DISPLAY( "Pb opening %s\n", inFileName); return 11; }
/* Memory size adjustments */
- inFileSize = BMK_GetFileSize(inFileName);
+ inFileSize = UTIL_getFileSize(inFileName);
if (inFileSize==0) { DISPLAY( "file is empty\n"); fclose(inFile); return 11; }
benchedSize = BMK_findMaxMem(inFileSize*2) / 2; /* because 2 buffers */
if (benchedSize==0) { DISPLAY( "not enough memory\n"); fclose(inFile); return 11; }
diff --git a/tests/fuzzer.c b/tests/fuzzer.c
index 06cfd40..b129c96 100644
--- a/tests/fuzzer.c
+++ b/tests/fuzzer.c
@@ -27,7 +27,6 @@
* Compiler options
**************************************/
#ifdef _MSC_VER /* Visual Studio */
-# define _CRT_SECURE_NO_WARNINGS /* fgets */
# pragma warning(disable : 4127) /* disable: C4127: conditional expression is constant */
# pragma warning(disable : 4146) /* disable: C4146: minus unsigned expression */
# pragma warning(disable : 4310) /* disable: C4310: constant char value > 127 */
@@ -37,6 +36,8 @@
/*-************************************
* Dependencies
**************************************/
+#include "platform.h" /* _CRT_SECURE_NO_WARNINGS */
+#include "util.h" /* U32 */
#include <stdlib.h>
#include <stdio.h> /* fgets, sscanf */
#include <string.h> /* strcmp */
@@ -49,19 +50,7 @@
/*-************************************
* Basic Types
**************************************/
-#if defined(__cplusplus) || (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
-# include <stdint.h>
-typedef uint8_t BYTE;
-typedef uint16_t U16;
-typedef uint32_t U32;
-typedef int32_t S32;
-typedef uint64_t U64;
-#else
-typedef unsigned char BYTE;
-typedef unsigned short U16;
-typedef unsigned int U32;
-typedef signed int S32;
-typedef unsigned long long U64;
+#if !defined(__cplusplus) && !(defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 */)
typedef size_t uintptr_t; /* true on most systems, except OpenVMS-64 (which doesn't need address overflow test) */
#endif
@@ -314,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;
@@ -360,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 */
@@ -477,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 */
@@ -502,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)
}
@@ -603,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");
@@ -611,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);
@@ -666,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;
@@ -761,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");
@@ -772,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);
@@ -786,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);
@@ -803,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);
@@ -824,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);
@@ -870,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) {
@@ -912,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
@@ -967,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);
@@ -1000,7 +990,7 @@ int main(int argc, const char** argv)
int nbTests = NB_ATTEMPTS;
int testNb = 0;
int proba = FUZ_COMPRESSIBILITY_DEFAULT;
- int pause = 0;
+ int use_pause = 0;
const char* programName = argv[0];
U32 duration = 0;
@@ -1012,7 +1002,7 @@ int main(int argc, const char** argv)
// Decode command (note : aggregated commands are allowed)
if (argument[0]=='-') {
- if (!strcmp(argument, "--no-prompt")) { pause=0; seedset=1; g_displayLevel=1; continue; }
+ if (!strcmp(argument, "--no-prompt")) { use_pause=0; seedset=1; g_displayLevel=1; continue; }
argument++;
while (*argument!=0) {
@@ -1028,7 +1018,7 @@ int main(int argc, const char** argv)
case 'p': /* pause at the end */
argument++;
- pause=1;
+ use_pause=1;
break;
case 'i':
@@ -1102,7 +1092,7 @@ int main(int argc, const char** argv)
}
}
- printf("Starting LZ4 fuzzer (%i-bits, v%s)\n", (int)(sizeof(size_t)*8), LZ4_VERSION_STRING);
+ printf("Starting LZ4 fuzzer (%i-bits, v%s)\n", (int)(sizeof(size_t)*8), LZ4_versionString());
if (!seedset) {
time_t const t = time(NULL);
@@ -1113,12 +1103,12 @@ 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;
{ int const result = FUZ_test(seed, nbTests, testNb, ((double)proba) / 100, duration);
- if (pause) {
+ if (use_pause) {
DISPLAY("press enter ... \n");
(void)getchar();
}