The collected-module gate moves to build/lib-module-gate.sh, which build-kernel.sh sources. Every WARDEN_MODULES_COLLECT module must carry this kernel's vermagic before it is copied, and the test-only directory needs CONFIG_WARDEN_TEST_HANG=m after olddefconfig. The grep-only checks of run-test-hang-tests.sh never ran either refusal path. run-module-gate-tests.sh runs them on fixtures, with no kernel tree and no compiler: a stale module is refused and not copied, in the test-only list and in the aic8800 release list, and a symbol that is not =m is refused. Accepting every vermagic fails five of its checks (mutation check). run-missing-tools-tests.sh lists find and cp among its base tools: the collection step and the fixtures use them. Refs blueflare/bfe-core1106-sdk#56 Refs flare-edge sp/m4a-e-f5-kernel-hang-module (F5, AT-M4-01, AT-M4-12) Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qGNpGNtFT7nhShpH56
149 lines
7.7 KiB
Bash
Executable File
149 lines
7.7 KiB
Bash
Executable File
#!/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, a cross compiler,
|
|
# python, flex and bison (the kernel's configuration parser). They run only when
|
|
# KERNEL_TARBALL and CROSS_COMPILE name them and those tools are on PATH (the
|
|
# build farm does this); otherwise they are skipped with a notice that names the
|
|
# missing piece (run-missing-tools-tests.sh checks those skips).
|
|
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"; }
|
|
# The EXIT trap deletes $TMP, so a failing step prints the end of its log here.
|
|
show_tail() { # <label> <log>
|
|
[ -s "$2" ] || return 0
|
|
printf -- '--- last 40 lines of %s ---\n' "$1"
|
|
tail -n 40 "$2"
|
|
printf -- '--- end of %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
|
|
|
|
# The test symbol and the vermagic gate live in build/lib-module-gate.sh, which
|
|
# the behavioural checks in run-module-gate-tests.sh drive with fixtures (below).
|
|
if grep -q '^\. "\$HERE/lib-module-gate\.sh"$' "$BK" \
|
|
&& grep -q 'collect_modules "\$SRC" "\$d" "\$KREL" "\$MODOUT" || exit 1' "$BK"; then
|
|
ok "build-kernel.sh collects every listed module through the vermagic gate"
|
|
else
|
|
bad "build-kernel.sh does not collect through the vermagic gate"
|
|
fi
|
|
|
|
# The behavioural gate tests: refusals with a module of the wrong vermagic, and the
|
|
# test symbol that must be =m (run-module-gate-tests.sh, no kernel tree needed).
|
|
if bash "$HERE/run-module-gate-tests.sh" > "$TMP/gate.log" 2>&1; then
|
|
ok "module gate: wrong-vermagic refusals and acceptance fixtures pass"
|
|
else
|
|
bad "module gate: fixtures fail (run-module-gate-tests.sh)"
|
|
show_tail "module gate log" "$TMP/gate.log"
|
|
fi
|
|
|
|
# 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" "$HERE/run-missing-tools-tests.sh" \
|
|
"$REPO/build/lib-module-gate.sh" "$HERE/run-module-gate-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 [ -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)"
|
|
elif ! command -v flex >/dev/null 2>&1 || ! command -v bison >/dev/null 2>&1; then
|
|
skip "configuration checks: flex and bison must both be on PATH (the kernel configuration parser needs them)"
|
|
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"
|
|
show_tail "fetch output" "$TMP/fetch.log"
|
|
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"
|
|
show_tail "release configuration log" "$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"
|
|
show_tail "test configuration log" "$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"
|