2017-04-03 09:50:12 -04:00
|
|
|
TEST_NAME=test
|
|
|
|
FUZZ=afl-fuzz
|
2018-05-04 10:42:54 -04:00
|
|
|
COMPONENTS_DIR=../..
|
2019-02-19 08:38:59 -05:00
|
|
|
CFLAGS=-g -DHOOK_MALLOC_FAILED -DESP_EVENT_H_ -D__ESP_LOG_H__ -DMDNS_TEST_MODE \
|
|
|
|
-I. -I.. -I../include -I../private_include -include esp32_compat.h \
|
|
|
|
-I$(COMPONENTS_DIR)/tcpip_adapter/include -I$(COMPONENTS_DIR)/esp_event/include -I$(COMPONENTS_DIR)/log/include
|
2018-05-04 10:42:54 -04:00
|
|
|
MDNS_C_DEPENDENCY_INJECTION=-include mdns_di.h
|
|
|
|
ifeq ($(INSTR),off)
|
|
|
|
CC=gcc
|
|
|
|
CFLAGS+=-DINSTR_IS_OFF
|
|
|
|
TEST_NAME=test_sim
|
|
|
|
else
|
|
|
|
CC=afl-clang-fast
|
|
|
|
endif
|
2017-04-03 09:50:12 -04:00
|
|
|
CPP=$(CC)
|
|
|
|
LD=$(CC)
|
2018-05-04 10:42:54 -04:00
|
|
|
OBJECTS=mdns.o esp32_mock.o test.o
|
2017-04-03 09:50:12 -04:00
|
|
|
|
|
|
|
OS := $(shell uname)
|
|
|
|
ifeq ($(OS),Darwin)
|
|
|
|
LDLIBS=
|
|
|
|
else
|
2018-05-04 10:42:54 -04:00
|
|
|
LDLIBS=-lbsd
|
|
|
|
CFLAGS+=-DUSE_BSD_STRING
|
2017-04-03 09:50:12 -04:00
|
|
|
endif
|
|
|
|
|
|
|
|
all: $(TEST_NAME)
|
|
|
|
|
|
|
|
%.o: %.c
|
|
|
|
@echo "[CC] $<"
|
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
mdns.o: ../mdns.c
|
|
|
|
@echo "[CC] $<"
|
2018-05-04 10:42:54 -04:00
|
|
|
@$(CC) $(CFLAGS) $(MDNS_C_DEPENDENCY_INJECTION) -c $< -o $@
|
2017-04-03 09:50:12 -04:00
|
|
|
|
|
|
|
$(TEST_NAME): $(OBJECTS)
|
|
|
|
@echo "[LD] $@"
|
2018-05-04 10:42:54 -04:00
|
|
|
@$(LD) $(OBJECTS) -o $@ $(LDLIBS)
|
2017-04-03 09:50:12 -04:00
|
|
|
|
|
|
|
fuzz: $(TEST_NAME)
|
|
|
|
@$(FUZZ) -i "in" -o "out" -- ./$(TEST_NAME)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@rm -rf *.o *.SYM $(TEST_NAME) out
|