Add test-only kernel hang module for bench fault F5 [skip ci]
A debugfs write to /sys/kernel/debug/warden_hang/trigger turns interrupts off and never returns, so warden-io stops beating and the HPMCU trips the relays and resets the board (d07 F5). The module is patch 95 and is built only when WARDEN_MODULES_COLLECT lists drivers/warden-test (the test flavour): build-kernel.sh enables CONFIG_WARDEN_TEST_HANG for that request, asserts that it survived olddefconfig, and fails when a collected module's vermagic is not this kernel's release. No defconfig or symbol list names the symbol, so the release configuration does not enable it. Covers: F5 (d07), AT-M4-01 and AT-M4-12 (shared F5), R-03, R-16. Tests: tests/test-hang/run-test-hang-tests.sh (offline checks; the configuration checks run with KERNEL_TARBALL and CROSS_COMPILE on the farm). Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qGNpGNtFT7nhShpH56
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
b771db225e
commit
e4e3993934
Executable
+121
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tests for the test-only kernel hang module (bench fault F5): patch 95,
|
||||
# the WARDEN_MODULES_COLLECT wiring in build/build-kernel.sh, and the vermagic gate.
|
||||
#
|
||||
# What a regression here costs: a release kernel that quietly carries the hang
|
||||
# trigger, or a test image whose module is missing or stale (a hand-copied .ko
|
||||
# that does not match the kernel). The offline checks always run. The checks
|
||||
# that expand the kernel configuration need the pinned tarball and a cross
|
||||
# compiler, so they run only when KERNEL_TARBALL and CROSS_COMPILE name them
|
||||
# (the build farm does this); otherwise they are skipped with a notice.
|
||||
set -uo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO="$(cd "$HERE/../.." && pwd)"
|
||||
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
|
||||
FAIL=0
|
||||
ok() { printf '[PASS] %s\n' "$1"; }
|
||||
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
||||
skip() { printf '[SKIP] %s\n' "$1"; }
|
||||
|
||||
PATCH="$REPO/patches/95-test-hang-module.patch"
|
||||
BK="$REPO/build/build-kernel.sh"
|
||||
|
||||
# --- offline: the patch and the build wiring -------------------------------
|
||||
|
||||
if bash -n "$BK"; then ok "build-kernel.sh parses"; else bad "build-kernel.sh does not parse"; fi
|
||||
|
||||
[ -f "$PATCH" ] && ok "patch 95 present" || bad "patch 95 missing"
|
||||
|
||||
for f in drivers/warden-test/Kconfig drivers/warden-test/Makefile drivers/warden-test/warden_hang.c; do
|
||||
grep -q "^+++ b/$f\$" "$PATCH" && ok "patch 95 adds $f" || bad "patch 95 does not add $f"
|
||||
done
|
||||
grep -q '^+source "drivers/warden-test/Kconfig"$' "$PATCH" \
|
||||
&& ok "drivers/Kconfig sources the test Kconfig" || bad "drivers/Kconfig does not source the test Kconfig"
|
||||
grep -q '^+obj-$(CONFIG_WARDEN_TEST_HANG) += warden-test/$' "$PATCH" \
|
||||
&& ok "drivers/Makefile descends into warden-test only under the symbol" \
|
||||
|| bad "drivers/Makefile does not descend into warden-test under CONFIG_WARDEN_TEST_HANG"
|
||||
grep -q 'config WARDEN_TEST_HANG' "$PATCH" && grep -q 'depends on DEBUG_FS' "$PATCH" \
|
||||
&& ok "CONFIG_WARDEN_TEST_HANG is a tristate under DEBUG_FS" \
|
||||
|| bad "CONFIG_WARDEN_TEST_HANG is missing or not under DEBUG_FS"
|
||||
grep -q 'default y' "$PATCH" && bad "a test symbol defaults to y in patch 95" \
|
||||
|| ok "patch 95 sets no default y"
|
||||
|
||||
if grep -q 'WARDEN_TEST_HANG' "$REPO/build/warden_defconfig" "$REPO/build/required-symbols.txt" \
|
||||
"$REPO/build/probe-symbols.txt"; then
|
||||
bad "a defconfig or symbol list names CONFIG_WARDEN_TEST_HANG (release must not)"
|
||||
else
|
||||
ok "no defconfig or symbol list names CONFIG_WARDEN_TEST_HANG"
|
||||
fi
|
||||
|
||||
test "$(grep -c 'drivers/warden-test)' "$BK")" -eq 2 \
|
||||
&& ok "build-kernel.sh enables the symbol and asserts it, for drivers/warden-test only" \
|
||||
|| bad "build-kernel.sh does not have exactly the two drivers/warden-test blocks"
|
||||
grep -q 'is not this kernel' "$BK" && ok "build-kernel.sh checks each module's vermagic" \
|
||||
|| bad "build-kernel.sh has no vermagic gate"
|
||||
|
||||
# ASCII only in everything this change adds (documentation and comments included).
|
||||
if LC_ALL=C grep -n -P '[^\x09\x0a\x20-\x7e]' "$BK" "$PATCH" "$REPO/patches/README.md" \
|
||||
"$REPO/tests/test-hang/run-test-hang-tests.sh" >/dev/null; then
|
||||
bad "non-ASCII byte in a file this change touches"
|
||||
else
|
||||
ok "ASCII only in the files this change touches"
|
||||
fi
|
||||
|
||||
# --- configuration expansion: needs the tarball and a cross compiler ---------
|
||||
|
||||
if [ -z "${KERNEL_TARBALL:-}" ]; then
|
||||
skip "configuration checks: KERNEL_TARBALL not set (run on the build farm)"
|
||||
elif [ ! -f "$KERNEL_TARBALL" ] && ! bash "$REPO/build/fetch-kernel-tarball.sh" "$KERNEL_TARBALL" >"$TMP/fetch.log" 2>&1; then
|
||||
bad "pinned kernel tarball could not be fetched into $KERNEL_TARBALL (see $TMP/fetch.log)"
|
||||
elif [ -z "${CROSS_COMPILE:-}" ] || ! command -v "${CROSS_COMPILE}gcc" >/dev/null 2>&1; then
|
||||
skip "configuration checks: no cross compiler (set CROSS_COMPILE)"
|
||||
elif ! command -v python >/dev/null 2>&1; then
|
||||
skip "configuration checks: no python on PATH (the SDK quirk)"
|
||||
else
|
||||
# Patches 05 and 95 both touch the two hook files; they must apply in order.
|
||||
mkdir -p "$TMP/hooks"
|
||||
tar -C "$TMP/hooks" -xJf "$KERNEL_TARBALL" linux-6.18.46/drivers/Kconfig linux-6.18.46/drivers/Makefile \
|
||||
&& cd "$TMP/hooks/linux-6.18.46" \
|
||||
&& git init -q . && git add -A && git -c user.name=t -c user.email=t@local commit -q -m base \
|
||||
&& git apply --include='drivers/Kconfig' --include='drivers/Makefile' "$REPO/patches/05-build-wiring.patch" \
|
||||
&& git apply --whitespace=nowarn "$PATCH" \
|
||||
&& grep -q '^source "drivers/warden-test/Kconfig"$' drivers/Kconfig \
|
||||
&& grep -q '^obj-$(CONFIG_WARDEN_TEST_HANG) += warden-test/$' drivers/Makefile \
|
||||
&& ok "patch 95 applies after patch 05 on pristine 6.18.46" \
|
||||
|| bad "patch 95 does not apply after patch 05 on pristine 6.18.46"
|
||||
cd "$HERE" || exit 1
|
||||
|
||||
# Release: the symbol stays unset. Test: it is =m only when the directory is listed.
|
||||
cfg() { # <out> <env assignments...>: expand the configuration only
|
||||
local out="$1"; shift
|
||||
env -u WARDEN_KCONFIG_FRAGMENT -u WARDEN_MODULES_COLLECT "$@" \
|
||||
WORK="$TMP/work-$(basename "$out" .config)" CONFIG_OUT="$out" WARDEN_CONFIG_ONLY=1 \
|
||||
KERNEL_TARBALL="$KERNEL_TARBALL" CROSS_COMPILE="$CROSS_COMPILE" \
|
||||
bash "$BK" >"$out.log" 2>&1
|
||||
}
|
||||
if cfg "$TMP/release.config"; then
|
||||
if grep -q '^CONFIG_WARDEN_TEST_HANG=' "$TMP/release.config"; then
|
||||
bad "release configuration enables CONFIG_WARDEN_TEST_HANG"
|
||||
else
|
||||
ok "release configuration leaves CONFIG_WARDEN_TEST_HANG out"
|
||||
fi
|
||||
else
|
||||
bad "release configuration expansion failed (see $TMP/release.config.log)"
|
||||
fi
|
||||
if cfg "$TMP/test.config" WARDEN_MODULES_COLLECT=drivers/warden-test; then
|
||||
grep -qx 'CONFIG_WARDEN_TEST_HANG=m' "$TMP/test.config" \
|
||||
&& ok "test configuration sets CONFIG_WARDEN_TEST_HANG=m" \
|
||||
|| bad "test configuration does not set CONFIG_WARDEN_TEST_HANG=m"
|
||||
if [ -f "$TMP/release.config" ] && [ "$(sha256sum < "$TMP/test.config")" != "$(sha256sum < "$TMP/release.config")" ]; then
|
||||
ok "test and release configurations differ (KCONFIG_SHA256 follows the request)"
|
||||
else
|
||||
bad "test configuration equals the release configuration"
|
||||
fi
|
||||
else
|
||||
bad "test configuration expansion failed (see $TMP/test.config.log)"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then echo "test-hang: all checks passed"; else echo "test-hang: FAILED"; fi
|
||||
exit "$FAIL"
|
||||
Reference in New Issue
Block a user