blob: 2cc2e2c6d5c8d354f04d4db873b02949d2536e84 [file] [log] [blame]
Dan Albert36b6f042015-07-30 16:56:30 -07001###########################################
2## A thin wrapper around BUILD_EXECUTABLE
3## Common flags for fuzz tests are added.
4###########################################
Dan Willemsen3bf15e72016-07-25 16:03:53 -07005$(call record-module-type,FUZZ_TEST)
Dan Albert36b6f042015-07-30 16:56:30 -07006
7ifdef LOCAL_SDK_VERSION
8 $(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.)
9endif
10
Zach Riggle6319dee2017-12-21 16:04:03 -060011my_fuzzer:=libFuzzer
12ifdef LOCAL_FUZZ_ENGINE
13 my_fuzzer:=$(LOCAL_FUZZ_ENGINE)
14else ifdef TARGET_FUZZ_ENGINE
15 my_fuzzer:=$(TARGET_FUZZ_ENGINE)
16endif
17
18
Zach Rigglebe0811f2017-08-21 17:07:42 -040019LOCAL_CFLAGS += -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp
Zach Riggle6319dee2017-12-21 16:04:03 -060020
21ifeq ($(my_fuzzer),libFuzzer)
Dan Austin5567e502017-04-19 10:56:45 -070022LOCAL_STATIC_LIBRARIES += libFuzzer
Zach Riggle6319dee2017-12-21 16:04:03 -060023else ifeq ($(my_fuzzer),honggfuzz)
24LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz
Zach Rigglebcfa37e2018-01-03 13:32:14 -060025LOCAL_REQUIRED_MODULES += honggfuzz
Zach Riggle6319dee2017-12-21 16:04:03 -060026LOCAL_LDFLAGS += \
27 "-Wl,--wrap=strcmp" \
28 "-Wl,--wrap=strcasecmp" \
29 "-Wl,--wrap=strncmp" \
30 "-Wl,--wrap=strncasecmp" \
31 "-Wl,--wrap=strstr" \
32 "-Wl,--wrap=strcasestr" \
33 "-Wl,--wrap=memcmp" \
34 "-Wl,--wrap=bcmp" \
35 "-Wl,--wrap=memmem" \
36 "-Wl,--wrap=ap_cstr_casecmp" \
37 "-Wl,--wrap=ap_cstr_casecmpn" \
38 "-Wl,--wrap=ap_strcasestr" \
39 "-Wl,--wrap=apr_cstr_casecmp" \
40 "-Wl,--wrap=apr_cstr_casecmpn" \
41 "-Wl,--wrap=CRYPTO_memcmp" \
42 "-Wl,--wrap=OPENSSL_memcmp" \
43 "-Wl,--wrap=OPENSSL_strcasecmp" \
44 "-Wl,--wrap=OPENSSL_strncasecmp" \
45 "-Wl,--wrap=xmlStrncmp" \
46 "-Wl,--wrap=xmlStrcmp" \
47 "-Wl,--wrap=xmlStrEqual" \
48 "-Wl,--wrap=xmlStrcasecmp" \
49 "-Wl,--wrap=xmlStrncasecmp" \
50 "-Wl,--wrap=xmlStrstr" \
51 "-Wl,--wrap=xmlStrcasestr"
52else
53$(call pretty-error, Unknown fuzz engine $(my_fuzzer))
54endif
Dan Albert36b6f042015-07-30 16:56:30 -070055
56ifdef LOCAL_MODULE_PATH
57$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE))
58endif
59
60ifdef LOCAL_MODULE_PATH_32
61$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE))
62endif
63
64ifdef LOCAL_MODULE_PATH_64
65$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
66endif
67
Vishwath Mohanb6baba02016-09-02 13:25:59 -070068LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(LOCAL_MODULE)
69LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(LOCAL_MODULE)
Dan Albert36b6f042015-07-30 16:56:30 -070070
71ifndef LOCAL_MULTILIB
72ifndef LOCAL_32_BIT_ONLY
73LOCAL_MULTILIB := both
74endif
75endif
76
Zach Rigglebcfa37e2018-01-03 13:32:14 -060077ifndef LOCAL_STRIP_MODULE
78LOCAL_STRIP_MODULE := keep_symbols
79endif
80
Dan Albert36b6f042015-07-30 16:56:30 -070081include $(BUILD_EXECUTABLE)