Skip to content

Commit cae7534

Browse files
committed
Run all fuzzers via make fuzz_test
1 parent d412e98 commit cae7534

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ test/test_mbedtls
4343
test/test_wolfssl
4444
test/test_no_tls
4545
test/server_fuzzer
46+
test/client_fuzzer
47+
test/header_parser_fuzzer
48+
test/url_parser_fuzzer
4649
test/test_proxy
4750
test/test_proxy_mbedtls
4851
test/test_proxy_wolfssl

test/Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,35 @@ test_proxy_mbedtls : test_proxy.cc ../httplib.h Makefile cert.pem
251251
test_proxy_wolfssl : test_proxy.cc ../httplib.h Makefile cert.pem
252252
$(CXX) -o $@ -I.. $(CXXFLAGS) test_proxy.cc $(TEST_ARGS_WOLFSSL)
253253

254-
# Runs server_fuzzer.cc based on value of $(LIB_FUZZING_ENGINE).
255-
# Usage: make fuzz_test LIB_FUZZING_ENGINE=/path/to/libFuzzer
256-
fuzz_test: server_fuzzer
257-
./server_fuzzer fuzzing/corpus/*
254+
# Runs all fuzz harnesses based on the value of $(LIB_FUZZING_ENGINE).
255+
# By default LIB_FUZZING_ENGINE is standalone_fuzz_target_runner.o, so each
256+
# fuzzer is replayed over its regression corpus.
257+
# Override for actual fuzzing:
258+
# make fuzz_test LIB_FUZZING_ENGINE=/path/to/libFuzzer
259+
fuzz_test: server_fuzzer client_fuzzer header_parser_fuzzer url_parser_fuzzer
260+
./server_fuzzer fuzzing/corpus/[0-9]* fuzzing/corpus/issue1264 fuzzing/corpus/clusterfuzz-testcase-minimized-server_fuzzer-*
261+
./client_fuzzer fuzzing/corpus/clusterfuzz-testcase-minimized-client_fuzzer-*
262+
./header_parser_fuzzer fuzzing/corpus/clusterfuzz-testcase-minimized-header_parser_fuzzer-*
263+
@matches=$$(find fuzzing/corpus -maxdepth 1 -type f -name 'clusterfuzz-testcase-minimized-url_parser_fuzzer-*'); \
264+
if [ -n "$$matches" ]; then ./url_parser_fuzzer $$matches; else echo "(no url_parser_fuzzer corpus)"; fi
258265

259266
# Fuzz target, so that you can choose which $(LIB_FUZZING_ENGINE) to use.
260267
server_fuzzer : fuzzing/server_fuzzer.cc ../httplib.h standalone_fuzz_target_runner.o
261268
$(CXX) -o $@ -I.. $(CXXFLAGS) $< $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(LIB_FUZZING_ENGINE) $(ZSTD_SUPPORT) $(LIBS)
262269
@file $@
263270

271+
client_fuzzer : fuzzing/client_fuzzer.cc ../httplib.h standalone_fuzz_target_runner.o
272+
$(CXX) -o $@ -I.. $(CXXFLAGS) $< $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(LIB_FUZZING_ENGINE) $(ZSTD_SUPPORT) $(LIBS)
273+
@file $@
274+
275+
header_parser_fuzzer : fuzzing/header_parser_fuzzer.cc ../httplib.h standalone_fuzz_target_runner.o
276+
$(CXX) -o $@ -I.. $(CXXFLAGS) $< $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(LIB_FUZZING_ENGINE) $(ZSTD_SUPPORT) $(LIBS)
277+
@file $@
278+
279+
url_parser_fuzzer : fuzzing/url_parser_fuzzer.cc ../httplib.h standalone_fuzz_target_runner.o
280+
$(CXX) -o $@ -I.. $(CXXFLAGS) $< $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) $(BROTLI_SUPPORT) $(LIB_FUZZING_ENGINE) $(ZSTD_SUPPORT) $(LIBS)
281+
@file $@
282+
264283
# Standalone fuzz runner, which just reads inputs from fuzzing/corpus/ dir and
265284
# feeds it to server_fuzzer.
266285
standalone_fuzz_target_runner.o : fuzzing/standalone_fuzz_target_runner.cpp
@@ -273,5 +292,5 @@ cert.pem:
273292
./gen-certs.sh
274293

275294
clean:
276-
rm -rf test test_split test_mbedtls test_split_mbedtls test_wolfssl test_split_wolfssl test_no_tls, test_split_no_tls test_proxy test_proxy_mbedtls test_proxy_wolfssl test_benchmark server_fuzzer *.pem *.0 *.o *.1 *.srl httplib.h httplib.cc _build* *.dSYM *_shard_*.log cpp-httplib
295+
rm -rf test test_split test_mbedtls test_split_mbedtls test_wolfssl test_split_wolfssl test_no_tls, test_split_no_tls test_proxy test_proxy_mbedtls test_proxy_wolfssl test_benchmark server_fuzzer client_fuzzer header_parser_fuzzer url_parser_fuzzer *.pem *.0 *.o *.1 *.srl httplib.h httplib.cc _build* *.dSYM *_shard_*.log cpp-httplib
277296

0 commit comments

Comments
 (0)