2018-05-14 09:03:37 -04:00
|
|
|
COMPONENTS_DIR=../..
|
2018-05-15 09:49:10 -04:00
|
|
|
CFLAGS=-std=gnu99 -Og -ggdb -ffunction-sections -fdata-sections -nostdlib -Wall -Werror=all -Wno-int-to-pointer-cast -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra \
|
|
|
|
-Wno-unused-parameter -Wno-sign-compare -Wno-address -Wno-unused-variable -DESP_PLATFORM -D IDF_VER=\"v3.1\" -MMD -MP -DWITH_POSIX
|
2018-07-27 03:26:51 -04:00
|
|
|
INC_DIRS=-I . -I $(COMPONENTS_DIR)/newlib/platform_include -I $(COMPONENTS_DIR)/newlib/include -I $(COMPONENTS_DIR)/driver/include -I $(COMPONENTS_DIR)/esp32/include -I $(COMPONENTS_DIR)/ethernet/include -I $(COMPONENTS_DIR)/freertos/include -I $(COMPONENTS_DIR)/heap/include -I $(COMPONENTS_DIR)/lwip/include/lwip -I $(COMPONENTS_DIR)/lwip/include/lwip/port -I $(COMPONENTS_DIR)/lwip/include/lwip/posix -I $(COMPONENTS_DIR)/lwip/apps/ping -I $(COMPONENTS_DIR)/soc/esp32/include -I $(COMPONENTS_DIR)/soc/include -I $(COMPONENTS_DIR)/tcpip_adapter/include -I $(COMPONENTS_DIR)/xtensa-debug-module/include
|
2018-05-14 09:03:37 -04:00
|
|
|
TEST_NAME=test
|
|
|
|
FUZZ=afl-fuzz
|
|
|
|
LD=$(CC)
|
2018-05-18 09:54:08 -04:00
|
|
|
ifeq ($(MODE),dhcp_client)
|
|
|
|
DEPENDENCY_INJECTION=-include dhcp_di.h
|
|
|
|
OBJECTS=dhcp.o network_mock.o test_dhcp_client.o
|
|
|
|
SAMPLE_PACKETS=in_dhcp_client
|
|
|
|
else ifeq ($(MODE),dhcp_server)
|
|
|
|
DEPENDENCY_INJECTION=-include dhcpserver_di.h
|
|
|
|
OBJECTS=dhcpserver.o test_dhcp_server.o network_mock.o
|
|
|
|
SAMPLE_PACKETS=in_dhcp_server
|
|
|
|
else ifeq ($(MODE),dns)
|
|
|
|
CFLAGS+=-DNOT_MOCK_DNS
|
|
|
|
DEPENDENCY_INJECTION=-include dns_di.h
|
|
|
|
OBJECTS=dns.o test_dns.o network_mock.o
|
|
|
|
SAMPLE_PACKETS=in_dns
|
|
|
|
else
|
|
|
|
$(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)
|
2018-05-14 09:03:37 -04:00
|
|
|
CC=gcc
|
2018-05-15 09:49:10 -04:00
|
|
|
CFLAGS+=-DINSTR_IS_OFF
|
2018-05-14 09:03:37 -04:00
|
|
|
TEST_NAME=test_sim
|
|
|
|
else
|
|
|
|
CC=afl-clang-fast
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFLAGS+=$(INC_DIRS)
|
|
|
|
|
|
|
|
all: $(TEST_NAME)
|
|
|
|
|
2018-05-18 09:54:08 -04:00
|
|
|
dns.o: ../core/dns.c
|
|
|
|
@echo "[CC] $<"
|
|
|
|
@$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@
|
|
|
|
|
2018-05-15 09:49:10 -04:00
|
|
|
dhcp.o: ../core/ipv4/dhcp.c
|
|
|
|
@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-05-14 09:03:37 -04:00
|
|
|
dhcpserver.o: ../apps/dhcpserver.c
|
|
|
|
@echo "[CC] $<"
|
2018-05-18 09:54:08 -04:00
|
|
|
@$(CC) $(CFLAGS) $(DEPENDENCY_INJECTION) -c $< -o $@
|
2018-05-14 09:03:37 -04:00
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
@echo "[CC] $<"
|
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
$(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)
|