1# ########################################################################## 2# LZ4 programs - Makefile 3# Copyright (C) Yann Collet 2011-present 4# 5# GPL v2 License 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License along 18# with this program; if not, write to the Free Software Foundation, Inc., 19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20# 21# You can contact the author at : 22# - LZ4 homepage : http://www.lz4.org 23# - LZ4 source repository : https://github.com/lz4/lz4 24# ########################################################################## 25# fuzzer : Test tool, to check lz4 integrity on target platform 26# frametest : Test tool, to check lz4frame integrity on target platform 27# fullbench : Precisely measure speed for each LZ4 function variant 28# datagen : generates synthetic data samples for tests & benchmarks 29# ########################################################################## 30 31LZ4DIR := ../lib 32PRGDIR := ../programs 33TESTDIR := versionsTest 34PYTHON ?= python3 35 36DEBUGLEVEL?= 1 37DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL) 38CFLAGS ?= -O3 # can select custom optimization flags. Example : CFLAGS=-O2 make 39CFLAGS += -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \ 40 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \ 41 -Wpointer-arith -Wstrict-aliasing=1 42CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) 43CPPFLAGS+= -I$(LZ4DIR) -I$(PRGDIR) -DXXH_NAMESPACE=LZ4_ 44FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) 45 46include ../Makefile.inc 47 48LZ4 := $(PRGDIR)/lz4$(EXT) 49 50 51# Default test parameters 52TEST_FILES := COPYING 53FUZZER_TIME := -T90s 54NB_LOOPS ?= -i1 55 56.PHONY: default 57default: all 58 59all: fullbench fuzzer frametest roundTripTest datagen checkFrame decompress-partial 60 61all32: CFLAGS+=-m32 62all32: all 63 64lz4: 65 $(MAKE) -C $(PRGDIR) $@ CFLAGS="$(CFLAGS)" 66 67lib liblz4.pc: 68 $(MAKE) -C $(LZ4DIR) $@ CFLAGS="$(CFLAGS)" 69 70lz4c unlz4 lz4cat: lz4 71 $(LN_SF) $(LZ4) $(PRGDIR)/$@ 72 73lz4c32: # create a 32-bits version for 32/64 interop tests 74 $(MAKE) -C $(PRGDIR) $@ CFLAGS="-m32 $(CFLAGS)" 75 76%.o : $(LZ4DIR)/%.c $(LZ4DIR)/%.h 77 $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ 78 79fullbench : DEBUGLEVEL=0 80fullbench : lz4.o lz4hc.o lz4frame.o xxhash.o fullbench.c 81 $(CC) $(FLAGS) $^ -o $@$(EXT) 82 83$(LZ4DIR)/liblz4.a: 84 $(MAKE) -C $(LZ4DIR) liblz4.a 85 86fullbench-lib: fullbench.c $(LZ4DIR)/liblz4.a 87 $(CC) $(FLAGS) $^ -o $@$(EXT) 88 89fullbench-dll: fullbench.c $(LZ4DIR)/xxhash.c 90 $(MAKE) -C $(LZ4DIR) liblz4 91 $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(LZ4DIR)/dll/$(LIBLZ4).dll 92 93# test LZ4_USER_MEMORY_FUNCTIONS 94fullbench-wmalloc: CPPFLAGS += -DLZ4_USER_MEMORY_FUNCTIONS 95fullbench-wmalloc: fullbench 96 97fuzzer : lz4.o lz4hc.o xxhash.o fuzzer.c 98 $(CC) $(FLAGS) $^ -o $@$(EXT) 99 100frametest: lz4frame.o lz4.o lz4hc.o xxhash.o frametest.c 101 $(CC) $(FLAGS) $^ -o $@$(EXT) 102 103roundTripTest : lz4.o lz4hc.o xxhash.o roundTripTest.c 104 $(CC) $(FLAGS) $^ -o $@$(EXT) 105 106datagen : $(PRGDIR)/datagen.c datagencli.c 107 $(CC) $(FLAGS) -I$(PRGDIR) $^ -o $@$(EXT) 108 109checkFrame : lz4frame.o lz4.o lz4hc.o xxhash.o checkFrame.c 110 $(CC) $(FLAGS) $^ -o $@$(EXT) 111 112decompress-partial: lz4.o decompress-partial.c 113 $(CC) $(FLAGS) $^ -o $@$(EXT) 114 115.PHONY: clean 116clean: 117 @$(MAKE) -C $(LZ4DIR) $@ > $(VOID) 118 @$(MAKE) -C $(PRGDIR) $@ > $(VOID) 119 @$(RM) -rf core *.o *.test tmp* \ 120 fullbench-dll$(EXT) fullbench-lib$(EXT) \ 121 fullbench$(EXT) fullbench32$(EXT) \ 122 fuzzer$(EXT) fuzzer32$(EXT) \ 123 frametest$(EXT) frametest32$(EXT) \ 124 fasttest$(EXT) roundTripTest$(EXT) \ 125 datagen$(EXT) checkTag$(EXT) \ 126 frameTest$(EXT) decompress-partial$(EXT) \ 127 lz4_all.c 128 @$(RM) -rf $(TESTDIR) 129 @echo Cleaning completed 130 131.PHONY: versionsTest 132versionsTest: 133 $(PYTHON) test-lz4-versions.py 134 135.PHONY: listTest 136listTest: lz4 137 QEMU_SYS=$(QEMU_SYS) $(PYTHON) test-lz4-list.py 138 139checkTag: checkTag.c $(LZ4DIR)/lz4.h 140 $(CC) $(FLAGS) $< -o $@$(EXT) 141 142#----------------------------------------------------------------------------- 143# validated only for Linux, OSX, BSD, Hurd and Solaris targets 144#----------------------------------------------------------------------------- 145ifeq ($(POSIX_ENV),Yes) 146 147MD5:=md5sum 148ifneq (,$(filter $(shell uname), Darwin )) 149MD5:=md5 -r 150endif 151 152# note : we should probably settle on a single compare utility 153CMP:=cmp 154DIFF:=diff 155ifneq (,$(filter $(shell uname),SunOS)) 156DIFF:=gdiff 157endif 158 159CAT:=cat 160DD:=dd 161DATAGEN:=./datagen 162 163.PHONY: list 164list: 165 @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs 166 167.PHONY: check 168check: test-lz4-essentials 169 170.PHONY: test 171test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-install test-amalgamation listTest test-decompress-partial 172 173.PHONY: test32 174test32: CFLAGS+=-m32 175test32: test 176 177test-amalgamation: lz4_all.o 178 179lz4_all.c: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c 180 $(CAT) $^ > $@ 181 182test-install: lz4 lib liblz4.pc 183 lz4_root=.. ./test_install.sh 184 185test-lz4-sparse: lz4 datagen 186 @echo "\n ---- test sparse file support ----" 187 $(DATAGEN) -g5M -P100 > tmplsdg5M 188 $(LZ4) -B4D tmplsdg5M -c | $(LZ4) -dv --sparse > tmplscB4 189 $(DIFF) -s tmplsdg5M tmplscB4 190 $(LZ4) -B5D tmplsdg5M -c | $(LZ4) -dv --sparse > tmplscB5 191 $(DIFF) -s tmplsdg5M tmplscB5 192 $(LZ4) -B6D tmplsdg5M -c | $(LZ4) -dv --sparse > tmplscB6 193 $(DIFF) -s tmplsdg5M tmplscB6 194 $(LZ4) -B7D tmplsdg5M -c | $(LZ4) -dv --sparse > tmplscB7 195 $(DIFF) -s tmplsdg5M tmplscB7 196 $(LZ4) tmplsdg5M -c | $(LZ4) -dv --no-sparse > tmplsnosparse 197 $(DIFF) -s tmplsdg5M tmplsnosparse 198 ls -ls tmpls* 199 $(DATAGEN) -s1 -g1200007 -P100 | $(LZ4) | $(LZ4) -dv --sparse > tmplsodd # Odd size file (to generate non-full last block) 200 $(DATAGEN) -s1 -g1200007 -P100 | $(DIFF) -s - tmplsodd 201 ls -ls tmplsodd 202 @$(RM) tmpls* 203 @echo "\n Compatibility with Console :" 204 echo "Hello World 1 !" | $(LZ4) | $(LZ4) -d -c 205 echo "Hello World 2 !" | $(LZ4) | $(LZ4) -d | $(CAT) 206 echo "Hello World 3 !" | $(LZ4) --no-frame-crc | $(LZ4) -d -c 207 @echo "\n Compatibility with Append :" 208 $(DATAGEN) -P100 -g1M > tmplsdg1M 209 $(CAT) tmplsdg1M tmplsdg1M > tmpls2M 210 $(LZ4) -B5 -v tmplsdg1M tmplsc 211 $(LZ4) -d -v tmplsc tmplsr 212 $(LZ4) -d -v tmplsc -c >> tmplsr 213 ls -ls tmp* 214 $(DIFF) tmpls2M tmplsr 215 @$(RM) tmpls* 216 217test-lz4-contentSize: lz4 datagen 218 @echo "\n ---- test original size support ----" 219 $(DATAGEN) -g15M > tmplc1 220 $(LZ4) -v tmplc1 -c | $(LZ4) -t 221 $(LZ4) -v --content-size tmplc1 -c | $(LZ4) -d > tmplc2 222 $(DIFF) tmplc1 tmplc2 223 $(LZ4) -f tmplc1 -c > tmplc1.lz4 224 $(LZ4) --content-size tmplc1 -c > tmplc2.lz4 225 ! $(DIFF) tmplc1.lz4 tmplc2.lz4 # must differ, due to content size 226 $(LZ4) --content-size < tmplc1 > tmplc3.lz4 227 $(DIFF) tmplc2.lz4 tmplc3.lz4 # both must contain content size 228 $(CAT) tmplc1 | $(LZ4) > tmplc4.lz4 229 $(DIFF) tmplc1.lz4 tmplc4.lz4 # both don't have content size 230 $(CAT) tmplc1 | $(LZ4) --content-size > tmplc5.lz4 # can't determine content size 231 $(DIFF) tmplc1.lz4 tmplc5.lz4 # both don't have content size 232 @$(RM) tmplc* 233 234test-lz4-frame-concatenation: lz4 datagen 235 @echo "\n ---- test frame concatenation ----" 236 @echo -n > tmp-lfc-empty 237 @echo hi > tmp-lfc-nonempty 238 $(CAT) tmp-lfc-nonempty tmp-lfc-empty tmp-lfc-nonempty > tmp-lfc-src 239 $(LZ4) -zq tmp-lfc-empty -c > tmp-lfc-empty.lz4 240 $(LZ4) -zq tmp-lfc-nonempty -c > tmp-lfc-nonempty.lz4 241 $(CAT) tmp-lfc-nonempty.lz4 tmp-lfc-empty.lz4 tmp-lfc-nonempty.lz4 > tmp-lfc-concat.lz4 242 $(LZ4) -d tmp-lfc-concat.lz4 -c > tmp-lfc-result 243 $(CMP) tmp-lfc-src tmp-lfc-result 244 @$(RM) tmp-lfc-* 245 @echo frame concatenation test completed 246 247test-lz4-multiple: lz4 datagen 248 @echo "\n ---- test multiple files ----" 249 @$(DATAGEN) -s1 > tmp-tlm1 2> $(VOID) 250 @$(DATAGEN) -s2 -g100K > tmp-tlm2 2> $(VOID) 251 @$(DATAGEN) -s3 -g200K > tmp-tlm3 2> $(VOID) 252 # compress multiple files : one .lz4 per source file 253 $(LZ4) -f -m tmp-tlm* 254 test -f tmp-tlm1.lz4 255 test -f tmp-tlm2.lz4 256 test -f tmp-tlm3.lz4 257 # decompress multiple files : one output file per .lz4 258 mv tmp-tlm1 tmp-tlm1-orig 259 mv tmp-tlm2 tmp-tlm2-orig 260 mv tmp-tlm3 tmp-tlm3-orig 261 $(LZ4) -d -f -m tmp-tlm*.lz4 262 $(CMP) tmp-tlm1 tmp-tlm1-orig # must be identical 263 $(CMP) tmp-tlm2 tmp-tlm2-orig 264 $(CMP) tmp-tlm3 tmp-tlm3-orig 265 # compress multiple files into stdout 266 $(CAT) tmp-tlm1.lz4 tmp-tlm2.lz4 tmp-tlm3.lz4 > tmp-tlm-concat1 267 $(RM) *.lz4 268 $(LZ4) -m tmp-tlm1 tmp-tlm2 tmp-tlm3 -c > tmp-tlm-concat2 269 test ! -f tmp-tlm1.lz4 # must not create .lz4 artefact 270 $(CMP) tmp-tlm-concat1 tmp-tlm-concat2 # must be equivalent 271 # decompress multiple files into stdout 272 $(RM) tmp-tlm-concat1 tmp-tlm-concat2 273 $(LZ4) -f -m tmp-tlm1 tmp-tlm2 tmp-tlm3 # generate .lz4 to decompress 274 $(CAT) tmp-tlm1 tmp-tlm2 tmp-tlm3 > tmp-tlm-concat1 # create concatenated reference 275 $(RM) tmp-tlm1 tmp-tlm2 tmp-tlm3 276 $(LZ4) -d -m tmp-tlm1.lz4 tmp-tlm2.lz4 tmp-tlm3.lz4 -c > tmp-tlm-concat2 277 test ! -f tmp-tlm1 # must not create file artefact 278 $(CMP) tmp-tlm-concat1 tmp-tlm-concat2 # must be equivalent 279 # compress multiple files, one of which is absent (must fail) 280 ! $(LZ4) -f -m tmp-tlm-concat1 notHere tmp-tlm-concat2 # must fail : notHere not present 281 @$(RM) tmp-tlm* 282 283test-lz4-multiple-legacy: lz4 datagen 284 @echo "\n ---- test multiple files (Legacy format) ----" 285 @$(DATAGEN) -s1 > tmp-tlm1 2> $(VOID) 286 @$(DATAGEN) -s2 -g100K > tmp-tlm2 2> $(VOID) 287 @$(DATAGEN) -s3 -g200K > tmp-tlm3 2> $(VOID) 288 # compress multiple files using legacy format: one .lz4 per source file 289 $(LZ4) -f -l -m tmp-tlm* 290 test -f tmp-tlm1.lz4 291 test -f tmp-tlm2.lz4 292 test -f tmp-tlm3.lz4 293 # decompress multiple files compressed using legacy format: one output file per .lz4 294 mv tmp-tlm1 tmp-tlm1-orig 295 mv tmp-tlm2 tmp-tlm2-orig 296 mv tmp-tlm3 tmp-tlm3-orig 297 $(LZ4) -d -f -m tmp-tlm*.lz4 298 $(LZ4) -l -d -f -m tmp-tlm*.lz4 # -l mustn't impact -d option 299 $(CMP) tmp-tlm1 tmp-tlm1-orig # must be identical 300 $(CMP) tmp-tlm2 tmp-tlm2-orig 301 $(CMP) tmp-tlm3 tmp-tlm3-orig 302 # compress multiple files into stdout using legacy format 303 $(CAT) tmp-tlm1.lz4 tmp-tlm2.lz4 tmp-tlm3.lz4 > tmp-tlm-concat1 304 $(RM) *.lz4 305 $(LZ4) -l -m tmp-tlm1 tmp-tlm2 tmp-tlm3 -c > tmp-tlm-concat2 306 test ! -f tmp-tlm1.lz4 # must not create .lz4 artefact 307 $(CMP) tmp-tlm-concat1 tmp-tlm-concat2 # must be equivalent 308 # # # decompress multiple files into stdout using legacy format 309 $(RM) tmp-tlm-concat1 tmp-tlm-concat2 310 $(LZ4) -l -f -m tmp-tlm1 tmp-tlm2 tmp-tlm3 # generate .lz4 to decompress 311 $(CAT) tmp-tlm1 tmp-tlm2 tmp-tlm3 > tmp-tlm-concat1 # create concatenated reference 312 $(RM) tmp-tlm1 tmp-tlm2 tmp-tlm3 313 $(LZ4) -d -m tmp-tlm1.lz4 tmp-tlm2.lz4 tmp-tlm3.lz4 -c > tmp-tlm-concat2 314 $(LZ4) -d -l -m tmp-tlm1.lz4 tmp-tlm2.lz4 tmp-tlm3.lz4 -c > tmp-tlm-concat2 # -l mustn't impact option -d 315 test ! -f tmp-tlm1 # must not create file artefact 316 $(CMP) tmp-tlm-concat1 tmp-tlm-concat2 # must be equivalent 317 # # # compress multiple files, one of which is absent (must fail) 318 ! $(LZ4) -f -l -m tmp-tlm-concat1 notHere-legacy tmp-tlm-concat2 # must fail : notHere-legacy not present 319 @$(RM) tmp-tlm* 320 321test-lz4-basic: lz4 datagen unlz4 lz4cat 322 @echo "\n ---- test lz4 basic compression/decompression ----" 323 $(DATAGEN) -g0 | $(LZ4) -v | $(LZ4) -t 324 $(DATAGEN) -g16KB | $(LZ4) -9 | $(LZ4) -t 325 $(DATAGEN) -g20KB > tmp-tlb-dg20k 326 $(LZ4) < tmp-tlb-dg20k | $(LZ4) -d > tmp-tlb-dec 327 $(DIFF) -q tmp-tlb-dg20k tmp-tlb-dec 328 $(LZ4) --no-frame-crc < tmp-tlb-dg20k | $(LZ4) -d > tmp-tlb-dec 329 $(DIFF) -q tmp-tlb-dg20k tmp-tlb-dec 330 $(DATAGEN) | $(LZ4) -BI | $(LZ4) -t 331 $(DATAGEN) -g6M -P99 | $(LZ4) -9BD | $(LZ4) -t 332 $(DATAGEN) -g17M | $(LZ4) -9v | $(LZ4) -qt 333 $(DATAGEN) -g33M | $(LZ4) --no-frame-crc | $(LZ4) -t 334 $(DATAGEN) -g256MB | $(LZ4) -vqB4D | $(LZ4) -t 335 @echo "hello world" > tmp-tlb-hw 336 $(LZ4) --rm -f tmp-tlb-hw tmp-tlb-hw.lz4 337 test ! -f tmp-tlb-hw # must fail (--rm) 338 test -f tmp-tlb-hw.lz4 339 $(PRGDIR)/lz4cat tmp-tlb-hw.lz4 # must display hello world 340 test -f tmp-tlb-hw.lz4 341 $(PRGDIR)/unlz4 --rm tmp-tlb-hw.lz4 tmp-tlb-hw 342 test -f tmp-tlb-hw 343 test ! -f tmp-tlb-hw.lz4 # must fail (--rm) 344 test ! -f tmp-tlb-hw.lz4.lz4 # must fail (unlz4) 345 $(PRGDIR)/lz4cat tmp-tlb-hw # pass-through mode 346 test -f tmp-tlb-hw 347 test ! -f tmp-tlb-hw.lz4 # must fail (lz4cat) 348 $(LZ4) tmp-tlb-hw tmp-tlb-hw.lz4 # creates tmp-tlb-hw.lz4 349 $(PRGDIR)/lz4cat < tmp-tlb-hw.lz4 > tmp-tlb3 # checks lz4cat works with stdin (#285) 350 $(DIFF) -q tmp-tlb-hw tmp-tlb3 351 $(PRGDIR)/lz4cat < tmp-tlb-hw > tmp-tlb2 # checks lz4cat works in pass-through mode 352 $(DIFF) -q tmp-tlb-hw tmp-tlb2 353 cp tmp-tlb-hw ./-d 354 $(LZ4) --rm -- -d -d.lz4 # compresses ./d into ./-d.lz4 355 test -f ./-d.lz4 356 test ! -f ./-d 357 mv ./-d.lz4 ./-z 358 $(LZ4) -d --rm -- -z tmp-tlb4 # uncompresses ./-z into tmp-tlb4 359 test ! -f ./-z 360 $(DIFF) -q tmp-tlb-hw tmp-tlb4 361 $(LZ4) -f tmp-tlb-hw 362 $(LZ4) --list tmp-tlb-hw.lz4 # test --list on valid single-frame file 363 $(CAT) tmp-tlb-hw >> tmp-tlb-hw.lz4 364 $(LZ4) -f tmp-tlb-hw.lz4 # uncompress valid frame followed by invalid data 365 $(LZ4) -BX tmp-tlb-hw -c -q | $(LZ4) -tv # test block checksum 366 # $(DATAGEN) -g20KB generates the same file every single time 367 # cannot save output of $(DATAGEN) -g20KB as input file to lz4 because the following shell commands are run before $(DATAGEN) -g20KB 368 test "$(shell $(DATAGEN) -g20KB | $(LZ4) -c --fast | wc -c)" -lt "$(shell $(DATAGEN) -g20KB | $(LZ4) -c --fast=9 | wc -c)" # -1 vs -9 369 test "$(shell $(DATAGEN) -g20KB | $(LZ4) -c -1 | wc -c)" -lt "$(shell $(DATAGEN) -g20KB| $(LZ4) -c --fast=1 | wc -c)" # 1 vs -1 370 test "$(shell $(DATAGEN) -g20KB | $(LZ4) -c --fast=1 | wc -c)" -eq "$(shell $(DATAGEN) -g20KB| $(LZ4) -c --fast| wc -c)" # checks default fast compression is -1 371 ! $(LZ4) -c --fast=0 tmp-tlb-dg20K # lz4 should fail when fast=0 372 ! $(LZ4) -c --fast=-1 tmp-tlb-dg20K # lz4 should fail when fast=-1 373 # High --fast values can result in out-of-bound dereferences #876 374 $(DATAGEN) -g1M | $(LZ4) -c --fast=999999999 > /dev/null 375 # Test for #596 376 @echo "TEST" > tmp-tlb-test 377 $(LZ4) -m tmp-tlb-test 378 $(LZ4) tmp-tlb-test.lz4 tmp-tlb-test2 379 $(DIFF) -q tmp-tlb-test tmp-tlb-test2 380 @$(RM) tmp-tlb* 381 382 383 384test-lz4-dict: lz4 datagen 385 @echo "\n ---- test lz4 compression/decompression with dictionary ----" 386 $(DATAGEN) -g16KB > tmp-dict 387 $(DATAGEN) -g32KB > tmp-dict-sample-32k 388 < tmp-dict-sample-32k $(LZ4) -D tmp-dict | $(LZ4) -dD tmp-dict | diff - tmp-dict-sample-32k 389 $(DATAGEN) -g128MB > tmp-dict-sample-128m 390 < tmp-dict-sample-128m $(LZ4) -D tmp-dict | $(LZ4) -dD tmp-dict | diff - tmp-dict-sample-128m 391 touch tmp-dict-sample-0 392 < tmp-dict-sample-0 $(LZ4) -D tmp-dict | $(LZ4) -dD tmp-dict | diff - tmp-dict-sample-0 393 394 < tmp-dict-sample-32k $(LZ4) -D tmp-dict-sample-0 | $(LZ4) -dD tmp-dict-sample-0 | diff - tmp-dict-sample-32k 395 < tmp-dict-sample-0 $(LZ4) -D tmp-dict-sample-0 | $(LZ4) -dD tmp-dict-sample-0 | diff - tmp-dict-sample-0 396 397 @echo "\n ---- test lz4 dictionary loading ----" 398 $(DATAGEN) -g128KB > tmp-dict-data-128KB 399 set -e; \ 400 for l in 0 1 4 128 32767 32768 32769 65535 65536 65537 98303 98304 98305 131071 131072 131073; do \ 401 $(DATAGEN) -g$$l > tmp-dict-$$l; \ 402 $(DD) if=tmp-dict-$$l of=tmp-dict-$$l-tail bs=1 count=65536 skip=$$((l > 65536 ? l - 65536 : 0)); \ 403 < tmp-dict-$$l $(LZ4) -D stdin tmp-dict-data-128KB -c | $(LZ4) -dD tmp-dict-$$l-tail | $(DIFF) - tmp-dict-data-128KB; \ 404 < tmp-dict-$$l-tail $(LZ4) -D stdin tmp-dict-data-128KB -c | $(LZ4) -dD tmp-dict-$$l | $(DIFF) - tmp-dict-data-128KB; \ 405 done 406 407 @$(RM) tmp-dict* 408 409test-lz4-hugefile: lz4 datagen 410 @echo "\n ---- test huge files compression/decompression ----" 411 ./datagen -g6GB | $(LZ4) -vB5D | $(LZ4) -qt 412 ./datagen -g4500MB | $(LZ4) -v3BD | $(LZ4) -qt 413 # test large file size [2-4] GB 414 @$(DATAGEN) -g3G -P100 | $(LZ4) -vv | $(LZ4) --decompress --force --sparse - tmphf1 415 @ls -ls tmphf1 416 @$(DATAGEN) -g3G -P100 | $(LZ4) --quiet --content-size | $(LZ4) --verbose --decompress --force --sparse - tmphf2 417 @ls -ls tmphf2 418 $(DIFF) -s tmphf1 tmphf2 419 @$(RM) tmphf* 420 421test-lz4-testmode: lz4 datagen 422 @echo "\n ---- bench mode ----" 423 $(LZ4) -bi0 424 @echo "\n ---- test mode ----" 425 ! $(DATAGEN) | $(LZ4) -t 426 ! $(DATAGEN) | $(LZ4) -tf 427 @echo "\n ---- pass-through mode ----" 428 @echo "Why hello there " > tmp-tlt2.lz4 429 ! $(LZ4) -f tmp-tlt2.lz4 > $(VOID) 430 ! $(DATAGEN) | $(LZ4) -dc > $(VOID) 431 ! $(DATAGEN) | $(LZ4) -df > $(VOID) 432 $(DATAGEN) | $(LZ4) -dcf > $(VOID) 433 @echo "Hello World !" > tmp-tlt1 434 $(LZ4) -dcf tmp-tlt1 435 @echo "from underground..." > tmp-tlt2 436 $(LZ4) -dcfm tmp-tlt1 tmp-tlt2 437 @echo "\n ---- non-existing source ----" 438 ! $(LZ4) file-does-not-exist 439 ! $(LZ4) -f file-does-not-exist 440 ! $(LZ4) -t file-does-not-exist 441 ! $(LZ4) -fm file1-dne file2-dne 442 @$(RM) tmp-tlt tmp-tlt1 tmp-tlt2 tmp-tlt2.lz4 443 444test-lz4-opt-parser: lz4 datagen 445 @echo "\n ---- test opt-parser ----" 446 $(DATAGEN) -g16KB | $(LZ4) -12 | $(LZ4) -t 447 $(DATAGEN) -P10 | $(LZ4) -12B4 | $(LZ4) -t 448 $(DATAGEN) -g256K | $(LZ4) -12B4D | $(LZ4) -t 449 $(DATAGEN) -g512K -P25 | $(LZ4) -12BD | $(LZ4) -t 450 $(DATAGEN) -g1M | $(LZ4) -12B5 | $(LZ4) -t 451 $(DATAGEN) -g2M -P99 | $(LZ4) -11B4D | $(LZ4) -t 452 $(DATAGEN) -g4M | $(LZ4) -11vq | $(LZ4) -qt 453 $(DATAGEN) -g8M | $(LZ4) -11B4 | $(LZ4) -t 454 $(DATAGEN) -g16M -P90 | $(LZ4) -11B5 | $(LZ4) -t 455 $(DATAGEN) -g32M -P10 | $(LZ4) -11B5D | $(LZ4) -t 456 457test-lz4-essentials : lz4 datagen test-lz4-basic test-lz4-multiple test-lz4-multiple-legacy \ 458 test-lz4-frame-concatenation test-lz4-testmode \ 459 test-lz4-contentSize test-lz4-dict 460 @$(RM) tmp* 461 462test-lz4: lz4 datagen test-lz4-essentials test-lz4-opt-parser \ 463 test-lz4-sparse test-lz4-hugefile test-lz4-dict 464 @$(RM) tmp* 465 466test-lz4c: lz4c datagen 467 @echo "\n ---- test lz4c variant ----" 468 $(DATAGEN) -g256MB | $(LZ4)c -l -v | $(LZ4)c -t 469 470test-lz4c32: CFLAGS+=-m32 471test-lz4c32: test-lz4 472 473test-interop-32-64: lz4 lz4c32 datagen 474 @echo "\n ---- test interoperability 32-bits -vs- 64 bits ----" 475 $(DATAGEN) -g16KB | $(LZ4)c32 -9 | $(LZ4) -t 476 $(DATAGEN) -P10 | $(LZ4) -9B4 | $(LZ4)c32 -t 477 $(DATAGEN) | $(LZ4)c32 | $(LZ4) -t 478 $(DATAGEN) -g1M | $(LZ4) -3B5 | $(LZ4)c32 -t 479 $(DATAGEN) -g256MB | $(LZ4)c32 -vqB4D | $(LZ4) -qt 480 $(DATAGEN) -g1G -P90 | $(LZ4) | $(LZ4)c32 -t 481 $(DATAGEN) -g6GB | $(LZ4)c32 -vq9BD | $(LZ4) -qt 482 483test-lz4c32-basic: lz4c32 datagen 484 @echo "\n ---- test lz4c32 32-bits version ----" 485 $(DATAGEN) -g16KB | $(LZ4)c32 -9 | $(LZ4)c32 -t 486 $(DATAGEN) | $(LZ4)c32 | $(LZ4)c32 -t 487 $(DATAGEN) -g256MB | $(LZ4)c32 -vqB4D | $(LZ4)c32 -qt 488 $(DATAGEN) -g6GB | $(LZ4)c32 -vqB5D | $(LZ4)c32 -qt 489 490test-platform: 491 @echo "\n ---- test lz4 $(QEMU_SYS) platform ----" 492 $(QEMU_SYS) $(DATAGEN) -g16KB | $(QEMU_SYS) $(LZ4) -9 | $(QEMU_SYS) $(LZ4) -t 493 $(QEMU_SYS) $(DATAGEN) | $(QEMU_SYS) $(LZ4) | $(QEMU_SYS) $(LZ4) -t 494 $(QEMU_SYS) $(DATAGEN) -g256MB | $(QEMU_SYS) $(LZ4) -vqB4D | $(QEMU_SYS) $(LZ4) -qt 495ifneq ($(QEMU_SYS),qemu-arm-static) 496 $(QEMU_SYS) $(DATAGEN) -g3GB | $(QEMU_SYS) $(LZ4) -vqB5D | $(QEMU_SYS) $(LZ4) -qt 497endif 498 499test-fullbench: fullbench 500 ./fullbench --no-prompt $(NB_LOOPS) $(TEST_FILES) 501 502test-fullbench32: CFLAGS += -m32 503test-fullbench32: test-fullbench 504 505test-fuzzer: fuzzer 506 ./fuzzer $(FUZZER_TIME) 507 508test-fuzzer32: CFLAGS += -m32 509test-fuzzer32: test-fuzzer 510 511test-frametest: frametest 512 ./frametest -v $(FUZZER_TIME) 513 514test-frametest32: CFLAGS += -m32 515test-frametest32: test-frametest 516 517test-mem: lz4 datagen fuzzer frametest fullbench 518 @echo "\n ---- valgrind tests : memory analyzer ----" 519 valgrind --leak-check=yes --error-exitcode=1 $(DATAGEN) -g50M > $(VOID) 520 $(DATAGEN) -g16KB > ftmdg16K 521 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) -9 -BD -f ftmdg16K $(VOID) 522 $(DATAGEN) -g16KB -s2 > ftmdg16K2 523 $(DATAGEN) -g16KB -s3 > ftmdg16K3 524 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) --force --multiple ftmdg16K ftmdg16K2 ftmdg16K3 525 $(DATAGEN) -g7MB > ftmdg7M 526 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) -9 -B5D -f ftmdg7M ftmdg16K2 527 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) -t ftmdg16K2 528 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) -bi1 ftmdg7M 529 valgrind --leak-check=yes --error-exitcode=1 ./fullbench -i1 ftmdg7M ftmdg16K2 530 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) -B4D -f -vq ftmdg7M $(VOID) 531 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) --list -m ftm*.lz4 532 valgrind --leak-check=yes --error-exitcode=1 $(LZ4) --list -m -v ftm*.lz4 533 $(RM) ftm* 534 valgrind --leak-check=yes --error-exitcode=1 ./fuzzer -i64 -t1 535 valgrind --leak-check=yes --error-exitcode=1 ./frametest -i256 536 537test-mem32: lz4c32 datagen 538# unfortunately, valgrind doesn't seem to work with non-native binary... 539 540test-decompress-partial : decompress-partial 541 @echo "\n ---- test decompress-partial ----" 542 ./decompress-partial$(EXT) 543 544endif 545