You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A test that reads a kernel fact from the machine running it asserts
against that machine's contents -- or against what it happens to lack,
which the test's own text does not reveal. Test builds define
KASLD_HERMETIC_PROBE, under which kasld_resolve records any fact path
resolved with no sysroot set and the harness fails the binary at its
tally, listing them. Reported at the tally rather than at the read,
because a test capturing a component's output may have stderr pointed at
/dev/null when it happens.
Runtime rather than a source scan, because the read is normally several
frames below the test: tests/test_render.c names no path and calls no
wrapper, yet reaches 13 of them through container detection, the LSM
probe and the group database. It catches staging done too late for the
same reason -- the prefix is resolved once and cached, so a read before
the setenv resolves live. Never defined for a shipped build.
Also wires check-absence-vs-denial into `make lint` and documents both
checks.
test : $(KASLD_BIN)$(TEST_BIN)$(TEST_RENDER_BIN)$(TEST_EST_BIN)$(TEST_EV_BIN)$(TEST_ALIGN_BIN)$(TEST_ADDRP_BIN)$(TEST_TWIDTH_BIN)$(TEST_TS_BIN)$(TEST_PREFETCH_SCAN_BIN)$(TEST_CPU_BIN)$(TEST_OUTCOME_BIN)$(TEST_TEXT_ORDER_BIN)$(TEST_KIMG_BIN)$(TEST_ENG_BIN)$(TEST_INT_BIN)$(TEST_DMESG_BIN)$(TEST_BACKTRACE_BIN)$(TEST_BOOTCFG_BIN)$(TEST_KASLRDIS_BIN)$(TEST_DTMEM_BIN)$(TEST_SOCKPTR_BIN)$(TEST_TIMERLIST_BIN)$(TEST_KALLSYMS_BIN)$(TEST_BTF_BIN)$(TEST_DMESG_RESV_BIN)$(TEST_BPE820_BIN)$(TEST_PARSERS_BIN)$(TEST_KCORE_BIN)
Copy file name to clipboardExpand all lines: docs/testing.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,6 +69,33 @@ chosen for what they say rather than how wide they are. The target-identity line
69
69
is exempt for the same reason — it interpolates an unbounded kernel version
70
70
string.
71
71
72
+
Every test binary also carries the hermeticity probe. Test builds define
73
+
`KASLD_HERMETIC_PROBE`, under which `kasld_resolve` records any kernel fact path
74
+
resolved while `KASLD_SYSROOT` is unset — a read that went to the machine
75
+
running the test rather than to a tree the test supplied — and the harness fails
76
+
that binary at its tally, listing the paths:
77
+
78
+
```
79
+
7/7 tests passed
80
+
read 1 kernel fact path from the host:
81
+
/proc/version
82
+
Stage a tree and point KASLD_SYSROOT at it before the first read.
83
+
```
84
+
85
+
A test that reads the host asserts against whatever that machine holds, or
86
+
against what it happens to lack, which the test's own text does not reveal. The
87
+
check is a runtime one because a source scan cannot see it: the read is normally
88
+
several frames below the test, so a renderer test that names no path still
89
+
reaches container detection, the LSM probe and the group database. It equally
90
+
catches staging done too late, since the prefix is resolved once and cached and
91
+
a read before the `setenv` resolves live.
92
+
93
+
The fix is to supply the source rather than borrow it: stage a directory, write
94
+
the files the test needs under it, and set `KASLD_SYSROOT` to it before the
95
+
first read. An empty staged tree is a legitimate answer, and the correct one
96
+
where the test wants the source absent. The probe is never defined for a shipped
97
+
build.
98
+
72
99
Run one driver in isolation:
73
100
74
101
```sh
@@ -105,6 +132,7 @@ and `make` halts on the first.
105
132
|`check-extent-callers`| only reviewed whole-map components call `kasld_result_extent` (the covering-completeness contract; a partial map would carve a false gap) |
106
133
|`check-truncation`| no silent 64-bit→word narrowing when compiled for 32-bit (compiles a TU with `i686-linux-gnu-gcc`) |
107
134
|`check-addr-parse`| kernel addresses are converted with `kasld_addr_parse` outside a reviewed allowlist — `sscanf("%lx")` reports success on an address wider than the word and hands back a truncated one |
135
+
|`check-absence-vs-denial`| no component reports a denied source as an absent one — a failed probe's reason is in `errno`, and UNAVAILABLE claims the target's build while NOPERM reports its hardening |
108
136
|`check-component-output`| components write only wire lines to stdout (stdout is the machine channel; diagnostics go to stderr) |
109
137
|`check-component-meta`| every component declares `KASLD_META` with a `method:` key |
110
138
|`check-component-cap`|`MAX_COMPONENTS` keeps a margin above the in-tree component count — a component directory that overruns it silently drops the excess |
0 commit comments