pw_fuzzer: Fix fuzz target unit tests
The path for the fuzzer unit test source was not source absolute.
Additionally, we need to provide a stub implementation of
FuzzedDataProvider when not using clang.
Change-Id: I440125b5aa86b6c1d1a194c399d8de6f53f58d48
diff --git a/pw_fuzzer/BUILD.gn b/pw_fuzzer/BUILD.gn
index 36f4cb4..479fcb8 100644
--- a/pw_fuzzer/BUILD.gn
+++ b/pw_fuzzer/BUILD.gn
@@ -21,8 +21,12 @@
pw_sanitizer = ""
}
+config("default_config") {
+ include_dirs = [ "public" ]
+}
+
# This is added automatically by the `pw_fuzzer` template.
-config("pw_fuzzer") {
+config("fuzzing") {
common_flags = [ "-fsanitize=fuzzer" ]
if (pw_sanitizer != "") {
common_flags += [ "-fsanitize=$pw_sanitizer" ]
@@ -31,6 +35,22 @@
ldflags = common_flags
}
+source_set("pw_fuzzer") {
+ public_configs = [ ":default_config" ]
+ public = [ "public/pw_fuzzer/fuzzed_data_provider.h" ]
+ sources = public
+ public_deps = [ "$dir_pw_log" ]
+}
+
+# See https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode
+config("fuzzing_build_mode_unsafe_for_production") {
+ defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ]
+}
+
+config("fuzzing_verbose_logging") {
+ defines = [ "FUZZING_VERBOSE_LOGGING" ]
+}
+
pw_doc_group("docs") {
inputs = [ "doc_resources/pw_fuzzer_coverage_guided.png" ]
sources = [ "docs.rst" ]