From 36b6f0472feb176aefff4ecba0a852755582fd43 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 30 Jul 2015 16:56:30 -0700 Subject: [PATCH] Add BUILD(_HOST)?_FUZZ_TEST. These are tests that use LLVM's libFuzzer for testing with a sanitizer. Bug: http://b/22850550 Change-Id: I6eeaff7877b7dd0c30f8910c6f27f5278b27a83d --- core/config.mk | 2 ++ core/fuzz_test.mk | 34 ++++++++++++++++++++++++++++++++++ core/host_fuzz_test.mk | 9 +++++++++ 3 files changed, 45 insertions(+) create mode 100644 core/fuzz_test.mk create mode 100644 core/host_fuzz_test.mk diff --git a/core/config.mk b/core/config.mk index 498c79313..fea3d4b45 100644 --- a/core/config.mk +++ b/core/config.mk @@ -85,6 +85,8 @@ BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk BUILD_NATIVE_BENCHMARK := $(BUILD_SYSTEM)/native_benchmark.mk BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk +BUILD_FUZZ_TEST := $(BUILD_SYSTEM)/fuzz_test.mk +BUILD_HOST_FUZZ_TEST := $(BUILD_SYSTEM)/host_fuzz_test.mk BUILD_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/shared_test_lib.mk BUILD_HOST_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/host_shared_test_lib.mk diff --git a/core/fuzz_test.mk b/core/fuzz_test.mk new file mode 100644 index 000000000..065cc030e --- /dev/null +++ b/core/fuzz_test.mk @@ -0,0 +1,34 @@ +########################################### +## A thin wrapper around BUILD_EXECUTABLE +## Common flags for fuzz tests are added. +########################################### + +ifdef LOCAL_SDK_VERSION + $(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.) +endif + +LOCAL_CFLAGS += -fsanitize-coverage=edge,indirect-calls,8bit-counters +LOCAL_STATIC_LIBRARIES += libLLVMFuzzer + +ifdef LOCAL_MODULE_PATH +$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE)) +endif + +ifdef LOCAL_MODULE_PATH_32 +$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE)) +endif + +ifdef LOCAL_MODULE_PATH_64 +$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE)) +endif + +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) + +ifndef LOCAL_MULTILIB +ifndef LOCAL_32_BIT_ONLY +LOCAL_MULTILIB := both +endif +endif + +include $(BUILD_EXECUTABLE) diff --git a/core/host_fuzz_test.mk b/core/host_fuzz_test.mk new file mode 100644 index 000000000..e917959df --- /dev/null +++ b/core/host_fuzz_test.mk @@ -0,0 +1,9 @@ +################################################ +## A thin wrapper around BUILD_HOST_EXECUTABLE +## Common flags for host fuzz tests are added. +################################################ + +LOCAL_CFLAGS += -fsanitize-coverage=edge,indirect-calls,8bit-counters +LOCAL_STATIC_LIBRARIES += libLLVMFuzzer + +include $(BUILD_HOST_EXECUTABLE)