test-hang: SKIP the configuration checks without flex and bison [skip ci]
tests/test-hang/run-test-hang-tests.sh needs flex and bison for its kernel configuration expansions, but it checked only for python and the cross compiler. On farm host 0056 (no flex or bison) both expansions FAILed with "flex: not found", and the failure named a log under the script's temp directory that the EXIT trap deletes, so the cause was not visible. The configuration checks now SKIP with a notice when flex or bison is not on PATH, as they already do for a missing python or cross compiler. The tool checks run before the tarball fetch, so a host without them fetches nothing. A failed fetch or expansion prints the last 40 lines of its log before the script exits. tests/test-hang/run-missing-tools-tests.sh covers both: with flex or with bison missing the checks SKIP and the script passes, and a failed fetch FAILs and prints its log tail. Each case is hermetic (a PATH with only the base tools and fakes; nothing is compiled or downloaded). Fixes #54 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
0b99a7ac8d
commit
45d8dbc59c
Executable
+90
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tests for run-test-hang-tests.sh when a tool its configuration checks need is
|
||||
# missing (the checks SKIP with a notice; they do not FAIL), and for the output
|
||||
# of a failed kernel tarball fetch (the end of its log is printed, because the
|
||||
# EXIT trap deletes the log).
|
||||
#
|
||||
# Hermetic: each case runs the script under a PATH that holds only the base
|
||||
# tools plus the fakes that case needs (python, the cross compiler, flex, bison,
|
||||
# curl), so the result does not depend on what this host has installed. Nothing
|
||||
# is compiled and nothing is downloaded.
|
||||
set -uo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
TARGET="$HERE/run-test-hang-tests.sh"
|
||||
BASH_BIN="$(command -v bash)"
|
||||
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
|
||||
FAIL=0
|
||||
ok() { printf '[PASS] %s\n' "$1"; }
|
||||
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
||||
|
||||
# Base tools used by the script, its offline checks and the fetch helper.
|
||||
BASE_TOOLS=(bash dirname basename mktemp rm mkdir cat tail grep sed awk tr head wc cut sort cmp sha256sum git tar xz env mv)
|
||||
|
||||
# mkpath <dir> <tool...>: link each named tool found on this host into <dir>.
|
||||
mkpath() {
|
||||
local dir="$1" t p
|
||||
shift
|
||||
mkdir -p "$dir"
|
||||
for t in "$@"; do
|
||||
p="$(command -v "$t")" && ln -sf "$p" "$dir/$t"
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
# stub <dir> <name> <command>: an executable that runs <command>.
|
||||
stub() {
|
||||
printf '#!/bin/sh\n%s\n' "$3" > "$1/$2"
|
||||
chmod 0755 "$1/$2"
|
||||
}
|
||||
|
||||
# run_target <path-dir> <out> <tarball>: run the script with exactly that PATH.
|
||||
run_target() {
|
||||
env -i PATH="$1" TMPDIR="$TMP" HOME="$TMP" KERNEL_TARBALL="$3" CROSS_COMPILE=fake- \
|
||||
"$BASH_BIN" "$TARGET" >"$2" 2>&1
|
||||
}
|
||||
|
||||
# Cases 1 and 2: one of flex and bison is missing. The configuration checks SKIP.
|
||||
for missing in flex bison; do
|
||||
dir="$TMP/no-$missing"
|
||||
mkpath "$dir" "${BASE_TOOLS[@]}"
|
||||
stub "$dir" python 'exit 0'
|
||||
stub "$dir" fake-gcc 'exit 0'
|
||||
for present in flex bison; do
|
||||
[ "$present" = "$missing" ] || stub "$dir" "$present" 'exit 0'
|
||||
done
|
||||
run_target "$dir" "$TMP/no-$missing.out" "$TMP/absent.tar.xz"
|
||||
rc=$?
|
||||
if [ "$rc" -eq 0 ] \
|
||||
&& grep -q '^\[SKIP\] configuration checks: flex and bison' "$TMP/no-$missing.out" \
|
||||
&& ! grep -q '^\[FAIL\]' "$TMP/no-$missing.out"; then
|
||||
ok "without $missing the configuration checks SKIP and the script passes"
|
||||
else
|
||||
bad "without $missing the configuration checks did not SKIP cleanly (rc $rc)"
|
||||
cat "$TMP/no-$missing.out"
|
||||
fi
|
||||
done
|
||||
|
||||
# Case 3: every tool is present, the fetch fails. The script FAILs and prints
|
||||
# the end of the fetch log before it exits.
|
||||
dir="$TMP/bad-fetch"
|
||||
mkpath "$dir" "${BASE_TOOLS[@]}"
|
||||
stub "$dir" python 'exit 0'
|
||||
stub "$dir" fake-gcc 'exit 0'
|
||||
stub "$dir" flex 'exit 0'
|
||||
stub "$dir" bison 'exit 0'
|
||||
stub "$dir" curl 'echo "fake curl: refused in this test" >&2; exit 22'
|
||||
run_target "$dir" "$TMP/bad-fetch.out" "$TMP/nodir/linux.tar.xz"
|
||||
rc=$?
|
||||
if [ "$rc" -eq 1 ] \
|
||||
&& grep -q '^\[FAIL\] pinned kernel tarball could not be fetched' "$TMP/bad-fetch.out" \
|
||||
&& grep -q '^--- last 40 lines of fetch output ---$' "$TMP/bad-fetch.out" \
|
||||
&& grep -q 'fake curl: refused in this test' "$TMP/bad-fetch.out"; then
|
||||
ok "a failed fetch FAILs and prints the end of its log before exit"
|
||||
else
|
||||
bad "a failed fetch did not print its log tail (rc $rc)"
|
||||
cat "$TMP/bad-fetch.out"
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then echo "missing-tools: all checks passed"; else echo "missing-tools: FAILED"; fi
|
||||
exit "$FAIL"
|
||||
@@ -5,9 +5,11 @@
|
||||
# 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.
|
||||
# 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)"
|
||||
@@ -17,6 +19,13 @@ 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"
|
||||
@@ -56,7 +65,7 @@ grep -q 'is not this kernel' "$BK" && ok "build-kernel.sh checks each module's v
|
||||
|
||||
# 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
|
||||
"$REPO/tests/test-hang/run-test-hang-tests.sh" "$HERE/run-missing-tools-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"
|
||||
@@ -66,12 +75,15 @@ fi
|
||||
|
||||
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)"
|
||||
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"
|
||||
@@ -101,7 +113,8 @@ else
|
||||
ok "release configuration leaves CONFIG_WARDEN_TEST_HANG out"
|
||||
fi
|
||||
else
|
||||
bad "release configuration expansion failed (see $TMP/release.config.log)"
|
||||
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" \
|
||||
@@ -113,7 +126,8 @@ else
|
||||
bad "test configuration equals the release configuration"
|
||||
fi
|
||||
else
|
||||
bad "test configuration expansion failed (see $TMP/test.config.log)"
|
||||
bad "test configuration expansion failed"
|
||||
show_tail "test configuration log" "$TMP/test.config.log"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user