From 19300183a6f0bac0d23f7a994b40a51e9c90d6e1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 5 Nov 2015 23:08:50 -0800 Subject: [PATCH] [fuzzing] Add build system --- configure.ac | 1 + test/Makefile.am | 2 +- test/fuzzing/Makefile.am | 44 +++++++++++++++++++++++++++++++++++++++ test/fuzzing/README | 2 ++ test/fuzzing/hb-fuzzer.cc | 4 ++-- 5 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 test/fuzzing/Makefile.am diff --git a/configure.ac b/configure.ac index 7e4142be7..b4af3cba3 100644 --- a/configure.ac +++ b/configure.ac @@ -440,6 +440,7 @@ src/hb-ucdn/Makefile util/Makefile test/Makefile test/api/Makefile +test/fuzzing/Makefile test/shaping/Makefile docs/Makefile docs/version.xml diff --git a/test/Makefile.am b/test/Makefile.am index bbd8e5f72..ec7782260 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,6 +1,6 @@ # Process this file with automake to produce Makefile.in -SUBDIRS = api shaping +SUBDIRS = api shaping fuzzing # Convenience targets: lib: diff --git a/test/fuzzing/Makefile.am b/test/fuzzing/Makefile.am new file mode 100644 index 000000000..5bd69214d --- /dev/null +++ b/test/fuzzing/Makefile.am @@ -0,0 +1,44 @@ +# Process this file with automake to produce Makefile.in + +NULL = +EXTRA_DIST = +CLEANFILES = +DISTCLEANFILES = +MAINTAINERCLEANFILES = + +# Convenience targets: +lib: + @$(MAKE) $(AM_MAKEFLAGS) -C $(top_builddir)/src lib + +EXTRA_DIST += \ + README \ + $(NULL) + +noinst_PROGRAMS = \ + hb-fuzzer \ + $(NULL) +check_PROGRAMS = $(noinst_PROGRAMS) + +AM_CPPFLAGS = \ + -DHB_DISABLE_DEPRECATED \ + -I$(top_srcdir)/src/ \ + -I$(top_builddir)/src/ \ + $(NULL) +LDADD = \ + $(top_builddir)/src/libharfbuzz.la \ + $(NULL) + +hb_fuzzer_SOURCES = \ + hb-fuzzer.cc \ + $(NULL) +hb_fuzzer_LDADD = \ + $(LDADD) \ + $(NULL) +hb_fuzzer_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -DMAIN \ + -DHB_MAX_NESTING_LEVEL=3 \ + -DHB_SANITIZE_MAX_EDITS=3 \ + $(NULL) + +-include $(top_srcdir)/git.mk diff --git a/test/fuzzing/README b/test/fuzzing/README index 2e537f637..47347db27 100644 --- a/test/fuzzing/README +++ b/test/fuzzing/README @@ -5,6 +5,8 @@ harfbuzz/test/fuzzing/hb-fuzzer.cc with: - With -fsanitize-coverage=edge[,8bit-counters,trace-cmp] - With various defines that limit worst case exponential behavior: * -DHB_MAX_NESTING_LEVEL=3 + * -DHB_SANITIZE_MAX_EDITS=3 + * See Makefile.am for full list of flags - link against libFuzzer To run the fuzzer one needs to first obtain a test corpus as a directory diff --git a/test/fuzzing/hb-fuzzer.cc b/test/fuzzing/hb-fuzzer.cc index d0efae841..141256785 100644 --- a/test/fuzzing/hb-fuzzer.cc +++ b/test/fuzzing/hb-fuzzer.cc @@ -1,6 +1,6 @@ #include -#include "src/hb.h" -#include "src/hb-ot.h" +#include +#include extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { const char text[] = "ABCDEXYZ123@_%&)*$!";