2022-04-28 11:04:07 -04:00
|
|
|
LWIP_COMPONENT_DIR=../
|
|
|
|
|
|
|
|
CFLAGS=-D IDF_VER=\"v3.1\" \
|
|
|
|
-DESP_PLATFORM \
|
|
|
|
-DLWIP_NO_CTYPE_H=1 \
|
|
|
|
-DWITH_POSIX \
|
|
|
|
-fdata-sections \
|
|
|
|
-ffunction-sections \
|
|
|
|
-ggdb \
|
|
|
|
-MMD \
|
|
|
|
-MP \
|
|
|
|
-nostdlib \
|
|
|
|
-Og \
|
|
|
|
-std=gnu99 \
|
|
|
|
-Wall \
|
|
|
|
-Werror=all \
|
|
|
|
-Wextra \
|
|
|
|
-Wno-address \
|
|
|
|
-Wno-constant-conversion \
|
|
|
|
-Wno-error=deprecated-declarations \
|
|
|
|
-Wno-error=unused-function \
|
|
|
|
-Wno-error=unused-variable \
|
|
|
|
-Wno-incompatible-pointer-types \
|
|
|
|
-Wno-incompatible-pointer-types-discards-qualifiers \
|
|
|
|
-Wno-int-to-pointer-cast \
|
|
|
|
-Wno-macro-redefined \
|
|
|
|
-Wno-sign-compare \
|
|
|
|
-Wno-typedef-redefinition \
|
|
|
|
-Wno-unused-parameter \
|
|
|
|
-Wno-unused-variable
|
|
|
|
|
|
|
|
INC_DIRS=-I . \
|
|
|
|
-I ./build/config \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/include/apps \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/include/apps/ping \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/include/apps/sntp \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/lwip/src/include \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/lwip/src/include/netif \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/lwip/src/include/posix \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/lwip/src/include/posix \
|
|
|
|
-I $(LWIP_COMPONENT_DIR)/port/esp32/include
|
|
|
|
|
2018-05-14 09:03:37 -04:00
|
|
|
TEST_NAME=test
|
|
|
|
FUZZ=afl-fuzz
|
2018-09-14 08:30:03 -04:00
|
|
|
GEN_CFG=generate_config
|
2018-05-14 09:03:37 -04:00
|
|
|
LD=$(CC)
|
2018-05-18 09:54:08 -04:00
|
|
|
ifeq ($(MODE),dhcp_client)
|
2022-04-28 11:04:07 -04:00
|
|
|
DEPENDENCY_INJECTION=-include dhcp_di.h
|
|
|
|
OBJECTS=dhcp.o def.o esp32_mock.o test_dhcp_client.o
|
|
|
|
SAMPLE_PACKETS=in_dhcp_client
|
2018-05-18 09:54:08 -04:00
|
|
|
else ifeq ($(MODE),dhcp_server)
|
2022-04-28 11:04:07 -04:00
|
|
|
DEPENDENCY_INJECTION=-include dhcpserver_di.h
|
|
|
|
OBJECTS=dhcpserver.o def.o esp32_mock.o test_dhcp_server.o
|
|
|
|
SAMPLE_PACKETS=in_dhcp_server
|
2018-05-18 09:54:08 -04:00
|
|
|
else ifeq ($(MODE),dns)
|
2022-04-28 11:04:07 -04:00
|
|
|
CFLAGS+=-DNOT_MOCK_DNS
|
|
|
|
DEPENDENCY_INJECTION=-include dns_di.h
|
|
|
|
OBJECTS=dns.o def.o esp32_mock.o test_dns.o
|
|
|
|
SAMPLE_PACKETS=in_dns
|
2018-05-18 09:54:08 -04:00
|
|
|
else
|
2022-04-28 11:04:07 -04:00
|
|
|
$(error Please specify MODE: dhcp_server, dhcp_client, dns)
|
2018-05-15 09:49:10 -04:00
|
|
|
endif
|
2018-05-14 09:03:37 -04:00
|
|
|
|
2018-05-15 09:49:10 -04:00
|
|
|
ifeq ($(INSTR),off)
|
2022-04-28 11:04:07 -04:00
|
|
|
CC=gcc
|
|
|
|
CFLAGS+=-DINSTR_IS_OFF
|
|
|
|
TEST_NAME=test_sim
|
2018-05-14 09:03:37 -04:00
|
|
|
else
|
2022-04-28 11:04:07 -04:00
|
|
|
CC=afl-clang-fast
|
2018-05-14 09:03:37 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS+=$(INC_DIRS)
|
|
|
|
|
|
|
|
all: $(TEST_NAME)
|
|
|
|
|
2018-09-14 08:30:03 -04:00
|
|
|
def.o: ../lwip/src/core/def.c $(GEN_CFG)
|
|
|
|
@echo "[CC] $<"
|
|
|
|
@$(CC) $(CFLAGS) -D BUILDING_DEF $(DEPENDENCY_INJECTION) -c $< -o $@
|
|
|
|
|
|
|
|
dns.o: ../lwip/src/core/dns.c $(GEN_CFG)
|
2018-05-18 09:54:08 -04:00
|
|
|
@echo "[CC] $<"
|
|
|
|
@$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@
|
|
|
|
|
2018-09-14 08:30:03 -04:00
|
|
|
dhcp.o: ../lwip/src/core/ipv4/dhcp.c $(GEN_CFG)
|
2018-05-15 09:49:10 -04:00
|
|
|
@echo "[CC] $<"
|
2018-05-18 09:54:08 -04:00
|
|
|
@$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@
|
2018-05-15 09:49:10 -04:00
|
|
|
|
2018-09-14 08:30:03 -04:00
|
|
|
dhcpserver.o: ../apps/dhcpserver/dhcpserver.c $(GEN_CFG)
|
2018-05-14 09:03:37 -04:00
|
|
|
@echo "[CC] $<"
|
2018-05-18 09:54:08 -04:00
|
|
|
@$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@
|
2018-05-14 09:03:37 -04:00
|
|
|
|
2018-09-14 08:30:03 -04:00
|
|
|
%.o: %.c $(GEN_CFG)
|
2018-05-14 09:03:37 -04:00
|
|
|
@echo "[CC] $<"
|
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
2018-09-14 08:30:03 -04:00
|
|
|
.PHONY: $(GEN_CFG)
|
|
|
|
$(GEN_CFG):
|
|
|
|
$(IDF_PATH)/tools/idf.py reconfigure
|
|
|
|
|
2018-05-14 09:03:37 -04:00
|
|
|
$(TEST_NAME): $(OBJECTS)
|
|
|
|
@echo "[LD] $@"
|
|
|
|
@$(LD) $(OBJECTS) -o $@ $(LDLIBS)
|
|
|
|
|
|
|
|
fuzz: $(TEST_NAME)
|
2018-07-27 03:26:51 -04:00
|
|
|
@$(FUZZ) -t 5000+ -i "$(SAMPLE_PACKETS)" -o "out" -- ./$(TEST_NAME)
|