hostapd/tests/fuzzing/rules.include
Jouni Malinen d438b4a3ce 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>
2019-06-11 06:34:19 +03:00

93 lines
1.6 KiB
Text

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
CFLAGS += -DTEST_LIBFUZZER
LDFLAGS += $(FUZZ_FLAGS)
endif
ifndef CC
CC=gcc
endif
ifndef LDO
LDO=$(CC)
endif
WPAS_SRC=../../../wpa_supplicant
SRC=../../../src
CFLAGS += -I$(SRC) -I$(SRC)/utils -I$(WPAS_SRC)
OBJS += ../fuzzer-common.o
$(SRC)/ap/libap.a:
$(MAKE) -C $(SRC)/ap TEST_FUZZ=y
$(SRC)/common/libcommon.a:
$(MAKE) -C $(SRC)/common
$(SRC)/crypto/libcrypto.a:
$(MAKE) -C $(SRC)/crypto TEST_FUZZ=y
$(SRC)/eapol_auth/libeapol_auth.a:
$(MAKE) -C $(SRC)/eapol_auth
$(SRC)/eapol_supp/libeapol_supp.a:
$(MAKE) -C $(SRC)/eapol_supp
$(SRC)/eap_common/libeap_common.a:
$(MAKE) -C $(SRC)/eap_common
$(SRC)/eap_peer/libeap_peer.a:
$(MAKE) -C $(SRC)/eap_peer
$(SRC)/eap_server/libeap_server.a:
$(MAKE) -C $(SRC)/eap_server
$(SRC)/l2_packet/libl2_packet.a:
$(MAKE) -C $(SRC)/l2_packet
$(SRC)/p2p/libp2p.a:
$(MAKE) -C $(SRC)/p2p
$(SRC)/radius/libradius.a:
$(MAKE) -C $(SRC)/radius
$(SRC)/rsn_supp/librsn_supp.a:
$(MAKE) -C $(SRC)/rsn_supp TEST_FUZZ=y
$(SRC)/tls/libtls.a:
$(MAKE) -C $(SRC)/tls TEST_FUZZ=y
$(SRC)/utils/libutils.a:
$(MAKE) -C $(SRC)/utils TEST_FUZZ=y
$(SRC)/wps/libwps.a:
$(MAKE) -C $(SRC)/wps
Q=@
E=echo
ifeq ($(V), 1)
Q=
E=true
endif
ifeq ($(QUIET), 1)
Q=@
E=true
endif
%.o: %.c
$(Q)$(CC) -c -o $@ $(CFLAGS) $<
@$(E) " CC " $<