• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
18
19LOCAL_CFLAGS += -fsanitize-coverage=trace-pc-guard,indirect-calls,trace-cmp
20
21ifeq ($(my_fuzzer),libFuzzer)
22LOCAL_STATIC_LIBRARIES += libFuzzer
23else ifeq ($(my_fuzzer),honggfuzz)
24LOCAL_STATIC_LIBRARIES += honggfuzz_libhfuzz
25LOCAL_REQUIRED_MODULES += honggfuzz
26LOCAL_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
55
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
68LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(my_fuzzer)/$(LOCAL_MODULE)
69LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/fuzzers/$(my_fuzzer)/$(LOCAL_MODULE)
70
71ifndef LOCAL_MULTILIB
72ifndef LOCAL_32_BIT_ONLY
73LOCAL_MULTILIB := 64
74endif
75endif
76
77ifndef LOCAL_STRIP_MODULE
78LOCAL_STRIP_MODULE := keep_symbols
79endif
80
81include $(BUILD_EXECUTABLE)
82