]> git.proxmox.com Git - ceph.git/blob - ceph/src/zstd/tests/Makefile
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / zstd / tests / Makefile
1 # ##########################################################################
2 # Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
3 # All rights reserved.
4 #
5 # This source code is licensed under the BSD-style license found in the
6 # LICENSE file in the root directory of this source tree. An additional grant
7 # of patent rights can be found in the PATENTS file in the same directory.
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 DESTDIR?=
22 PREFIX ?= /usr/local
23 BINDIR = $(PREFIX)/bin
24 MANDIR = $(PREFIX)/share/man/man1
25 ZSTDDIR = ../lib
26 PRGDIR = ../programs
27 PYTHON ?= python3
28 TESTARTEFACT := versionsTest namespaceTest
29
30
31 CPPFLAGS= -I$(ZSTDDIR) -I$(ZSTDDIR)/common -I$(ZSTDDIR)/dictBuilder -I$(PRGDIR)
32 CFLAGS ?= -O3
33 CFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow -Wstrict-aliasing=1 \
34 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef
35 CFLAGS += $(MOREFLAGS)
36 FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
37
38
39 ZSTDCOMMON_FILES := $(ZSTDDIR)/common/*.c
40 ZSTDCOMP_FILES := $(ZSTDDIR)/compress/*.c
41 ZSTDDECOMP_FILES := $(ZSTDDIR)/decompress/*.c
42 ZSTD_FILES := $(ZSTDDECOMP_FILES) $(ZSTDCOMMON_FILES) $(ZSTDCOMP_FILES)
43 ZBUFF_FILES := $(ZSTDDIR)/deprecated/*.c
44 ZDICT_FILES := $(ZSTDDIR)/dictBuilder/*.c
45
46
47
48 # Define *.exe as extension for Windows systems
49 ifneq (,$(filter Windows%,$(OS)))
50 EXT =.exe
51 else
52 EXT =
53 endif
54
55 VOID = /dev/null
56 ZSTREAM_TESTTIME = -T2mn
57 FUZZERTEST= -T5mn
58 ZSTDRTTEST= --test-large-data
59
60 .PHONY: default all all32 clean test test32 test-all namespaceTest versionsTest
61
62 default: fullbench
63
64 all: fullbench fuzzer zstreamtest paramgrill datagen zbufftest
65
66 all32: fullbench32 fuzzer32 zstreamtest32 zbufftest32
67
68
69
70 zstd:
71 $(MAKE) -C $(PRGDIR) $@
72
73 zstd32:
74 $(MAKE) -C $(PRGDIR) $@
75
76 zstd-nolegacy:
77 $(MAKE) -C $(PRGDIR) $@
78
79 gzstd:
80 $(MAKE) -C $(PRGDIR) $@
81
82 fullbench : $(ZSTD_FILES) $(PRGDIR)/datagen.c fullbench.c
83 $(CC) $(FLAGS) $^ -o $@$(EXT)
84
85 fullbench32 : $(ZSTD_FILES) $(PRGDIR)/datagen.c fullbench.c
86 $(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
87
88 fullbench-lib: $(PRGDIR)/datagen.c fullbench.c
89 $(MAKE) -C $(ZSTDDIR) libzstd.a
90 $(CC) $(FLAGS) $^ -o $@$(EXT) $(ZSTDDIR)/libzstd.a
91
92 fullbench-dll: $(PRGDIR)/datagen.c fullbench.c
93 $(MAKE) -C $(ZSTDDIR) libzstd
94 $(CC) $(FLAGS) $^ -o $@$(EXT) -DZSTD_DLL_IMPORT=1 $(ZSTDDIR)/dll/libzstd.dll
95
96 fuzzer : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c fuzzer.c
97 $(CC) $(FLAGS) $^ -o $@$(EXT)
98
99 fuzzer32 : $(ZSTD_FILES) $(ZDICT_FILES) $(PRGDIR)/datagen.c fuzzer.c
100 $(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
101
102 zbufftest : CPPFLAGS += -I$(ZSTDDIR)/deprecated
103 zbufftest : CFLAGS += -Wno-deprecated-declarations # required to silence deprecation warnings
104 zbufftest : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c zbufftest.c
105 $(CC) $(FLAGS) $^ -o $@$(EXT)
106
107 zbufftest32 : CPPFLAGS += -I$(ZSTDDIR)/deprecated
108 zbufftest32 : CFLAGS += -Wno-deprecated-declarations -m32
109 zbufftest32 : $(ZSTD_FILES) $(ZBUFF_FILES) $(PRGDIR)/datagen.c zbufftest.c
110 $(CC) $(FLAGS) $^ -o $@$(EXT)
111
112 zstreamtest : $(ZSTD_FILES) $(PRGDIR)/datagen.c zstreamtest.c
113 $(CC) $(FLAGS) $^ -o $@$(EXT)
114
115 zstreamtest32 : $(ZSTD_FILES) $(PRGDIR)/datagen.c zstreamtest.c
116 $(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
117
118 paramgrill : $(ZSTD_FILES) $(PRGDIR)/datagen.c paramgrill.c
119 $(CC) $(FLAGS) $^ -lm -o $@$(EXT)
120
121 datagen : $(PRGDIR)/datagen.c datagencli.c
122 $(CC) $(FLAGS) $^ -o $@$(EXT)
123
124 roundTripCrash : $(ZSTD_FILES) roundTripCrash.c
125 $(CC) $(FLAGS) $^ -o $@$(EXT)
126
127 longmatch : $(ZSTD_FILES) longmatch.c
128 $(CC) $(FLAGS) $^ -o $@$(EXT)
129
130 namespaceTest:
131 if $(CC) namespaceTest.c ../lib/common/xxhash.c -o $@ ; then echo compilation should fail; exit 1 ; fi
132 $(RM) $@
133
134 versionsTest:
135 $(PYTHON) test-zstd-versions.py
136
137 clean:
138 $(MAKE) -C ../lib clean
139 @$(RM) -fR $(TESTARTEFACT)
140 @$(RM) -f core *.o tmp* result* *.gcda dictionary *.zst \
141 $(PRGDIR)/zstd$(EXT) $(PRGDIR)/zstd32$(EXT) \
142 fullbench$(EXT) fullbench32$(EXT) \
143 fullbench-lib$(EXT) fullbench-dll$(EXT) \
144 fuzzer$(EXT) fuzzer32$(EXT) zbufftest$(EXT) zbufftest32$(EXT) \
145 zstreamtest$(EXT) zstreamtest32$(EXT) \
146 datagen$(EXT) paramgrill$(EXT) roundTripCrash$(EXT) longmatch$(EXT)
147 @echo Cleaning completed
148
149
150 #----------------------------------------------------------------------------------
151 #make valgrindTest is validated only for Linux, OSX, kFreeBSD, Hurd and some BSD targets
152 #----------------------------------------------------------------------------------
153 ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD DragonFly))
154 HOST_OS = POSIX
155
156 valgrindTest: VALGRIND = valgrind --leak-check=full --error-exitcode=1
157 valgrindTest: zstd datagen fuzzer fullbench
158 @echo "\n ---- valgrind tests : memory analyzer ----"
159 $(VALGRIND) ./datagen -g50M > $(VOID)
160 $(VALGRIND) $(PRGDIR)/zstd ; if [ $$? -eq 0 ] ; then echo "zstd without argument should have failed"; false; fi
161 ./datagen -g80 | $(VALGRIND) $(PRGDIR)/zstd - -c > $(VOID)
162 ./datagen -g16KB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
163 ./datagen -g2930KB | $(VALGRIND) $(PRGDIR)/zstd -5 -vf - -o tmp
164 $(VALGRIND) $(PRGDIR)/zstd -vdf tmp -c > $(VOID)
165 ./datagen -g64MB | $(VALGRIND) $(PRGDIR)/zstd -vf - -c > $(VOID)
166 @rm tmp
167 $(VALGRIND) ./fuzzer -T1mn -t1
168 $(VALGRIND) ./fullbench -i1
169
170 endif
171
172
173 ifneq (,$(filter MSYS%,$(shell uname)))
174 HOST_OS = MSYS
175 endif
176
177
178 #------------------------------------------------------------------------
179 #make tests validated only for MSYS, Linux, OSX, kFreeBSD and Hurd targets
180 #------------------------------------------------------------------------
181 ifneq (,$(filter $(HOST_OS),MSYS POSIX))
182 zstd-playTests: datagen
183 file $(ZSTD)
184 ZSTD="$(QEMU_SYS) $(ZSTD)" ./playTests.sh $(ZSTDRTTEST)
185
186 test: test-zstd test-fullbench test-fuzzer test-zstream test-longmatch
187
188 test32: test-zstd32 test-fullbench32 test-fuzzer32 test-zstream32
189
190 test-all: test test32 valgrindTest
191
192 test-zstd: ZSTD = $(PRGDIR)/zstd
193 test-zstd: zstd zstd-playTests
194
195 test-zstd32: ZSTD = $(PRGDIR)/zstd32
196 test-zstd32: zstd32 zstd-playTests
197
198 test-zstd-nolegacy: ZSTD = $(PRGDIR)/zstd
199 test-zstd-nolegacy: zstd-nolegacy zstd-playTests
200
201 test-gzstd: gzstd
202 $(PRGDIR)/zstd README.md test-zstd-speed.py
203 gzip README.md test-zstd-speed.py
204 cat README.md.zst test-zstd-speed.py.gz >zstd_gz.zst
205 cat README.md.gz test-zstd-speed.py.zst >gz_zstd.gz
206 $(PRGDIR)/zstd -d README.md.gz -o README2.md
207 $(PRGDIR)/zstd -d README.md.gz test-zstd-speed.py.gz
208 $(PRGDIR)/zstd -d zstd_gz.zst gz_zstd.gz
209 diff -q zstd_gz gz_zstd
210 echo Hello World ZSTD | $(PRGDIR)/zstd -c - >hello.zst
211 echo Hello World GZIP | gzip -c - >hello.gz
212 echo Hello World TEXT >hello.txt
213 cat hello.zst hello.gz hello.txt >hello_zst_gz_txt.gz
214 $(PRGDIR)/zstd -dcf hello.*
215 $(PRGDIR)/zstd -dcf - <hello_zst_gz_txt.gz
216
217 test-fullbench: fullbench datagen
218 $(QEMU_SYS) ./fullbench -i1
219 $(QEMU_SYS) ./fullbench -i1 -P0
220
221 test-fullbench32: fullbench32 datagen
222 $(QEMU_SYS) ./fullbench32 -i1
223 $(QEMU_SYS) ./fullbench32 -i1 -P0
224
225 test-fuzzer: fuzzer
226 $(QEMU_SYS) ./fuzzer $(FUZZERTEST)
227
228 test-fuzzer32: fuzzer32
229 $(QEMU_SYS) ./fuzzer32 $(FUZZERTEST)
230
231 test-zbuff: zbufftest
232 $(QEMU_SYS) ./zbufftest $(ZSTREAM_TESTTIME)
233
234 test-zbuff32: zbufftest32
235 $(QEMU_SYS) ./zbufftest32 $(ZSTREAM_TESTTIME)
236
237 test-zstream: zstreamtest
238 $(QEMU_SYS) ./zstreamtest $(ZSTREAM_TESTTIME)
239
240 test-zstream32: zstreamtest32
241 $(QEMU_SYS) ./zstreamtest32 $(ZSTREAM_TESTTIME)
242
243 test-longmatch: longmatch
244 $(QEMU_SYS) ./longmatch
245
246 endif