2017-04-03 09:50:12 -04:00
|
|
|
TEST_NAME=test
|
|
|
|
FUZZ=afl-fuzz
|
2018-05-04 10:42:54 -04:00
|
|
|
COMPONENTS_DIR=../..
|
|
|
|
CFLAGS=-g -DMDNS_TEST_MODE -I. -I.. -I../include -I../private_include -I$(COMPONENTS_DIR)/tcpip_adapter/include -I$(COMPONENTS_DIR)/esp32/include -include esp32_compat.h
|
|
|
|
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
|