test/stp: build the simulator against the firmware headers

test/stp/shim held hand-written copies of the headers the STP code
includes, and they had drifted: the uIP buffer was 600 bytes instead of
1556, struct machine had three fields, port_ingress_filter_get()
returned a plain uint8_t. The simulator now compiles rtl837x_stp.c and
rtl837x_stp_cli.c the way test/ compiles firmware sources, with the real
headers and sdcc_shim.h forced in, and with the same warnings, including
-Wno-pointer-sign for the string literals passed to cmd_compare(). It
stays on -std=c11: in gnu11 mode glibc defines LITTLE_ENDIAN, which
uip-conf.h names as the byte order, and HTONS() stops swapping. Its own
print_string() and cmd_compare() take the firmware's argument types.
This commit is contained in:
DrDoof authored and d00f committed 2026-10-27 22:11:24 +01:00
1 parent aff6ac0923
commit e19271fc44
8 files changed
+17 -106

No files matched your search

+15 -8
View File
@@ -1,7 +1,16 @@
CC ?= cc
CFLAGS = -std=c11 -Wall -Wextra -Wno-unknown-pragmas \
-D__xdata= -D__code= -D__banked= -D__reentrant= \
-Ishim -I../..
CC ?= cc
SRCROOT = ../..
CFLAGS = -std=c11 -g -O1 -Wall -Wextra -Werror -Wno-unused-parameter -Wno-unknown-pragmas \
-Wno-pointer-sign \
-DRTLP_HOST_TEST \
-fsanitize=address,undefined -fno-omit-frame-pointer \
-include ../sdcc_shim.h -I../stub -I$(SRCROOT) -I$(SRCROOT)/httpd -I$(SRCROOT)/uip
ifeq ($(findstring clang,$(shell $(CC) --version 2>/dev/null)),)
CFLAGS += -Wno-builtin-declaration-mismatch
endif
LDFLAGS = -fsanitize=address,undefined
SRCS = stp_sim.c $(SRCROOT)/rtl837x_stp.c $(SRCROOT)/rtl837x_stp_cli.c
all: build/stp_sim
./build/stp_sim
@@ -9,11 +18,9 @@ all: build/stp_sim
verbose: build/stp_sim
./build/stp_sim -v
build/stp_sim: stp_sim.c ../../rtl837x_stp.c ../../rtl837x_stp_cli.c ../../rtl837x_stp.h shim/*.h
build/stp_sim: $(SRCS) $(SRCROOT)/rtl837x_stp.h
mkdir -p build
cp ../../rtl837x_stp.c build/stp_under_test.c
cp ../../rtl837x_stp_cli.c build/stp_cli_under_test.c
$(CC) $(CFLAGS) -o $@ stp_sim.c build/stp_under_test.c build/stp_cli_under_test.c
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS)
clean:
rm -rf build