test: Add llvm libFuzz arguments for builtin clang 6.0

Clang 6.0 has libFuzzer included and different args

Change-Id: Iad7470d13a93c6b5e41de63f634ba8d501eaaa37
Signed-off-by: Greg Tucker <greg.b.tucker@intel.com>
This commit is contained in:
Greg Tucker 2018-03-30 00:25:08 -07:00
parent 0ba5f0f7db
commit 16a5d25988
2 changed files with 14 additions and 7 deletions

View File

@ -133,11 +133,11 @@ $(all_perf_tests): % : %.c $(lib_name)
$(sort $(notdir $(examples))): % : %.c $(lib_name)
$(sort $(notdir $(other_tests))): % : %.c $(lib_name)
$(all_llvm_fuzz_tests): LDLIBS += -lFuzzer
$(all_llvm_fuzz_tests): FUZZLINK = -lFuzzer
$(all_llvm_fuzz_tests): CFLAGS += -fsanitize-coverage=trace-pc-guard -fsanitize=address
$(all_llvm_fuzz_tests): CXXFLAGS += -fsanitize-coverage=trace-pc-guard -fsanitize=address
$(all_llvm_fuzz_tests): % : %.o $(lib_name)
$(CXX) $(CXXFLAGS) $^ $(LDLIBS) -o $@
$(CXX) $(CXXFLAGS) $^ $(LDLIBS) $(FUZZLINK) -o $@
sim test trace: $(addsuffix .run,$(all_unit_tests))

View File

@ -103,13 +103,20 @@ fi
# Optionally build llvm fuzz tests
if [ $use_llvm -ge 0 ]; then
echo Build llvm fuzz tests
if ! ( command -V clang++ > /dev/null &&
echo int LLVMFuzzerTestOneInput\(\)\{return 0\;\} | clang++ -x c - -lFuzzer -lpthread -o /dev/null); then
echo $0 option --llvm requires clang++ and libFuzzer
exit 0
if ( command -V clang++ > /dev/null ); then
if (echo int LLVMFuzzerTestOneInput\(\)\{return 0\;\} | clang++ -x c - -fsanitize=fuzzer,address -lpthread -o /dev/null >& /dev/null); then
echo have modern clang
llvm_link_args='FUZZLINK=-fsanitize=fuzzer,address'
elif (echo int LLVMFuzzerTestOneInput\(\)\{return 0\;\} | clang++ -x c - -lFuzzer -lpthread -o /dev/null >& /dev/null); then
echo have libFuzzer
llvm_link_args='FUZZLINK=-lFuzzer'
else
echo $0 option --llvm requires clang++ and libFuzzer
exit 0
fi
fi
rm -rf bin
make -f Makefile.unx units=igzip llvm_fuzz_tests igzip_dump_inflate_corpus CC=clang CXX=clang++
make -f Makefile.unx units=igzip llvm_fuzz_tests igzip_dump_inflate_corpus CC=clang CXX=clang++ ${llvm_link_args}
fi
# Optionally fill fuzz input with internal tests corpus