From 4f984e45a5a36c446d959e1c790d90cef5d5dcb8 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 31 Jan 2022 14:51:20 -0800 Subject: added target test-compile-with-lz4-memory-usage and run it in GA CI --- .github/workflows/ci.yml | 10 ++++++++-- lib/lz4.h | 9 +++++---- lib/lz4hc.c | 2 ++ tests/Makefile | 8 ++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c0afb1..fe9f479 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -236,6 +236,13 @@ jobs: - name: LZ4 frame test (32-bit) run: make V=1 -C tests test-frametest32 + lz4-memory-usage: + name: test different values of LZ4_MEMORY_USAGE + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 # https://github.com/actions/checkout + - name: LZ4_MEMORY_USAGE + run: make V=1 -C tests test-compile-with-lz4-memory-usage # Custom LZ4_DISTANCE_MAX ; lz4-wlib (CLI linked to dynamic library); LZ4_USER_MEMORY_FUNCTIONS lz4-custom-distance: @@ -244,7 +251,7 @@ jobs: steps: - uses: actions/checkout@v2 # https://github.com/actions/checkout - - name: custom LZ4_DISTANCE_MAX + - name: custom LZ4_DISTANCE_MAX; test LZ4_USER_MEMORY_FUNCTIONS run: | MOREFLAGS='-DLZ4_DISTANCE_MAX=8000' make V=1 check make V=1 clean @@ -392,7 +399,6 @@ jobs: - name: unicode lint run: bash ./tests/unicode_lint.sh - lz4-examples: name: make examples runs-on: ubuntu-latest diff --git a/lib/lz4.h b/lib/lz4.h index 50f1d7a..7c401f6 100644 --- a/lib/lz4.h +++ b/lib/lz4.h @@ -116,6 +116,10 @@ LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; /*-************************************ * Tuning parameter **************************************/ +#define LZ4_MEMORY_USAGE_MIN 10 +#define LZ4_MEMORY_USAGE_DEFAULT 14 +#define LZ4_MEMORY_USAGE_MAX 20 + /*! * LZ4_MEMORY_USAGE : * Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB; ) @@ -124,12 +128,9 @@ LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; * Default value is 14, for 16KB, which nicely fits into Intel x86 L1 cache */ #ifndef LZ4_MEMORY_USAGE -# define LZ4_MEMORY_USAGE 14 +# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT #endif -#define LZ4_MEMORY_USAGE_MIN 10 -#define LZ4_MEMORY_USAGE_MAX 20 - #if (LZ4_MEMORY_USAGE < LZ4_MEMORY_USAGE_MIN) # error "LZ4_MEMORY_USAGE is too small !" #endif diff --git a/lib/lz4hc.c b/lib/lz4hc.c index ee6fc41..99650a6 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -277,6 +277,8 @@ LZ4HC_InsertAndGetWiderMatch ( /* do nothing */ } else if (matchIndex >= dictLimit) { /* within current Prefix */ const BYTE* const matchPtr = base + matchIndex; + DEBUGLOG(2, "matchPtr = %p", matchPtr); + DEBUGLOG(2, "lowPrefixPtr = %p", lowPrefixPtr); assert(matchPtr >= lowPrefixPtr); assert(matchPtr < ip); assert(longest >= 1); diff --git a/tests/Makefile b/tests/Makefile index 5fc6fc6..b4d40ca 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -174,14 +174,22 @@ test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-install test32: CFLAGS+=-m32 test32: test +.PHONY: test-amalgamation test-amalgamation: lz4_all.o lz4_all.c: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(CAT) $^ > $@ +.PHONY: test-install test-install: lz4 lib liblz4.pc lz4_root=.. ./test_install.sh +.PHONY: test-compile-with-lz4-memory-usage +test-compile-with-lz4-memory-usage: + $(MAKE) clean; CFLAGS=-O0 CPPFLAGS=-D'LZ4_MEMORY_USAGE=LZ4_MEMORY_USAGE_MIN' $(MAKE) all + $(MAKE) clean; CFLAGS=-O0 CPPFLAGS=-D'LZ4_MEMORY_USAGE=LZ4_MEMORY_USAGE_MAX' $(MAKE) all + +.PHONY: test-lz4-sparse test-lz4-sparse: lz4 datagen @echo "\n ---- test sparse file support ----" $(DATAGEN) -g5M -P100 > tmplsdg5M -- cgit v0.12