]> git.proxmox.com Git - ceph.git/blame - ceph/src/zstd/tests/Makefile
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / zstd / tests / Makefile
CommitLineData
11fdf7f2 1# ################################################################
f67539c2 2# Copyright (c) 2015-2020, Yann Collet, Facebook, Inc.
7c673cae
FG
3# All rights reserved.
4#
11fdf7f2
TL
5# This source code is licensed under both the BSD-style license (found in the
6# LICENSE file in the root directory of this source tree) and the GPLv2 (found
7# in the COPYING file in the root directory of this source tree).
f67539c2 8# You may select, at your option, one of the above-listed licenses.
11fdf7f2 9# ################################################################
7c673cae
FG
10# datagen : Synthetic and parametrable data generator, for tests
11# fullbench : Precisely measure speed for each zstd inner functions
12# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
13# fuzzer : Test tool, to check zstd integrity on target platform
14# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
15# paramgrill : parameter tester for zstd
16# test-zstd-speed.py : script for testing zstd speed difference between commits
17# versionsTest : compatibility test between zstd versions stored on Github (v0.1+)
18# zstreamtest : Fuzzer test tool for zstd streaming API
19# zstreamtest32: Same as zstreamtest, but forced to compile in 32-bits mode
20# ##########################################################################
21
7c673cae
FG
22ZSTDDIR = ../lib
23PRGDIR = ../programs
24PYTHON ?= python3
9f95a23c 25TESTARTEFACT := versionsTest
7c673cae 26
11fdf7f2 27DEBUGLEVEL ?= 1
9f95a23c 28DEBUGFLAGS = -g -DDEBUGLEVEL=$(DEBUGLEVEL)
11fdf7f2
TL
29CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \
30 -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR)
9f95a23c
TL
31ifeq ($(OS),Windows_NT) # MinGW assumed
32CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting
33endif
11fdf7f2
TL
34CFLAGS ?= -O3
35CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
36 -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
9f95a23c 37 -Wstrict-prototypes -Wundef \
11fdf7f2 38 -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
9f95a23c 39 -Wredundant-decls -Wmissing-prototypes
11fdf7f2
TL
40CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
41FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
7c673cae
FG
42
43
44ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
11fdf7f2 45ZSTDCOMP_FILES := $(ZSTDDIR)/compress/*.c
7c673cae 46ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/*.c
11fdf7f2 47ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
7c673cae
FG
48ZBUFF_FILES := $(ZSTDDIR)/deprecated/*.c
49ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
50
9f95a23c
TL
51ZSTD_F1 := $(wildcard $(ZSTD_FILES))
52ZSTD_OBJ1 := $(subst $(ZSTDDIR)/common/,zstdm_,$(ZSTD_F1))
53ZSTD_OBJ2 := $(subst $(ZSTDDIR)/compress/,zstdc_,$(ZSTD_OBJ1))
54ZSTD_OBJ3 := $(subst $(ZSTDDIR)/decompress/,zstdd_,$(ZSTD_OBJ2))
55ZSTD_OBJECTS := $(ZSTD_OBJ3:.c=.o)
56
57ZSTDMT_OBJ1 := $(subst $(ZSTDDIR)/common/,zstdmt_m_,$(ZSTD_F1))
58ZSTDMT_OBJ2 := $(subst $(ZSTDDIR)/compress/,zstdmt_c_,$(ZSTDMT_OBJ1))
59ZSTDMT_OBJ3 := $(subst $(ZSTDDIR)/decompress/,zstdmt_d_,$(ZSTDMT_OBJ2))
60ZSTDMT_OBJECTS := $(ZSTDMT_OBJ3:.c=.o)
7c673cae 61
7c673cae
FG
62# Define *.exe as extension for Windows systems
63ifneq (,$(filter Windows%,$(OS)))
64EXT =.exe
11fdf7f2
TL
65MULTITHREAD_CPP = -DZSTD_MULTITHREAD
66MULTITHREAD_LD =
7c673cae
FG
67else
68EXT =
11fdf7f2
TL
69MULTITHREAD_CPP = -DZSTD_MULTITHREAD
70MULTITHREAD_LD = -pthread
7c673cae 71endif
11fdf7f2 72MULTITHREAD = $(MULTITHREAD_CPP) $(MULTITHREAD_LD)
7c673cae
FG
73
74VOID = /dev/null
11fdf7f2
TL
75ZSTREAM_TESTTIME ?= -T90s
76FUZZERTEST ?= -T200s
77ZSTDRTTEST = --test-large-data
78DECODECORPUS_TESTTIME ?= -T30
7c673cae 79
9f95a23c 80.PHONY: default all all32 allnothread dll clean test test32 test-all versionsTest
7c673cae
FG
81
82default: fullbench
9f95a23c 83 @echo $(ZSTDMT_OBJECTS)
7c673cae 84
9f95a23c
TL
85all: fullbench fuzzer zstreamtest paramgrill datagen decodecorpus roundTripCrash \
86 fullbench-lib poolTests
7c673cae 87
11fdf7f2 88all32: fullbench32 fuzzer32 zstreamtest32
7c673cae 89
9f95a23c
TL
90allnothread: MULTITHREAD_CPP=
91allnothread: MULTITHREAD_LD=
11fdf7f2 92allnothread: fullbench fuzzer paramgrill datagen decodecorpus
7c673cae 93
f67539c2 94# note : broken : requires symbols unavailable from dynamic library
11fdf7f2 95dll: fuzzer-dll zstreamtest-dll
7c673cae 96
9f95a23c
TL
97PHONY: zstd zstd32 zstd-nolegacy # must be phony, only external makefile knows how to build them, or if they need an update
98zstd zstd32 zstd-nolegacy:
99 $(MAKE) -C $(PRGDIR) $@ MOREFLAGS+="$(DEBUGFLAGS)"
7c673cae 100
9f95a23c 101gzstd:
f67539c2 102 $(MAKE) -C $(PRGDIR) $@ HAVE_ZLIB=1 MOREFLAGS+="$(DEBUGFLAGS)"
7c673cae 103
f67539c2
TL
104.PHONY: libzstd
105libzstd :
9f95a23c 106 $(MAKE) -C $(ZSTDDIR) libzstd
7c673cae 107
f67539c2
TL
108%-dll : libzstd
109%-dll : LDFLAGS+= -L$(ZSTDDIR) -lzstd
110
9f95a23c
TL
111.PHONY: zstd-staticLib
112zstd-staticLib :
113 $(MAKE) -C $(ZSTDDIR) libzstd.a
114
115zstdm_%.o : $(ZSTDDIR)/common/%.c
116 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
117
118zstdc_%.o : $(ZSTDDIR)/compress/%.c
119 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
120
121zstdd_%.o : $(ZSTDDIR)/decompress/%.c
122 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
123
124zstdmt%.o : CPPFLAGS += $(MULTITHREAD_CPP)
125
126zstdmt_m_%.o : $(ZSTDDIR)/common/%.c
127 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
128
129zstdmt_c_%.o : $(ZSTDDIR)/compress/%.c
130 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
131
132zstdmt_d_%.o : $(ZSTDDIR)/decompress/%.c
133 $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
7c673cae 134
11fdf7f2
TL
135fullbench32: CPPFLAGS += -m32
136fullbench fullbench32 : CPPFLAGS += $(MULTITHREAD_CPP)
137fullbench fullbench32 : LDFLAGS += $(MULTITHREAD_LD)
9f95a23c
TL
138fullbench fullbench32 : DEBUGFLAGS = -DNDEBUG # turn off assert() for speed measurements
139fullbench fullbench32 : $(ZSTD_FILES)
140fullbench fullbench32 : $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c fullbench.c
11fdf7f2 141 $(CC) $(FLAGS) $^ -o $@$(EXT)
7c673cae 142
9f95a23c
TL
143fullbench-lib : CPPFLAGS += -DXXH_NAMESPACE=ZSTD_
144fullbench-lib : zstd-staticLib
145fullbench-lib : $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c fullbench.c
146 $(CC) $(FLAGS) $(filter %.c,$^) -o $@$(EXT) $(ZSTDDIR)/libzstd.a
7c673cae 147
f67539c2 148# note : broken : requires symbols unavailable from dynamic library
9f95a23c
TL
149fullbench-dll: $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/benchfn.c $(PRGDIR)/timefn.c fullbench.c
150# $(CC) $(FLAGS) $(filter %.c,$^) -o $@$(EXT) -DZSTD_DLL_IMPORT=1 $(ZSTDDIR)/dll/libzstd.dll
151 $(CC) $(FLAGS) $(filter %.c,$^) -o $@$(EXT)
7c673cae 152
9f95a23c
TL
153fuzzer : CPPFLAGS += $(MULTITHREAD_CPP)
154fuzzer : LDFLAGS += $(MULTITHREAD_LD)
11fdf7f2 155fuzzer32: CFLAGS += -m32
9f95a23c
TL
156fuzzer : $(ZSTDMT_OBJECTS)
157fuzzer32: $(ZSTD_FILES)
158fuzzer fuzzer32 : $(ZDICT_FILES) $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c fuzzer.c
11fdf7f2 159 $(CC) $(FLAGS) $^ -o $@$(EXT)
7c673cae 160
f67539c2 161# note : broken : requires symbols unavailable from dynamic library
9f95a23c
TL
162fuzzer-dll : $(ZSTDDIR)/common/xxhash.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c fuzzer.c
163 $(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@$(EXT)
7c673cae 164
f67539c2
TL
165zbufftest zbufftest32 zbufftest-dll : CPPFLAGS += -I$(ZSTDDIR)/deprecated
166zbufftest zbufftest32 zbufftest-dll : CFLAGS += -Wno-deprecated-declarations # required to silence deprecation warnings
167zbufftest32 : CFLAGS += -m32
168zbufftest zbufftest32 : $(ZSTD_OBJECTS) $(ZBUFF_FILES) $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c zbufftest.c
7c673cae
FG
169 $(CC) $(FLAGS) $^ -o $@$(EXT)
170
9f95a23c
TL
171zbufftest-dll : $(ZSTDDIR)/common/xxhash.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/datagen.c zbufftest.c
172 $(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@$(EXT)
7c673cae 173
9f95a23c
TL
174ZSTREAM_LOCAL_FILES := $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c seqgen.c zstreamtest.c
175ZSTREAM_PROPER_FILES := $(ZDICT_FILES) $(ZSTREAM_LOCAL_FILES)
176ZSTREAMFILES := $(ZSTD_FILES) $(ZSTREAM_PROPER_FILES)
11fdf7f2 177zstreamtest32 : CFLAGS += -m32
9f95a23c
TL
178zstreamtest zstreamtest32 : CPPFLAGS += $(MULTITHREAD_CPP)
179zstreamtest zstreamtest32 : LDFLAGS += $(MULTITHREAD_LD)
180zstreamtest : $(ZSTDMT_OBJECTS) $(ZSTREAM_PROPER_FILES)
11fdf7f2 181zstreamtest32 : $(ZSTREAMFILES)
9f95a23c
TL
182zstreamtest zstreamtest32 :
183 $(CC) $(FLAGS) $^ -o $@$(EXT)
11fdf7f2
TL
184
185zstreamtest_asan : CFLAGS += -fsanitize=address
186zstreamtest_asan : $(ZSTREAMFILES)
187 $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
188
189zstreamtest_tsan : CFLAGS += -fsanitize=thread
190zstreamtest_tsan : $(ZSTREAMFILES)
191 $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
192
f67539c2 193# note : broken : requires symbols unavailable from dynamic library
9f95a23c
TL
194zstreamtest-dll : $(ZSTDDIR)/common/xxhash.c # xxh symbols not exposed from dll
195zstreamtest-dll : $(ZSTREAM_LOCAL_FILES)
196 $(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@$(EXT)
7c673cae 197
9f95a23c
TL
198paramgrill : DEBUGFLAGS = # turn off assert() by default for speed measurements
199paramgrill : $(ZSTD_FILES) $(PRGDIR)/util.c $(PRGDIR)/timefn.c $(PRGDIR)/benchfn.c $(PRGDIR)/benchzstd.c $(PRGDIR)/datagen.c paramgrill.c
200 $(CC) $(FLAGS) $^ -lm -o $@$(EXT)
7c673cae
FG
201
202datagen : $(PRGDIR)/datagen.c datagencli.c
9f95a23c 203 $(CC) $(FLAGS) $^ -o $@$(EXT)
7c673cae 204
9f95a23c
TL
205roundTripCrash : $(ZSTD_OBJECTS) roundTripCrash.c
206 $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
7c673cae 207
9f95a23c
TL
208longmatch : $(ZSTD_OBJECTS) longmatch.c
209 $(CC) $(FLAGS) $^ -o $@$(EXT)
7c673cae 210
f67539c2
TL
211bigdict: $(ZSTDMT_OBJECTS) $(PRGDIR)/datagen.c bigdict.c
212 $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
213
9f95a23c
TL
214invalidDictionaries : $(ZSTD_OBJECTS) invalidDictionaries.c
215 $(CC) $(FLAGS) $^ -o $@$(EXT)
11fdf7f2 216
9f95a23c 217legacy : CPPFLAGS += -I$(ZSTDDIR)/legacy -DZSTD_LEGACY_SUPPORT=4
11fdf7f2 218legacy : $(ZSTD_FILES) $(wildcard $(ZSTDDIR)/legacy/*.c) legacy.c
9f95a23c 219 $(CC) $(FLAGS) $^ -o $@$(EXT)
11fdf7f2 220
9f95a23c
TL
221decodecorpus : $(filter-out zstdc_zstd_compress.o, $(ZSTD_OBJECTS)) $(ZDICT_FILES) $(PRGDIR)/util.c $(PRGDIR)/timefn.c decodecorpus.c
222 $(CC) $(FLAGS) $^ -o $@$(EXT) -lm
11fdf7f2 223
9f95a23c 224poolTests : $(PRGDIR)/util.c $(PRGDIR)/timefn.c poolTests.c $(ZSTDDIR)/common/pool.c $(ZSTDDIR)/common/threading.c $(ZSTDDIR)/common/zstd_common.c $(ZSTDDIR)/common/error_private.c
11fdf7f2
TL
225 $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT)
226
9f95a23c 227.PHONY: versionsTest
11fdf7f2 228versionsTest: clean
7c673cae
FG
229 $(PYTHON) test-zstd-versions.py
230
f67539c2
TL
231automated_benchmarking: clean
232 $(PYTHON) automated_benchmarking.py
233
9f95a23c
TL
234checkTag: checkTag.c $(ZSTDDIR)/zstd.h
235 $(CC) $(FLAGS) $< -o $@$(EXT)
236
7c673cae 237clean:
11fdf7f2 238 $(MAKE) -C $(ZSTDDIR) clean
9f95a23c 239 $(MAKE) -C $(PRGDIR) clean
7c673cae 240 @$(RM) -fR $(TESTARTEFACT)
f67539c2
TL
241 @$(RM) -rf tmp* # some test directories are named tmp*
242 @$(RM) core *.o *.tmp result* *.gcda dictionary *.zst \
7c673cae
FG
243 $(PRGDIR)/zstd$(EXT) $(PRGDIR)/zstd32$(EXT) \
244 fullbench$(EXT) fullbench32$(EXT) \
245 fullbench-lib$(EXT) fullbench-dll$(EXT) \
246 fuzzer$(EXT) fuzzer32$(EXT) zbufftest$(EXT) zbufftest32$(EXT) \
9f95a23c 247 fuzzer-dll$(EXT) zstreamtest-dll$(EXT) zbufftest-dll$(EXT) \
11fdf7f2
TL
248 zstreamtest$(EXT) zstreamtest32$(EXT) \
249 datagen$(EXT) paramgrill$(EXT) roundTripCrash$(EXT) longmatch$(EXT) \
250 symbols$(EXT) invalidDictionaries$(EXT) legacy$(EXT) poolTests$(EXT) \
f67539c2 251 decodecorpus$(EXT) checkTag$(EXT) bigdict$(EXT)
7c673cae
FG
252 @echo Cleaning completed
253
254
255#----------------------------------------------------------------------------------
f67539c2 256# valgrind tests are validated only for some posix platforms
7c673cae 257#----------------------------------------------------------------------------------
11fdf7f2 258ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
7c673cae
FG
259HOST_OS = POSIX
260
11fdf7f2 261valgrindTest: VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1
7c673cae
FG
262valgrindTest: zstd datagen fuzzer fullbench
263 @echo "\n ---- valgrind tests : memory analyzer ----"
264 $(VALGRIND) ./datagen -g50M > $(VOID)
265 $(VALGRIND) $(PRGDIR)/zstd ; if [ $$? -eq 0 ] ; then echo "zstd without argument should have failed"; false; fi
266 ./datagen -g80 | $(VALGRIND) $(PRGDIR)/zstd - -c > $(VOID)
267 ./datagen -g16KB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
268 ./datagen -g2930KB | $(VALGRIND) $(PRGDIR)/zstd -5 -vf - -o tmp
269 $(VALGRIND) $(PRGDIR)/zstd -vdf tmp -c > $(VOID)
270 ./datagen -g64MB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
271 @rm tmp
272 $(VALGRIND) ./fuzzer -T1mn -t1
273 $(VALGRIND) ./fullbench -i1
274
275endif
276
277
f67539c2 278ifneq (,$(filter MINGW% MSYS%,$(shell uname)))
7c673cae
FG
279HOST_OS = MSYS
280endif
281
282
11fdf7f2
TL
283#-----------------------------------------------------------------------------
284# make tests validated only for below targets
285#-----------------------------------------------------------------------------
7c673cae 286ifneq (,$(filter $(HOST_OS),MSYS POSIX))
11fdf7f2
TL
287
288DIFF:=diff
289ifneq (,$(filter $(shell uname),SunOS))
290DIFF:=gdiff
291endif
292
9f95a23c
TL
293.PHONY: list
294list:
295 @$(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
7c673cae 296
9f95a23c 297.PHONY: shortest
11fdf7f2
TL
298shortest: ZSTDRTTEST=
299shortest: test-zstd
300
9f95a23c 301.PHONY: fuzztest
11fdf7f2
TL
302fuzztest: test-fuzzer test-zstream test-decodecorpus
303
9f95a23c 304.PHONY: test
11fdf7f2
TL
305test: test-zstd test-fullbench test-fuzzer test-zstream test-invalidDictionaries test-legacy test-decodecorpus
306ifeq ($(QEMU_SYS),)
307test: test-pool
308endif
7c673cae
FG
309
310test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zstream32
311
11fdf7f2 312test-all: test test32 valgrindTest test-decodecorpus-cli
7c673cae 313
9f95a23c
TL
314
315.PHONY: test-zstd test-zstd32 test-zstd-nolegacy test-zstdgrep
7c673cae 316test-zstd: ZSTD = $(PRGDIR)/zstd
9f95a23c 317test-zstd: zstd
7c673cae
FG
318
319test-zstd32: ZSTD = $(PRGDIR)/zstd32
9f95a23c 320test-zstd32: zstd32
7c673cae 321
11fdf7f2 322test-zstd-nolegacy: ZSTD = $(PRGDIR)/zstd-nolegacy
9f95a23c
TL
323test-zstd-nolegacy: zstd-nolegacy
324
325test-zstd test-zstd32 test-zstd-nolegacy: datagen
326 file $(ZSTD)
f67539c2 327 EXE_PREFIX="$(QEMU_SYS)" ZSTD_BIN="$(ZSTD)" DATAGEN_BIN=./datagen ./playTests.sh $(ZSTDRTTEST)
9f95a23c 328
7c673cae
FG
329
330test-gzstd: gzstd
11fdf7f2
TL
331 $(PRGDIR)/zstd -f README.md test-zstd-speed.py
332 gzip -f README.md test-zstd-speed.py
7c673cae
FG
333 cat README.md.zst test-zstd-speed.py.gz >zstd_gz.zst
334 cat README.md.gz test-zstd-speed.py.zst >gz_zstd.gz
11fdf7f2
TL
335 $(PRGDIR)/zstd -df README.md.gz -o README2.md
336 $(PRGDIR)/zstd -df README.md.gz test-zstd-speed.py.gz
337 $(PRGDIR)/zstd -df zstd_gz.zst gz_zstd.gz
338 $(DIFF) -q zstd_gz gz_zstd
7c673cae
FG
339 echo Hello World ZSTD | $(PRGDIR)/zstd -c - >hello.zst
340 echo Hello World GZIP | gzip -c - >hello.gz
341 echo Hello World TEXT >hello.txt
342 cat hello.zst hello.gz hello.txt >hello_zst_gz_txt.gz
343 $(PRGDIR)/zstd -dcf hello.*
344 $(PRGDIR)/zstd -dcf - <hello_zst_gz_txt.gz
11fdf7f2 345 $(RM) *.gz *.zst README2.md gz_zstd zstd_gz hello.txt
7c673cae 346
9f95a23c
TL
347test-zstdgrep: gzstd
348 -[ -f /tmp/zstdcat ] || ln -s $(PWD)/$(PRGDIR)/zstd /tmp/zstdcat
349 echo a | $(PRGDIR)/zstd | env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep a
350 echo a | $(PRGDIR)/zstd | env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep b && return 1 || return 0
351 -echo 'hello world' > test.txt && $(PRGDIR)/zstd test.txt
352 env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep hello test.txt.zst
353 env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep weird test.txt.zst && return 1 || return 0
f67539c2
TL
354 -echo 'hello' > pattern.txt
355 env ZCAT=/tmp/zstdcat $(PRGDIR)/zstdgrep -f pattern.txt test.txt.zst
356 $(RM) test.txt test.txt.zst pattern.txt
9f95a23c 357
7c673cae
FG
358test-fullbench: fullbench datagen
359 $(QEMU_SYS) ./fullbench -i1
360 $(QEMU_SYS) ./fullbench -i1 -P0
361
362test-fullbench32: fullbench32 datagen
363 $(QEMU_SYS) ./fullbench32 -i1
364 $(QEMU_SYS) ./fullbench32 -i1 -P0
365
366test-fuzzer: fuzzer
9f95a23c
TL
367 $(QEMU_SYS) ./fuzzer -v $(FUZZERTEST) $(FUZZER_FLAGS)
368
369test-fuzzer-stackmode: MOREFLAGS += -DZSTD_HEAPMODE=0
370test-fuzzer-stackmode: test-fuzzer
7c673cae
FG
371
372test-fuzzer32: fuzzer32
9f95a23c 373 $(QEMU_SYS) ./fuzzer32 -v $(FUZZERTEST) $(FUZZER_FLAGS)
7c673cae
FG
374
375test-zbuff: zbufftest
376 $(QEMU_SYS) ./zbufftest $(ZSTREAM_TESTTIME)
377
378test-zbuff32: zbufftest32
379 $(QEMU_SYS) ./zbufftest32 $(ZSTREAM_TESTTIME)
380
381test-zstream: zstreamtest
9f95a23c 382 $(QEMU_SYS) ./zstreamtest -v $(ZSTREAM_TESTTIME) $(FUZZER_FLAGS)
11fdf7f2
TL
383 $(QEMU_SYS) ./zstreamtest --mt -t1 $(ZSTREAM_TESTTIME) $(FUZZER_FLAGS)
384 $(QEMU_SYS) ./zstreamtest --newapi -t1 $(ZSTREAM_TESTTIME) $(FUZZER_FLAGS)
7c673cae
FG
385
386test-zstream32: zstreamtest32
11fdf7f2 387 $(QEMU_SYS) ./zstreamtest32 $(ZSTREAM_TESTTIME) $(FUZZER_FLAGS)
7c673cae
FG
388
389test-longmatch: longmatch
390 $(QEMU_SYS) ./longmatch
391
f67539c2
TL
392test-bigdict: bigdict
393 $(QEMU_SYS) ./bigdict
394
11fdf7f2
TL
395test-invalidDictionaries: invalidDictionaries
396 $(QEMU_SYS) ./invalidDictionaries
397
11fdf7f2
TL
398test-legacy: legacy
399 $(QEMU_SYS) ./legacy
400
401test-decodecorpus: decodecorpus
402 $(QEMU_SYS) ./decodecorpus -t $(DECODECORPUS_TESTTIME)
403
404test-decodecorpus-cli: decodecorpus
405 @echo "\n ---- decodecorpus basic cli tests ----"
406 @mkdir testdir
407 ./decodecorpus -n5 -otestdir -ptestdir
408 @cd testdir && \
409 $(ZSTD) -d z000000.zst -o tmp0 && \
410 $(ZSTD) -d z000001.zst -o tmp1 && \
411 $(ZSTD) -d z000002.zst -o tmp2 && \
412 $(ZSTD) -d z000003.zst -o tmp3 && \
413 $(ZSTD) -d z000004.zst -o tmp4 && \
414 diff z000000 tmp0 && \
415 diff z000001 tmp1 && \
416 diff z000002 tmp2 && \
417 diff z000003 tmp3 && \
418 diff z000004 tmp4 && \
419 rm ./* && \
420 cd ..
421 @echo "\n ---- decodecorpus dictionary cli tests ----"
422 ./decodecorpus -n5 -otestdir -ptestdir --use-dict=1MB
423 @cd testdir && \
424 $(ZSTD) -d z000000.zst -D dictionary -o tmp0 && \
425 $(ZSTD) -d z000001.zst -D dictionary -o tmp1 && \
426 $(ZSTD) -d z000002.zst -D dictionary -o tmp2 && \
427 $(ZSTD) -d z000003.zst -D dictionary -o tmp3 && \
428 $(ZSTD) -d z000004.zst -D dictionary -o tmp4 && \
429 diff z000000 tmp0 && \
430 diff z000001 tmp1 && \
431 diff z000002 tmp2 && \
432 diff z000003 tmp3 && \
433 diff z000004 tmp4 && \
434 cd ..
435 @rm -rf testdir
436
437test-pool: poolTests
438 $(QEMU_SYS) ./poolTests
439
440test-lz4: ZSTD = LD_LIBRARY_PATH=/usr/local/lib $(PRGDIR)/zstd
441test-lz4: ZSTD_LZ4 = LD_LIBRARY_PATH=/usr/local/lib ./lz4
442test-lz4: ZSTD_UNLZ4 = LD_LIBRARY_PATH=/usr/local/lib ./unlz4
9f95a23c
TL
443test-lz4: zstd decodecorpus datagen
444 [ -f lz4 ] || ln -s $(PRGDIR)/zstd lz4
445 [ -f unlz4 ] || ln -s $(PRGDIR)/zstd unlz4
11fdf7f2
TL
446
447 ./decodecorpus -ptmp
448 # lz4 -> zstd
449 lz4 < tmp | \
450 $(ZSTD) -d | \
451 cmp - tmp
452 lz4 < tmp | \
453 $(ZSTD_UNLZ4) | \
454 cmp - tmp
455 # zstd -> lz4
456 $(ZSTD) --format=lz4 < tmp | \
457 lz4 -d | \
458 cmp - tmp
459 $(ZSTD_LZ4) < tmp | \
460 lz4 -d | \
461 cmp - tmp
462 # zstd -> zstd
463 $(ZSTD) --format=lz4 < tmp | \
464 $(ZSTD) -d | \
465 cmp - tmp
466 # zstd -> zstd
467 $(ZSTD) < tmp | \
468 $(ZSTD) -d | \
469 cmp - tmp
470
9f95a23c
TL
471 ./datagen -g384KB | $(ZSTD) --format=lz4 | $(ZSTD) -d > /dev/null
472
11fdf7f2
TL
473 rm tmp lz4 unlz4
474
7c673cae 475endif