tests: Fix CFLAGS passing for new fuzzing tools

src/*/Makefile needs to allow additional CFLAGS values to be provided
from the calling Makefiles so that the clang command line arguments to
enable sanitizers consistently. In addition, it can be useful to be able
to provide CC, CFLAGS, and LDFLAGS from external setup while still
requesing LIBFUZZER=y build. Allow that by not overriding these
variables if they are already set.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
Jouni Malinen 2019-06-07 23:57:02 +03:00
parent 009c4d79d3
commit d438b4a3ce
2 changed files with 18 additions and 12 deletions

View file

@ -11,6 +11,7 @@ CFLAGS += -DCONFIG_NO_RANDOM_POOL
CFLAGS += -DTEST_FUZZ CFLAGS += -DTEST_FUZZ
endif endif
CFLAGS += $(FUZZ_CFLAGS)
CFLAGS += -I.. -I../utils CFLAGS += -I.. -I../utils

View file

@ -1,9 +1,21 @@
FUZZ_CFLAGS =
ifdef LIBFUZZER
CC ?= clang
#FUZZ_FLAGS ?= -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
FUZZ_FLAGS ?= -fsanitize=fuzzer,address
ifndef CFLAGS
FUZZ_CFLAGS += $(FUZZ_FLAGS)
endif
endif
FUZZ_CFLAGS += -DCONFIG_NO_RANDOM_POOL -DTEST_FUZZ
export FUZZ_CFLAGS
CFLAGS ?= -MMD -O2 -Wall -g
CFLAGS += $(FUZZ_CFLAGS)
ifdef LIBFUZZER ifdef LIBFUZZER
CC=clang
CFLAGS = -MMD -O2 -Wall -g
CFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow
CFLAGS += -DTEST_LIBFUZZER CFLAGS += -DTEST_LIBFUZZER
LDFLAGS += -fsanitize=fuzzer,address,signed-integer-overflow,unsigned-integer-overflow LDFLAGS += $(FUZZ_FLAGS)
endif endif
ifndef CC ifndef CC
@ -14,13 +26,6 @@ ifndef LDO
LDO=$(CC) LDO=$(CC)
endif endif
ifndef CFLAGS
CFLAGS = -MMD -O2 -Wall -g
endif
CFLAGS += -DCONFIG_NO_RANDOM_POOL
CFLAGS += -DTEST_FUZZ
WPAS_SRC=../../../wpa_supplicant WPAS_SRC=../../../wpa_supplicant
SRC=../../../src SRC=../../../src
@ -34,7 +39,7 @@ $(SRC)/common/libcommon.a:
$(MAKE) -C $(SRC)/common $(MAKE) -C $(SRC)/common
$(SRC)/crypto/libcrypto.a: $(SRC)/crypto/libcrypto.a:
$(MAKE) -C $(SRC)/crypto $(MAKE) -C $(SRC)/crypto TEST_FUZZ=y
$(SRC)/eapol_auth/libeapol_auth.a: $(SRC)/eapol_auth/libeapol_auth.a:
$(MAKE) -C $(SRC)/eapol_auth $(MAKE) -C $(SRC)/eapol_auth