Debian Codegraph @

fuzz/GNUmakefile

raw
1 # Standalone makefile for the MyThes libFuzzer harness.
2 # Use the oss-fuzz build.sh in CI; this is for local fuzzing only.
3 #
4 # make CXX=clang++
5 # ./mythes_fuzzer -max_len=65536 corpus/
6 #
7 # Coverage (separate binary without ASAN to keep llvm-cov line mapping clean):
8 #
9 # make coverage # report against corpus/
10 # make coverage CORPUS=/path/to/dir # any libFuzzer corpus
11 # make coverage-html # browsable HTML in coverage-html/
12
13 CXX ?= clang++
14 SANITIZE ?= fuzzer,address,undefined
15 CXXFLAGS ?= -std=c++14 -g -O1 -fsanitize=$(SANITIZE)
16 CPPFLAGS = -I..
17
18 COV_CXXFLAGS = -std=c++14 -g -O1 -fsanitize=fuzzer \
19 -fprofile-instr-generate -fcoverage-mapping
20 LLVM_PROFDATA ?= llvm-profdata
21 LLVM_COV ?= llvm-cov
22 CORPUS ?= corpus
23
24 mythes_fuzzer: mythes_fuzzer.cc ../mythes.cxx ../mythes.hxx
25 $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ mythes_fuzzer.cc ../mythes.cxx
26
27 mythes_fuzzer_cov: mythes_fuzzer.cc ../mythes.cxx ../mythes.hxx
28 $(CXX) $(COV_CXXFLAGS) $(CPPFLAGS) -o $@ mythes_fuzzer.cc ../mythes.cxx
29
30 coverage: mythes_fuzzer_cov
31 rm -f coverage.profraw coverage.profdata
32 LLVM_PROFILE_FILE=coverage.profraw \
33 ./mythes_fuzzer_cov -runs=0 -max_len=4194304 $(CORPUS)
34 $(LLVM_PROFDATA) merge -sparse coverage.profraw -o coverage.profdata
35 $(LLVM_COV) report ./mythes_fuzzer_cov \
36 -instr-profile=coverage.profdata ../mythes.cxx ../mythes.hxx
37
38 coverage-html: coverage
39 $(LLVM_COV) show ./mythes_fuzzer_cov \
40 -instr-profile=coverage.profdata \
41 -format=html -output-dir=coverage-html \
42 ../mythes.cxx ../mythes.hxx
43 @echo "Open coverage-html/index.html"
44
45 clean:
46 rm -f mythes_fuzzer mythes_fuzzer_cov coverage.profraw coverage.profdata
47 rm -rf coverage-html
48
49 .PHONY: clean coverage coverage-html