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