live_capture.py and dump_pcap.py were untracked files inside the third-party its-g5-receiver-firmware checkout, so the tools every on-air measurement depends on were versioned nowhere and would vanish with a fresh clone of that project. They are ours rather than that project's, so they now live in capture/, with the setup notes rewritten as its README: which port the sniffer speaks on and why, how to capture, how to check a capture, and how to flash the sniffer board. live_capture.py carries the fix made on 2026-09-14. The sniffer's console converts LF to CRLF on its way out, and that applies to every 0x0a byte of the binary pcap stream, not only to log text, so every inserted CR shifts the rest of the stream. A 787 KB capture parsed cleanly for only 82 of about 2000 records, and DENMs turned up on nonsense BTP ports because their payloads carry 0x0a often. undo_crlf() reverses it on the raw stream before any framing, which is exact; afterwards a capture parsed to EOF and DENMs read as port 2002. Captures taken before that date are truncated at their first corrupted record, so anything measured from them is worth re-checking. capture/recordings/ is gitignored, since captures are data rather than source. The host tests now read both that directory and the older one in the receiver checkout, so no capture has to be moved while it is being written. dump_pcap.py reads the same console and still needs the same treatment; that is recorded in TODO.md.
61 lines
2.1 KiB
Makefile
61 lines
2.1 KiB
Makefile
# Host-side tests for obu-firmware. See README.md: needs gcc and make on PATH (MSYS2 UCRT64), and
|
|
# asn1tools under `py -3.11` for the replay check.
|
|
#
|
|
# make build and run everything: chain, replay, fuzz
|
|
# make chain | replay | fuzz one of them
|
|
# make fuzz FUZZ_ITER=50000000 FUZZ_SEED=7 a longer or different fuzz run
|
|
# make clean remove build/
|
|
#
|
|
# The firmware sources are compiled straight from ../../main, never copied.
|
|
|
|
CC = gcc
|
|
PYTHON = python
|
|
PYTHON_ASN1 = py -3.11
|
|
FW = ../../main
|
|
BUILD = build
|
|
EXE = $(if $(filter Windows_NT,$(OS)),.exe,)
|
|
# Captures live in capture/recordings/ since 2026-09-14; older ones are still in the
|
|
# receiver checkout beside this repo.
|
|
RECORDINGS = $(wildcard ../../../capture/recordings/*.pcap ../../../its-g5-receiver-firmware/recordings/*.pcap)
|
|
FUZZ_ITER = 2000000
|
|
FUZZ_SEED = 1
|
|
|
|
# -Werror: these sources must stay warning-free on the host compiler too.
|
|
# UBSan in trap mode needs no runtime library, so it works on MinGW; a trap shows up as a crash.
|
|
CFLAGS = -std=c11 -O2 -g -Wall -Wextra -Wpedantic -Werror -I$(FW) \
|
|
-fsanitize=undefined -fsanitize-undefined-trap-on-error
|
|
|
|
FW_SRCS = $(FW)/geonet.c $(FW)/dot11p.c $(FW)/gn_unwrap.c
|
|
DEPS = test_util.c test_util.h $(FW_SRCS) $(wildcard $(FW)/*.h)
|
|
|
|
.PHONY: all check chain replay fuzz clean
|
|
|
|
all: check
|
|
|
|
check: chain replay fuzz
|
|
|
|
$(BUILD):
|
|
mkdir -p $@
|
|
|
|
$(BUILD)/%$(EXE): %.c $(DEPS) | $(BUILD)
|
|
$(CC) $(CFLAGS) -o $@ $< test_util.c $(FW_SRCS)
|
|
|
|
# The pcap goes through pcap_gn_tally.py as a second, independent parser of the same frames.
|
|
chain: $(BUILD)/test_chain$(EXE)
|
|
$(BUILD)/test_chain$(EXE) $(BUILD)/test_chain.pcap
|
|
$(PYTHON) ../pcap_gn_tally.py $(BUILD)/test_chain.pcap
|
|
|
|
replay: $(BUILD)/test_replay$(EXE)
|
|
ifeq ($(RECORDINGS),)
|
|
@echo "replay: no recordings in ../../../its-g5-receiver-firmware/recordings, skipped"
|
|
else
|
|
$(BUILD)/test_replay$(EXE) $(BUILD)/replay.tsv $(RECORDINGS)
|
|
$(PYTHON_ASN1) check_replay.py $(BUILD)/replay.tsv $(RECORDINGS)
|
|
endif
|
|
|
|
fuzz: $(BUILD)/fuzz_gn_unwrap$(EXE)
|
|
$(BUILD)/fuzz_gn_unwrap$(EXE) $(FUZZ_ITER) $(FUZZ_SEED) $(RECORDINGS)
|
|
|
|
clean:
|
|
rm -rf $(BUILD)
|