1###########################################
2## A thin wrapper around BUILD_EXECUTABLE
3## Common flags for fuzz tests are added.
4###########################################
5$(call record-module-type,FUZZ_TEST)
6
7ifdef LOCAL_SDK_VERSION
8    $(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.)
9endif
10
11my_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
18LOCAL_SANITIZE += fuzzer
19
20ifeq ($(my_fuzzer),libFuzzer)
21LOCAL_STATIC_LIBRARIES += libFuzzer
22else ifeq ($(my_fuzzer),honggfuzz)
23LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz
24LOCAL_REQUIRED_MODULES += honggfuzz
25LOCAL_LDFLAGS += \
26        "-Wl,--wrap=strcmp" \
27        "-Wl,--wrap=strcasecmp" \
28        "-Wl,--wrap=strncmp" \
29        "-Wl,--wrap=strncasecmp" \
30        "-Wl,--wrap=strstr" \
31        "-Wl,--wrap=strcasestr" \
32        "-Wl,--wrap=memcmp" \
33        "-Wl,--wrap=bcmp" \
34        "-Wl,--wrap=memmem" \
35        "-Wl,--wrap=ap_cstr_casecmp" \
36        "-Wl,--wrap=ap_cstr_casecmpn" \
37        "-Wl,--wrap=ap_strcasestr" \
38        "-Wl,--wrap=apr_cstr_casecmp" \
39        "-Wl,--wrap=apr_cstr_casecmpn" \
40        "-Wl,--wrap=CRYPTO_memcmp" \
41        "-Wl,--wrap=OPENSSL_memcmp" \
42        "-Wl,--wrap=OPENSSL_strcasecmp" \
43        "-Wl,--wrap=OPENSSL_strncasecmp" \
44        "-Wl,--wrap=xmlStrncmp" \
45        "-Wl,--wrap=xmlStrcmp" \
46        "-Wl,--wrap=xmlStrEqual" \
47        "-Wl,--wrap=xmlStrcasecmp" \
48        "-Wl,--wrap=xmlStrncasecmp" \
49        "-Wl,--wrap=xmlStrstr" \
50        "-Wl,--wrap=xmlStrcasestr"
51else
52$(call pretty-error, Unknown fuzz engine $(my_fuzzer))
53endif
54
55ifdef LOCAL_MODULE_PATH
56$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE))
57endif
58
59ifdef LOCAL_MODULE_PATH_32
60$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE))
61endif
62
63ifdef LOCAL_MODULE_PATH_64
64$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
65endif
66
67LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(my_fuzzer)/$(LOCAL_MODULE)
68LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(my_fuzzer)/$(LOCAL_MODULE)
69
70ifndef LOCAL_STRIP_MODULE
71LOCAL_STRIP_MODULE := keep_symbols
72endif
73
74include $(BUILD_EXECUTABLE)
75