# Host tests for the package table (several packages per board,
# tool/docs/multi-package.md) and the COMM_PKG commands over it.
#
# main.c is vesc_express's main/script/test/test_pkg_table.c unchanged, and
# script/pkg_table.c is byte-identical to vesc_express's main/script copy:
# the same test runs over the same code in both trees. table.bin is the
# cross-repo anchor, a table that vesc_express/tools/luapack.py --table
# emitted -- the unit tests build their own entries and would keep passing if
# the format drifted; that one would not.

TARGET = test
CC = gcc
CFLAGS = -O1 -g -std=c11 -Wall -Wextra -Wconversion -Wsign-conversion \
         -I../../script
SAN ?= -fsanitize=address,undefined -fno-omit-frame-pointer
SOURCES = main.c ../../script/pkg_table.c
HEADERS = ../../script/pkg_table.h

.PHONY: default all run clean

default: $(TARGET)
all: default
run: $(TARGET)
	./$(TARGET) table.bin

$(TARGET): $(SOURCES) $(HEADERS)
	$(CC) $(CFLAGS) $(SAN) -o $@ $(SOURCES)

clean:
	rm -f $(TARGET)
