# Host test for the background task and the WiFi hop on it.
#
#   nix develop --command sh -c 'cd tests/bg_work && make && ./test_bg_work'
#
# main/bg_work.c, main/wifi_nets.c and main/wifi_pick.c are compiled straight
# from the firmware source; shim/ stands in for FreeRTOS, the WiFi driver,
# NVS, the terminal and the main config.

CFLAGS += -O1 -g -std=gnu11 -Wall -Wextra
SAN ?= -fsanitize=address,undefined -fno-omit-frame-pointer

MAIN = ../../main

SRCS = test_bg_work.c shim/shim.c $(MAIN)/bg_work.c $(MAIN)/wifi_nets.c $(MAIN)/wifi_pick.c
HDRS = $(wildcard shim/*.h) $(wildcard shim/freertos/*.h) \
	$(MAIN)/bg_work.h $(MAIN)/wifi_nets.h $(MAIN)/wifi_pick.h

all: test_bg_work

test_bg_work: $(SRCS) $(HDRS)
	$(CC) $(CFLAGS) $(SAN) -Ishim -I$(MAIN) -o $@ $(SRCS)

clean:
	rm -f test_bg_work

.PHONY: all clean
