interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / argus / lane_d.mk

55 lines · 2591 bytes Raw Blame History
1# lane_d.mk -- ARGUS-0 lane D (resident state core) build + tests.
2# Links against tests/stub_lanes_d.c until lanes B (argus_event.c) and
3# E (argus_detect.c) merge; the integrator swaps the stub for the real objects.
4#
5# make -f lane_d.mk test-core unit tests + heap/symbol checks
6# make -f lane_d.mk test-determinism determinism gate + provisional bench
7
8CC ?= cc
9CFLAGS ?= -std=gnu11 -O2 -Wall -Wextra -Werror -fstack-protector-strong
10OUT ?= out-d
11
12CORE_OBJ = $(OUT)/argus_core.o
13STUB_OBJ = $(OUT)/stub_lanes_d.o
14T_HDRS = tests/test_common_d.h tests/stub_lanes_d.h argus_core.h argus_abi.h
15
16# Symbols argus_core.o may import: the four header-declared lane calls, mem*,
17# and the stack protector. Anything else (heap, I/O, clock) fails the build.
18ALLOWED_UNDEF = argus_event_validate|argus_event_digest|argus_chain_extend|argus_detect_run|memset|memcpy|memcmp|memmove|bzero|__memset_chk|__memcpy_chk|__memmove_chk|__stack_chk_fail|__stack_chk_guard
19
20.PHONY: all test-core test-determinism check-core-symbols clean
21
22all: $(OUT)/test_argus_core $(OUT)/test_argus_determinism
23
24$(OUT):
25 mkdir -p $(OUT)
26
27$(CORE_OBJ): argus_core.c argus_core.h argus_abi.h | $(OUT)
28 $(CC) $(CFLAGS) -c -o $@ argus_core.c
29
30$(STUB_OBJ): tests/stub_lanes_d.c tests/stub_lanes_d.h argus_abi.h | $(OUT)
31 $(CC) $(CFLAGS) -c -o $@ tests/stub_lanes_d.c
32
33$(OUT)/test_argus_core: tests/test_argus_core.c $(T_HDRS) $(CORE_OBJ) $(STUB_OBJ)
34 $(CC) $(CFLAGS) -o $@ tests/test_argus_core.c $(CORE_OBJ) $(STUB_OBJ)
35
36$(OUT)/test_argus_determinism: tests/test_argus_determinism.c $(T_HDRS) $(CORE_OBJ) $(STUB_OBJ)
37 $(CC) $(CFLAGS) -o $@ tests/test_argus_determinism.c $(CORE_OBJ) $(STUB_OBJ)
38
39check-core-symbols: $(CORE_OBJ)
40 @if grep -nwE 'malloc|calloc|realloc|free|printf|fopen|clock_gettime|time' argus_core.c; then \
41 echo "FAIL: argus_core.c references heap/io/clock"; exit 1; fi
42 @if grep -nwiE 'tok[e]n|AIENOS_CAP_TOK[E]N_LEN' argus_core.c argus_core.h tests/*_d.* tests/test_argus_core.c tests/test_argus_determinism.c lane_d.mk; then \
43 echo "FAIL: forbidden word in lane D files"; exit 1; fi
44 @bad=$$(nm -u $(CORE_OBJ) | awk '{print $$NF}' | grep -vxE '_?($(ALLOWED_UNDEF))' || true); \
45 if [ -n "$$bad" ]; then echo "FAIL: argus_core.o imports: $$bad"; exit 1; fi
46 @echo "check-core-symbols: OK (no heap, no I/O, no clock; imports only: $$(nm -u $(CORE_OBJ) | awk '{print $$NF}' | tr '\n' ' '))"
47
48test-core: $(OUT)/test_argus_core check-core-symbols
49 ./$(OUT)/test_argus_core
50
51test-determinism: $(OUT)/test_argus_determinism check-core-symbols
52 ./$(OUT)/test_argus_determinism
53
54clean:
55 rm -rf $(OUT)