# Host tests for the packet framing, including the decode-to-buffer path that
# LispBM's pkt-dec is built on.
#
#   nix-shell -p gcc gnumake --run 'cd tests/packet && make && ./test_packet'
#
# main/packet.c and main/crc.c are compiled straight from the firmware
# source. Neither includes anything from the SDK, so there is no shim.

CFLAGS += -O1 -g -std=c11 -D_POSIX_C_SOURCE=200809L -Wall -Wextra
SAN ?= -fsanitize=address,undefined -fno-omit-frame-pointer

MAIN = ../../main

INCLUDES = -I$(MAIN)

SRCS = test_packet.c $(MAIN)/packet.c $(MAIN)/crc.c

HDRS = $(MAIN)/packet.h $(MAIN)/crc.h

all: test_packet

test_packet: $(SRCS) $(HDRS)
	$(CC) $(CFLAGS) $(SAN) $(INCLUDES) -o $@ $(SRCS)

run: test_packet
	./test_packet

clean:
	rm -f test_packet

.PHONY: all run clean
