]>
Commit | Line | Data |
---|---|---|
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 |
22 | ZSTDDIR = ../lib |
23 | PRGDIR = ../programs | |
24 | PYTHON ?= python3 | |
9f95a23c | 25 | TESTARTEFACT := versionsTest |
7c673cae | 26 | |
11fdf7f2 | 27 | DEBUGLEVEL ?= 1 |
9f95a23c | 28 | DEBUGFLAGS = -g -DDEBUGLEVEL=$(DEBUGLEVEL) |
11fdf7f2 TL |
29 | CPPFLAGS += -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/compress \ |
30 | -I$(ZSTDDIR)/dictBuilder -I$(ZSTDDIR)/deprecated -I$(PRGDIR) | |
9f95a23c TL |
31 | ifeq ($(OS),Windows_NT) # MinGW assumed |
32 | CPPFLAGS += -D__USE_MINGW_ANSI_STDIO # compatibility with %zu formatting | |
33 | endif | |
11fdf7f2 TL |
34 | CFLAGS ?= -O3 |
35 | CFLAGS += -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 |
40 | CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) |
41 | FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) | |
7c673cae FG |
42 | |
43 | ||
44 | ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c | |
11fdf7f2 | 45 | ZSTDCOMP_FILES := $(ZSTDDIR)/compress/*.c |
7c673cae | 46 | ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/*.c |
11fdf7f2 | 47 | ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES) |
7c673cae FG |
48 | ZBUFF_FILES := $(ZSTDDIR)/deprecated/*.c |
49 | ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c | |
50 | ||
9f95a23c TL |
51 | ZSTD_F1 := $(wildcard $(ZSTD_FILES)) |
52 | ZSTD_OBJ1 := $(subst $(ZSTDDIR)/common/,zstdm_,$(ZSTD_F1)) | |
53 | ZSTD_OBJ2 := $(subst $(ZSTDDIR)/compress/,zstdc_,$(ZSTD_OBJ1)) | |
54 | ZSTD_OBJ3 := $(subst $(ZSTDDIR)/decompress/,zstdd_,$(ZSTD_OBJ2)) | |
55 | ZSTD_OBJECTS := $(ZSTD_OBJ3:.c=.o) | |
56 | ||
57 | ZSTDMT_OBJ1 := $(subst $(ZSTDDIR)/common/,zstdmt_m_,$(ZSTD_F1)) | |
58 | ZSTDMT_OBJ2 := $(subst $(ZSTDDIR)/compress/,zstdmt_c_,$(ZSTDMT_OBJ1)) | |
59 | ZSTDMT_OBJ3 := $(subst $(ZSTDDIR)/decompress/,zstdmt_d_,$(ZSTDMT_OBJ2)) | |
60 | ZSTDMT_OBJECTS := $(ZSTDMT_OBJ3:.c=.o) | |
7c673cae | 61 | |
7c673cae FG |
62 | # Define *.exe as extension for Windows systems |
63 | ifneq (,$(filter Windows%,$(OS))) | |
64 | EXT =.exe | |
11fdf7f2 TL |
65 | MULTITHREAD_CPP = -DZSTD_MULTITHREAD |
66 | MULTITHREAD_LD = | |
7c673cae FG |
67 | else |
68 | EXT = | |
11fdf7f2 TL |
69 | MULTITHREAD_CPP = -DZSTD_MULTITHREAD |
70 | MULTITHREAD_LD = -pthread | |
7c673cae | 71 | endif |
11fdf7f2 | 72 | MULTITHREAD = $(MULTITHREAD_CPP) $(MULTITHREAD_LD) |
7c673cae FG |
73 | |
74 | VOID = /dev/null | |
11fdf7f2 TL |
75 | ZSTREAM_TESTTIME ?= -T90s |
76 | FUZZERTEST ?= -T200s | |
77 | ZSTDRTTEST = --test-large-data | |
78 | DECODECORPUS_TESTTIME ?= -T30 | |
7c673cae | 79 | |
9f95a23c | 80 | .PHONY: default all all32 allnothread dll clean test test32 test-all versionsTest |
7c673cae FG |
81 | |
82 | default: fullbench | |
9f95a23c | 83 | @echo $(ZSTDMT_OBJECTS) |
7c673cae | 84 | |
9f95a23c TL |
85 | all: fullbench fuzzer zstreamtest paramgrill datagen decodecorpus roundTripCrash \ |
86 | fullbench-lib poolTests | |
7c673cae | 87 | |
11fdf7f2 | 88 | all32: fullbench32 fuzzer32 zstreamtest32 |
7c673cae | 89 | |
9f95a23c TL |
90 | allnothread: MULTITHREAD_CPP= |
91 | allnothread: MULTITHREAD_LD= | |
11fdf7f2 | 92 | allnothread: fullbench fuzzer paramgrill datagen decodecorpus |
7c673cae | 93 | |
f67539c2 | 94 | # note : broken : requires symbols unavailable from dynamic library |
11fdf7f2 | 95 | dll: fuzzer-dll zstreamtest-dll |
7c673cae | 96 | |
9f95a23c TL |
97 | PHONY: zstd zstd32 zstd-nolegacy # must be phony, only external makefile knows how to build them, or if they need an update |
98 | zstd zstd32 zstd-nolegacy: | |
99 | $(MAKE) -C $(PRGDIR) $@ MOREFLAGS+="$(DEBUGFLAGS)" | |
7c673cae | 100 | |
9f95a23c | 101 | gzstd: |
f67539c2 | 102 | $(MAKE) -C $(PRGDIR) $@ HAVE_ZLIB=1 MOREFLAGS+="$(DEBUGFLAGS)" |
7c673cae | 103 | |
f67539c2 TL |
104 | .PHONY: libzstd |
105 | libzstd : | |
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 |
112 | zstd-staticLib : | |
113 | $(MAKE) -C $(ZSTDDIR) libzstd.a | |
114 | ||
115 | zstdm_%.o : $(ZSTDDIR)/common/%.c | |
116 | $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | |
117 | ||
118 | zstdc_%.o : $(ZSTDDIR)/compress/%.c | |
119 | $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | |
120 | ||
121 | zstdd_%.o : $(ZSTDDIR)/decompress/%.c | |
122 | $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | |
123 | ||
124 | zstdmt%.o : CPPFLAGS += $(MULTITHREAD_CPP) | |
125 | ||
126 | zstdmt_m_%.o : $(ZSTDDIR)/common/%.c | |
127 | $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | |
128 | ||
129 | zstdmt_c_%.o : $(ZSTDDIR)/compress/%.c | |
130 | $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | |
131 | ||
132 | zstdmt_d_%.o : $(ZSTDDIR)/decompress/%.c | |
133 | $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | |
7c673cae | 134 | |
11fdf7f2 TL |
135 | fullbench32: CPPFLAGS += -m32 |
136 | fullbench fullbench32 : CPPFLAGS += $(MULTITHREAD_CPP) | |
137 | fullbench fullbench32 : LDFLAGS += $(MULTITHREAD_LD) | |
9f95a23c TL |
138 | fullbench fullbench32 : DEBUGFLAGS = -DNDEBUG # turn off assert() for speed measurements |
139 | fullbench fullbench32 : $(ZSTD_FILES) | |
140 | fullbench 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 |
143 | fullbench-lib : CPPFLAGS += -DXXH_NAMESPACE=ZSTD_ |
144 | fullbench-lib : zstd-staticLib | |
145 | fullbench-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 |
149 | fullbench-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 |
153 | fuzzer : CPPFLAGS += $(MULTITHREAD_CPP) |
154 | fuzzer : LDFLAGS += $(MULTITHREAD_LD) | |
11fdf7f2 | 155 | fuzzer32: CFLAGS += -m32 |
9f95a23c TL |
156 | fuzzer : $(ZSTDMT_OBJECTS) |
157 | fuzzer32: $(ZSTD_FILES) | |
158 | fuzzer 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 |
162 | fuzzer-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 |
165 | zbufftest zbufftest32 zbufftest-dll : CPPFLAGS += -I$(ZSTDDIR)/deprecated |
166 | zbufftest zbufftest32 zbufftest-dll : CFLAGS += -Wno-deprecated-declarations # required to silence deprecation warnings | |
167 | zbufftest32 : CFLAGS += -m32 | |
168 | zbufftest 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 |
171 | zbufftest-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 |
174 | ZSTREAM_LOCAL_FILES := $(PRGDIR)/datagen.c $(PRGDIR)/util.c $(PRGDIR)/timefn.c seqgen.c zstreamtest.c |
175 | ZSTREAM_PROPER_FILES := $(ZDICT_FILES) $(ZSTREAM_LOCAL_FILES) | |
176 | ZSTREAMFILES := $(ZSTD_FILES) $(ZSTREAM_PROPER_FILES) | |
11fdf7f2 | 177 | zstreamtest32 : CFLAGS += -m32 |
9f95a23c TL |
178 | zstreamtest zstreamtest32 : CPPFLAGS += $(MULTITHREAD_CPP) |
179 | zstreamtest zstreamtest32 : LDFLAGS += $(MULTITHREAD_LD) | |
180 | zstreamtest : $(ZSTDMT_OBJECTS) $(ZSTREAM_PROPER_FILES) | |
11fdf7f2 | 181 | zstreamtest32 : $(ZSTREAMFILES) |
9f95a23c TL |
182 | zstreamtest zstreamtest32 : |
183 | $(CC) $(FLAGS) $^ -o $@$(EXT) | |
11fdf7f2 TL |
184 | |
185 | zstreamtest_asan : CFLAGS += -fsanitize=address | |
186 | zstreamtest_asan : $(ZSTREAMFILES) | |
187 | $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT) | |
188 | ||
189 | zstreamtest_tsan : CFLAGS += -fsanitize=thread | |
190 | zstreamtest_tsan : $(ZSTREAMFILES) | |
191 | $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT) | |
192 | ||
f67539c2 | 193 | # note : broken : requires symbols unavailable from dynamic library |
9f95a23c TL |
194 | zstreamtest-dll : $(ZSTDDIR)/common/xxhash.c # xxh symbols not exposed from dll |
195 | zstreamtest-dll : $(ZSTREAM_LOCAL_FILES) | |
196 | $(CC) $(CPPFLAGS) $(CFLAGS) $(filter %.c,$^) $(LDFLAGS) -o $@$(EXT) | |
7c673cae | 197 | |
9f95a23c TL |
198 | paramgrill : DEBUGFLAGS = # turn off assert() by default for speed measurements |
199 | paramgrill : $(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 | |
202 | datagen : $(PRGDIR)/datagen.c datagencli.c | |
9f95a23c | 203 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
7c673cae | 204 | |
9f95a23c TL |
205 | roundTripCrash : $(ZSTD_OBJECTS) roundTripCrash.c |
206 | $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT) | |
7c673cae | 207 | |
9f95a23c TL |
208 | longmatch : $(ZSTD_OBJECTS) longmatch.c |
209 | $(CC) $(FLAGS) $^ -o $@$(EXT) | |
7c673cae | 210 | |
f67539c2 TL |
211 | bigdict: $(ZSTDMT_OBJECTS) $(PRGDIR)/datagen.c bigdict.c |
212 | $(CC) $(FLAGS) $(MULTITHREAD) $^ -o $@$(EXT) | |
213 | ||
9f95a23c TL |
214 | invalidDictionaries : $(ZSTD_OBJECTS) invalidDictionaries.c |
215 | $(CC) $(FLAGS) $^ -o $@$(EXT) | |
11fdf7f2 | 216 | |
9f95a23c | 217 | legacy : CPPFLAGS += -I$(ZSTDDIR)/legacy -DZSTD_LEGACY_SUPPORT=4 |
11fdf7f2 | 218 | legacy : $(ZSTD_FILES) $(wildcard $(ZSTDDIR)/legacy/*.c) legacy.c |
9f95a23c | 219 | $(CC) $(FLAGS) $^ -o $@$(EXT) |
11fdf7f2 | 220 | |
9f95a23c TL |
221 | decodecorpus : $(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 | 224 | poolTests : $(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 | 228 | versionsTest: clean |
7c673cae FG |
229 | $(PYTHON) test-zstd-versions.py |
230 | ||
f67539c2 TL |
231 | automated_benchmarking: clean |
232 | $(PYTHON) automated_benchmarking.py | |
233 | ||
9f95a23c TL |
234 | checkTag: checkTag.c $(ZSTDDIR)/zstd.h |
235 | $(CC) $(FLAGS) $< -o $@$(EXT) | |
236 | ||
7c673cae | 237 | clean: |
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 | 258 | ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS)) |
7c673cae FG |
259 | HOST_OS = POSIX |
260 | ||
11fdf7f2 | 261 | valgrindTest: VALGRIND = valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 |
7c673cae FG |
262 | valgrindTest: 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 | ||
275 | endif | |
276 | ||
277 | ||
f67539c2 | 278 | ifneq (,$(filter MINGW% MSYS%,$(shell uname))) |
7c673cae FG |
279 | HOST_OS = MSYS |
280 | endif | |
281 | ||
282 | ||
11fdf7f2 TL |
283 | #----------------------------------------------------------------------------- |
284 | # make tests validated only for below targets | |
285 | #----------------------------------------------------------------------------- | |
7c673cae | 286 | ifneq (,$(filter $(HOST_OS),MSYS POSIX)) |
11fdf7f2 TL |
287 | |
288 | DIFF:=diff | |
289 | ifneq (,$(filter $(shell uname),SunOS)) | |
290 | DIFF:=gdiff | |
291 | endif | |
292 | ||
9f95a23c TL |
293 | .PHONY: list |
294 | list: | |
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 |
298 | shortest: ZSTDRTTEST= |
299 | shortest: test-zstd | |
300 | ||
9f95a23c | 301 | .PHONY: fuzztest |
11fdf7f2 TL |
302 | fuzztest: test-fuzzer test-zstream test-decodecorpus |
303 | ||
9f95a23c | 304 | .PHONY: test |
11fdf7f2 TL |
305 | test: test-zstd test-fullbench test-fuzzer test-zstream test-invalidDictionaries test-legacy test-decodecorpus |
306 | ifeq ($(QEMU_SYS),) | |
307 | test: test-pool | |
308 | endif | |
7c673cae FG |
309 | |
310 | test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zstream32 | |
311 | ||
11fdf7f2 | 312 | test-all: test test32 valgrindTest test-decodecorpus-cli |
7c673cae | 313 | |
9f95a23c TL |
314 | |
315 | .PHONY: test-zstd test-zstd32 test-zstd-nolegacy test-zstdgrep | |
7c673cae | 316 | test-zstd: ZSTD = $(PRGDIR)/zstd |
9f95a23c | 317 | test-zstd: zstd |
7c673cae FG |
318 | |
319 | test-zstd32: ZSTD = $(PRGDIR)/zstd32 | |
9f95a23c | 320 | test-zstd32: zstd32 |
7c673cae | 321 | |
11fdf7f2 | 322 | test-zstd-nolegacy: ZSTD = $(PRGDIR)/zstd-nolegacy |
9f95a23c TL |
323 | test-zstd-nolegacy: zstd-nolegacy |
324 | ||
325 | test-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 | |
330 | test-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 |
347 | test-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 |
358 | test-fullbench: fullbench datagen |
359 | $(QEMU_SYS) ./fullbench -i1 | |
360 | $(QEMU_SYS) ./fullbench -i1 -P0 | |
361 | ||
362 | test-fullbench32: fullbench32 datagen | |
363 | $(QEMU_SYS) ./fullbench32 -i1 | |
364 | $(QEMU_SYS) ./fullbench32 -i1 -P0 | |
365 | ||
366 | test-fuzzer: fuzzer | |
9f95a23c TL |
367 | $(QEMU_SYS) ./fuzzer -v $(FUZZERTEST) $(FUZZER_FLAGS) |
368 | ||
369 | test-fuzzer-stackmode: MOREFLAGS += -DZSTD_HEAPMODE=0 | |
370 | test-fuzzer-stackmode: test-fuzzer | |
7c673cae FG |
371 | |
372 | test-fuzzer32: fuzzer32 | |
9f95a23c | 373 | $(QEMU_SYS) ./fuzzer32 -v $(FUZZERTEST) $(FUZZER_FLAGS) |
7c673cae FG |
374 | |
375 | test-zbuff: zbufftest | |
376 | $(QEMU_SYS) ./zbufftest $(ZSTREAM_TESTTIME) | |
377 | ||
378 | test-zbuff32: zbufftest32 | |
379 | $(QEMU_SYS) ./zbufftest32 $(ZSTREAM_TESTTIME) | |
380 | ||
381 | test-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 | |
386 | test-zstream32: zstreamtest32 | |
11fdf7f2 | 387 | $(QEMU_SYS) ./zstreamtest32 $(ZSTREAM_TESTTIME) $(FUZZER_FLAGS) |
7c673cae FG |
388 | |
389 | test-longmatch: longmatch | |
390 | $(QEMU_SYS) ./longmatch | |
391 | ||
f67539c2 TL |
392 | test-bigdict: bigdict |
393 | $(QEMU_SYS) ./bigdict | |
394 | ||
11fdf7f2 TL |
395 | test-invalidDictionaries: invalidDictionaries |
396 | $(QEMU_SYS) ./invalidDictionaries | |
397 | ||
11fdf7f2 TL |
398 | test-legacy: legacy |
399 | $(QEMU_SYS) ./legacy | |
400 | ||
401 | test-decodecorpus: decodecorpus | |
402 | $(QEMU_SYS) ./decodecorpus -t $(DECODECORPUS_TESTTIME) | |
403 | ||
404 | test-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 | ||
437 | test-pool: poolTests | |
438 | $(QEMU_SYS) ./poolTests | |
439 | ||
440 | test-lz4: ZSTD = LD_LIBRARY_PATH=/usr/local/lib $(PRGDIR)/zstd | |
441 | test-lz4: ZSTD_LZ4 = LD_LIBRARY_PATH=/usr/local/lib ./lz4 | |
442 | test-lz4: ZSTD_UNLZ4 = LD_LIBRARY_PATH=/usr/local/lib ./unlz4 | |
9f95a23c TL |
443 | test-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 | 475 | endif |