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