Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8b5d64c2a | ||
|
|
6f8903c1df | ||
|
|
aa01bca930 | ||
|
|
cf08254f4c | ||
|
|
748979611e | ||
|
|
45d8dbc59c | ||
|
|
0b99a7ac8d | ||
|
|
e4e3993934 | ||
|
|
fc62400157 |
@@ -237,7 +237,9 @@ jobs:
|
||||
- name: QEMU busybox fetch regression tests
|
||||
# Retry on a bad sha256, the cached copy, and a server that answers
|
||||
# and then stalls (#1588), against local listeners: no network.
|
||||
run: bash qemu/tests/busybox-fetch.sh
|
||||
run: |
|
||||
bash qemu/tests/busybox-fetch.sh
|
||||
bash qemu/tests/busybox-source-mirror.sh
|
||||
- name: unpack-buildroot regression tests
|
||||
# Fresh unpack, leave-existing-tree-alone, and every refusal path
|
||||
# (unpatched selectors, bad tarball, half-present tree, failed
|
||||
|
||||
+27
-7
@@ -34,6 +34,10 @@
|
||||
# `make modules` (the zImage target alone generates no
|
||||
# Module.symvers, so per-dir M= builds cannot link) and
|
||||
# collects the listed dirs' modules into $WORK/modules-out.
|
||||
# Every collected module must carry this kernel's vermagic
|
||||
# (include/config/kernel.release), or the build fails. The
|
||||
# test-only drivers/warden-test directory (bench fault F5) also
|
||||
# enables CONFIG_WARDEN_TEST_HANG; no other caller lists it.
|
||||
#
|
||||
# Requires: `python` (not python3) on PATH: the SDK quirk; the CI runner provides
|
||||
# a project-local venv. Builds are SERIAL on the shared SDK box: never run two.
|
||||
@@ -43,6 +47,8 @@ KVER=6.18.46
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # build/
|
||||
# shellcheck source=build/lib-required-symbols.sh
|
||||
. "$HERE/lib-required-symbols.sh"
|
||||
# shellcheck source=build/lib-module-gate.sh
|
||||
. "$HERE/lib-module-gate.sh"
|
||||
REQ_SYMBOLS="$HERE/required-symbols.txt"
|
||||
PROBE_SYMBOLS="$HERE/probe-symbols.txt"
|
||||
REPO="$(cd "$HERE/.." && pwd)"
|
||||
@@ -133,6 +139,16 @@ if [ -n "${WARDEN_KCONFIG_FRAGMENT:-}" ]; then
|
||||
log "merging kconfig fragment $(basename "$FRAG")"
|
||||
( cd "$SRC" && ARCH=arm ./scripts/kconfig/merge_config.sh -m .config "$FRAG" )
|
||||
fi
|
||||
# Test-only modules. A directory listed in WARDEN_MODULES_COLLECT whose Kconfig
|
||||
# symbol defaults to n is enabled here, before olddefconfig, so the configuration
|
||||
# (and KCONFIG_SHA256) follows the request. A release or debug build never lists
|
||||
# one, so its configuration does not change through this block.
|
||||
for d in ${WARDEN_MODULES_COLLECT:-}; do
|
||||
sym="$(test_symbol_of "$d")"
|
||||
if [ -n "$sym" ]; then
|
||||
( cd "$SRC" && ./scripts/config --file .config --module "$sym" )
|
||||
fi
|
||||
done
|
||||
# CROSS_COMPILE defaults to the Luckfox SDK uclibc prefix (set SDK_TC to its bin/),
|
||||
# but the kernel is freestanding, so a caller may override with a generic arm cross
|
||||
# toolchain instead: e.g. CROSS_COMPILE=arm-linux-gnueabihf- (in Debian's
|
||||
@@ -143,6 +159,11 @@ if [ -n "${SDK_TC:-}" ]; then export PATH="$SDK_TC:$PATH"; fi
|
||||
command -v "${CROSS_COMPILE}gcc" >/dev/null \
|
||||
|| { echo "cross toolchain ${CROSS_COMPILE}gcc not on PATH (set SDK_TC, or CROSS_COMPILE to one that is)" >&2; exit 1; }
|
||||
make -C "$SRC" ARCH=arm CROSS_COMPILE="$CROSS_COMPILE" olddefconfig >/dev/null
|
||||
# A requested test module whose symbol did not survive olddefconfig (an unmet
|
||||
# dependency drops it without a word) fails here, not as a missing .ko later.
|
||||
for d in ${WARDEN_MODULES_COLLECT:-}; do
|
||||
require_test_config "$SRC/.config" "$d" || exit 1
|
||||
done
|
||||
|
||||
# Took-effect assertion for every symbol the platform needs. olddefconfig drops
|
||||
# a defconfig line whose dependencies are unmet, or whose symbol does not exist,
|
||||
@@ -223,14 +244,13 @@ if [ -n "${WARDEN_MODULES_COLLECT:-}" ]; then
|
||||
rm -rf "$MODOUT"; mkdir -p "$MODOUT"
|
||||
log "building modules (full set: needed for Module.symvers)"
|
||||
make -C "$SRC" ARCH=arm CROSS_COMPILE="$CROSS_COMPILE" CC="$KCC" -j"$JOBS" modules
|
||||
# The kernel's own release string; every collected module must carry it
|
||||
# (lib-module-gate.sh refuses a module that does not, before it is copied).
|
||||
KREL="$(tr -d '[:space:]' < "$SRC/include/config/kernel.release")"
|
||||
[ -n "$KREL" ] || { echo "FATAL: include/config/kernel.release is empty" >&2; exit 1; }
|
||||
for d in $WARDEN_MODULES_COLLECT; do
|
||||
[ -d "$SRC/$d" ] || { echo "FATAL: WARDEN_MODULES_COLLECT dir '$d' not in tree" >&2; exit 1; }
|
||||
n=0
|
||||
while IFS= read -r ko; do
|
||||
cp "$ko" "$MODOUT/"; n=$((n + 1))
|
||||
done < <(find "$SRC/$d" -name '*.ko')
|
||||
[ "$n" -gt 0 ] || { echo "FATAL: no .ko produced under '$d'" >&2; exit 1; }
|
||||
log "collected $n module(s) from $d"
|
||||
collect_modules "$SRC" "$d" "$KREL" "$MODOUT" || exit 1
|
||||
log "collected $COLLECTED module(s) from $d (vermagic $KREL)"
|
||||
done
|
||||
ls -la "$MODOUT"
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
# shellcheck shell=bash
|
||||
# Gate for the kernel modules a build collects (WARDEN_MODULES_COLLECT in
|
||||
# build-kernel.sh). Sourced, not run: reading it changes nothing.
|
||||
#
|
||||
# Every collected module must carry this kernel's vermagic, so a module built
|
||||
# against another tree, or a hand-copied .ko, cannot reach an image. A
|
||||
# directory that needs a test-only Kconfig symbol must find it =m after
|
||||
# olddefconfig. tests/test-hang/run-module-gate-tests.sh runs these functions
|
||||
# against fixtures, including the refusal paths.
|
||||
|
||||
# The test-only Kconfig symbol a collected directory needs (empty for the rest).
|
||||
# Release and debug builds list no test directory, so they get no symbol.
|
||||
test_symbol_of() {
|
||||
case "$1" in
|
||||
drivers/warden-test) echo WARDEN_TEST_HANG ;;
|
||||
*) : ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# module_vermagic_check <kernel release> <module file>: 0 when the module's
|
||||
# vermagic is "<release> " (the release, then a space), else 1 with a FATAL line.
|
||||
module_vermagic_check() {
|
||||
local krel=$1 ko=$2 vm
|
||||
if [ -z "$krel" ]; then
|
||||
echo "FATAL: kernel release is empty" >&2
|
||||
return 1
|
||||
fi
|
||||
# vermagic is a NUL-separated .modinfo string; one printable run per line.
|
||||
vm="$(tr -c '[:print:]' '\n' < "$ko" | grep -m1 '^vermagic=' || true)"
|
||||
case "$vm" in
|
||||
"vermagic=$krel "*) return 0 ;;
|
||||
'') echo "FATAL: $(basename "$ko") has no vermagic" >&2 ;;
|
||||
*) echo "FATAL: $(basename "$ko") vermagic '${vm#vermagic=}' is not this kernel's '$krel'" >&2 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
# collect_modules <source tree> <dir> <kernel release> <out dir>: copies every
|
||||
# .ko under <source tree>/<dir> into <out dir>, each only after it passed
|
||||
# module_vermagic_check. Sets COLLECTED to the count. Returns 1 at the first
|
||||
# module that fails, when the directory is missing, or when it yields none.
|
||||
collect_modules() {
|
||||
local src=$1 d=$2 krel=$3 out=$4 ko
|
||||
COLLECTED=0
|
||||
if [ ! -d "$src/$d" ]; then
|
||||
echo "FATAL: WARDEN_MODULES_COLLECT dir '$d' not in tree" >&2
|
||||
return 1
|
||||
fi
|
||||
while IFS= read -r ko; do
|
||||
module_vermagic_check "$krel" "$ko" || return 1
|
||||
cp "$ko" "$out/" || return 1
|
||||
COLLECTED=$((COLLECTED + 1))
|
||||
done < <(find "$src/$d" -name '*.ko')
|
||||
if [ "$COLLECTED" -eq 0 ]; then
|
||||
echo "FATAL: no .ko produced under '$d'" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# require_test_config <kernel .config> <dir>: a directory with a test symbol
|
||||
# must find it =m in the configuration after olddefconfig (an unmet dependency
|
||||
# drops the symbol without a word). Returns 1 with a FATAL line otherwise.
|
||||
require_test_config() {
|
||||
local cfg=$1 d=$2 sym
|
||||
sym="$(test_symbol_of "$d")"
|
||||
[ -n "$sym" ] || return 0
|
||||
if ! grep -qx "CONFIG_${sym}=m" "$cfg" 2>/dev/null; then
|
||||
echo "FATAL: $d needs CONFIG_${sym}=m, which did not survive olddefconfig" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
diff --git a/drivers/Kconfig b/drivers/Kconfig
|
||||
index 4915a63..979a6e7 100644
|
||||
--- a/drivers/Kconfig
|
||||
+++ b/drivers/Kconfig
|
||||
@@ -251,4 +251,6 @@ source "drivers/hte/Kconfig"
|
||||
|
||||
source "drivers/cdx/Kconfig"
|
||||
|
||||
+source "drivers/warden-test/Kconfig"
|
||||
+
|
||||
endmenu
|
||||
diff --git a/drivers/Makefile b/drivers/Makefile
|
||||
index 8e1ffa4..e120fc2 100644
|
||||
--- a/drivers/Makefile
|
||||
+++ b/drivers/Makefile
|
||||
@@ -197,3 +197,6 @@ obj-$(CONFIG_DPLL) += dpll/
|
||||
|
||||
obj-$(CONFIG_DIBS) += dibs/
|
||||
obj-$(CONFIG_S390) += s390/
|
||||
+
|
||||
+# Test-only modules (bench fault F5): built only when the test flavour enables them.
|
||||
+obj-$(CONFIG_WARDEN_TEST_HANG) += warden-test/
|
||||
diff --git a/drivers/warden-test/Kconfig b/drivers/warden-test/Kconfig
|
||||
new file mode 100644
|
||||
index 0000000..3c6b7d8
|
||||
--- /dev/null
|
||||
+++ b/drivers/warden-test/Kconfig
|
||||
@@ -0,0 +1,16 @@
|
||||
+# SPDX-License-Identifier: GPL-2.0-only
|
||||
+#
|
||||
+# Test-only modules for the WardenOS bench. The SDK builds a symbol here only
|
||||
+# when the caller lists its directory in WARDEN_MODULES_COLLECT (build/build-kernel.sh),
|
||||
+# which only the test flavour does. Release and debug kernels never enable them.
|
||||
+
|
||||
+config WARDEN_TEST_HANG
|
||||
+ tristate "Warden test: kernel hang on a debugfs write (bench fault F5)"
|
||||
+ depends on DEBUG_FS
|
||||
+ help
|
||||
+ Test-only. Creates /sys/kernel/debug/warden_hang/trigger. A write to it
|
||||
+ turns interrupts off and never returns, so warden-io stops beating and
|
||||
+ the board is reset by its watchdog (d07 fault F5). Never enable this in
|
||||
+ a release or debug kernel.
|
||||
+
|
||||
+ If unsure, say N.
|
||||
diff --git a/drivers/warden-test/Makefile b/drivers/warden-test/Makefile
|
||||
new file mode 100644
|
||||
index 0000000..c586de7
|
||||
--- /dev/null
|
||||
+++ b/drivers/warden-test/Makefile
|
||||
@@ -0,0 +1,4 @@
|
||||
+# SPDX-License-Identifier: GPL-2.0-only
|
||||
+# Test-only modules. Built only when their Kconfig symbol is =m, which build/build-kernel.sh
|
||||
+# sets for the test flavour (WARDEN_MODULES_COLLECT lists this directory).
|
||||
+obj-$(CONFIG_WARDEN_TEST_HANG) += warden_hang.o
|
||||
diff --git a/drivers/warden-test/warden_hang.c b/drivers/warden-test/warden_hang.c
|
||||
new file mode 100644
|
||||
index 0000000..3307532
|
||||
--- /dev/null
|
||||
+++ b/drivers/warden-test/warden_hang.c
|
||||
@@ -0,0 +1,62 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-only
|
||||
+/*
|
||||
+ * Warden test-only kernel hang (bench fault F5, d07 "Fault Matrix").
|
||||
+ *
|
||||
+ * A write to /sys/kernel/debug/warden_hang/trigger turns interrupts off on the
|
||||
+ * only core and never returns. Nothing runs after that: warden-io stops
|
||||
+ * beating, the HPMCU trips the relays once their deadline passes, and the
|
||||
+ * watchdog resets the board about 90 s after the hang.
|
||||
+ *
|
||||
+ * Test flavour only. build/build-kernel.sh enables CONFIG_WARDEN_TEST_HANG
|
||||
+ * when WARDEN_MODULES_COLLECT lists drivers/warden-test, and the module is
|
||||
+ * then collected into oem.img with the kernel's vermagic. Nothing loads it on
|
||||
+ * its own: the bench runner inserts it for the F5 case.
|
||||
+ */
|
||||
+#include <linux/debugfs.h>
|
||||
+#include <linux/fs.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/irqflags.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/printk.h>
|
||||
+#include <linux/processor.h>
|
||||
+
|
||||
+static struct dentry *hang_dir;
|
||||
+
|
||||
+static void __noreturn warden_hang_spin(void)
|
||||
+{
|
||||
+ local_irq_disable();
|
||||
+ for (;;)
|
||||
+ cpu_relax();
|
||||
+}
|
||||
+
|
||||
+static ssize_t trigger_write(struct file *file, const char __user *buf,
|
||||
+ size_t count, loff_t *ppos)
|
||||
+{
|
||||
+ /* Logged before interrupts go off; the spin below never returns. */
|
||||
+ pr_emerg("warden_hang: F5 kernel hang requested, interrupts off\n");
|
||||
+ warden_hang_spin();
|
||||
+}
|
||||
+
|
||||
+static const struct file_operations trigger_fops = {
|
||||
+ .owner = THIS_MODULE,
|
||||
+ .write = trigger_write,
|
||||
+ .llseek = noop_llseek,
|
||||
+};
|
||||
+
|
||||
+static int __init warden_hang_init(void)
|
||||
+{
|
||||
+ hang_dir = debugfs_create_dir("warden_hang", NULL);
|
||||
+ debugfs_create_file("trigger", 0200, hang_dir, NULL, &trigger_fops);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void __exit warden_hang_exit(void)
|
||||
+{
|
||||
+ debugfs_remove_recursive(hang_dir);
|
||||
+}
|
||||
+
|
||||
+module_init(warden_hang_init);
|
||||
+module_exit(warden_hang_exit);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("Warden test-only kernel hang (bench fault F5)");
|
||||
@@ -31,6 +31,7 @@ with `../build/warden_defconfig` -> `zImage` + `rv1106-warden.dtb`).
|
||||
| `80-misc-thermal-rtc-adc.patch` | tsadc, rtc-rockchip, saradc, trng, otp, gmac, goodix touch |
|
||||
| `82-arch-timer-vdso-phys-counter.patch` | arch timer: keep the arm32 vDSO clock off the virtual counter while the kernel times on the physical one (CNTVOFF left non-zero by the boot firmware, #35); checked by `tests/arch-timer/check-vdso-counter.py` |
|
||||
| `90-kconfig-no-python-symbol.patch` | drops `DRM_MSM_VALIDATE_XML` so the expanded `.config` (and `KCONFIG_SHA256`) does not depend on the host python (#19) |
|
||||
| `95-test-hang-module.patch` | test-only kernel hang module for bench fault F5 in `drivers/warden-test/` (`CONFIG_WARDEN_TEST_HANG`, default n); enabled only when `WARDEN_MODULES_COLLECT` lists `drivers/warden-test`, never in a release or debug build |
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -121,7 +121,8 @@ bb_main() {
|
||||
rm -f "$bin.inputs"
|
||||
|
||||
tar="${BB_SRC_TARBALL:-$out/busybox-${BB_SRC_VER}.tar.bz2}"
|
||||
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source"
|
||||
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source" \
|
||||
"$BB_SRC_MIRROR_URL"
|
||||
|
||||
scratch="$(mktemp -d "${TMPDIR:-/tmp}/warden-busybox.XXXXXX")"
|
||||
# Expanded now on purpose: the trap must remove this run's directory.
|
||||
|
||||
+8
-1
@@ -11,6 +11,9 @@ BB_SRC_VER=1.37.0
|
||||
# Read by build-busybox.sh, which sources this file.
|
||||
# shellcheck disable=SC2034
|
||||
BB_SRC_URL="https://busybox.net/downloads/busybox-${BB_SRC_VER}.tar.bz2"
|
||||
# Buildroot mirrors this exact pinned release; verification is unchanged.
|
||||
# shellcheck disable=SC2034
|
||||
BB_SRC_MIRROR_URL="https://sources.buildroot.net/busybox/busybox-${BB_SRC_VER}.tar.bz2"
|
||||
BB_SRC_SHA256=3311dff32e746499f4df0d5df04d7eb396382d7e108bb9250e7b519b837043a4
|
||||
|
||||
qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||
@@ -18,9 +21,10 @@ qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||
# Download URL to DEST and verify it against the sha256 WANT. A DEST that
|
||||
# already matches is kept. FAILS CLOSED: three bounded attempts, then exit 1;
|
||||
# a mismatching download never lands at DEST.
|
||||
# Usage: qemu_fetch_verified URL WANT DEST LABEL
|
||||
# Usage: qemu_fetch_verified URL WANT DEST LABEL [MIRROR_URL]
|
||||
qemu_fetch_verified() {
|
||||
local url="$1" want="$2" dest="$3" label="$4" got
|
||||
local mirror="${5:-}"
|
||||
if [ -f "$dest" ]; then
|
||||
got="$(sha256sum "$dest" | awk '{print $1}')"
|
||||
if [ "$want" = "$got" ]; then
|
||||
@@ -40,6 +44,9 @@ qemu_fetch_verified() {
|
||||
local attempt tmp="${dest}.download.$$"
|
||||
rm -f "$tmp"
|
||||
for attempt in 1 2 3; do
|
||||
if [ "$attempt" -gt 1 ] && [ -n "$mirror" ]; then
|
||||
url="$mirror"
|
||||
fi
|
||||
qemu_log "downloading $url (attempt $attempt/3)"
|
||||
if curl --retry 1 --retry-delay "$delay" --retry-connrefused \
|
||||
--connect-timeout "$stall" --speed-limit 1024 --speed-time "$stall" \
|
||||
|
||||
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# The sourced downloader runs before the later production-call test stub.
|
||||
# shellcheck disable=SC2218
|
||||
set -euo pipefail
|
||||
|
||||
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
QEMU_DIR="$(cd "$TEST_DIR/.." && pwd)"
|
||||
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/busybox-source-mirror.XXXXXX")"
|
||||
trap 'rm -rf "$SCRATCH"' EXIT
|
||||
|
||||
mkdir -p "$SCRATCH/bin"
|
||||
printf 'pinned source fixture' > "$SCRATCH/good"
|
||||
WANT="$(sha256sum "$SCRATCH/good" | awk '{print $1}')"
|
||||
export MIRROR_LOG="$SCRATCH/requests" MIRROR_GOOD="$SCRATCH/good"
|
||||
export MIRROR_MODE=good
|
||||
cat > "$SCRATCH/bin/curl" <<'CURL'
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
url= out=
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
-o) shift; out="$1" ;;
|
||||
https://*) url="$1" ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
printf '%s\n' "$url" >> "$MIRROR_LOG"
|
||||
[ -n "$out" ] || exit 2
|
||||
case "$url" in
|
||||
https://primary.invalid/source) exit 28 ;;
|
||||
https://mirror.invalid/source)
|
||||
if [ "$MIRROR_MODE" = good ]; then cp "$MIRROR_GOOD" "$out";
|
||||
else printf 'corrupt mirror response' > "$out"; fi ;;
|
||||
*) exit 2 ;;
|
||||
esac
|
||||
CURL
|
||||
chmod 0755 "$SCRATCH/bin/curl"
|
||||
export PATH="$SCRATCH/bin:$PATH"
|
||||
# shellcheck source=qemu/lib.sh disable=SC1091
|
||||
source "$QEMU_DIR/lib.sh"
|
||||
|
||||
qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
||||
"$SCRATCH/fetched" source https://mirror.invalid/source
|
||||
cmp "$SCRATCH/good" "$SCRATCH/fetched"
|
||||
printf '%s\n' https://primary.invalid/source https://mirror.invalid/source > "$SCRATCH/expected"
|
||||
cmp "$MIRROR_LOG" "$SCRATCH/expected"
|
||||
echo 'PASS primary timeout uses verified mirror'
|
||||
|
||||
: > "$MIRROR_LOG"
|
||||
qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
||||
"$SCRATCH/fetched" source https://mirror.invalid/source
|
||||
test ! -s "$MIRROR_LOG"
|
||||
echo 'PASS verified cache avoids both sources'
|
||||
|
||||
export MIRROR_MODE=bad
|
||||
: > "$MIRROR_LOG"
|
||||
if (qemu_fetch_verified https://primary.invalid/source "$WANT" \
|
||||
"$SCRATCH/refused" source https://mirror.invalid/source) > "$SCRATCH/refusal" 2>&1; then
|
||||
echo 'FAIL corrupt mirror was accepted' >&2
|
||||
exit 1
|
||||
fi
|
||||
test "$(wc -l < "$MIRROR_LOG")" -eq 3
|
||||
test ! -e "$SCRATCH/refused"
|
||||
test -z "$(find "$SCRATCH" -maxdepth 1 -name 'refused.download.*' -print -quit)"
|
||||
grep -q 'after 3 verified attempts' "$SCRATCH/refusal"
|
||||
echo 'PASS corrupt mirror refused within three attempts'
|
||||
|
||||
# Exercise the production source call with the downloader intercepted only
|
||||
# after build-busybox.sh loads its constants. Refuse before extraction.
|
||||
# shellcheck source=qemu/build-busybox.sh disable=SC1091
|
||||
source "$QEMU_DIR/build-busybox.sh"
|
||||
mkdir -p "$SCRATCH/toolchain"
|
||||
printf '#!/bin/sh\nexit 0\n' > "$SCRATCH/toolchain/fake-gcc"
|
||||
chmod 0755 "$SCRATCH/toolchain/fake-gcc"
|
||||
qemu_fetch_verified() {
|
||||
[ "$1" = "$BB_SRC_URL" ] && [ "$2" = "$BB_SRC_SHA256" ]
|
||||
[ "$5" = "$BB_SRC_MIRROR_URL" ]
|
||||
printf '%s\n' 'production mirror call verified' > "$SCRATCH/wired"
|
||||
return 42
|
||||
}
|
||||
set +e
|
||||
(set -e; OUT="$SCRATCH/build" CROSS_COMPILE="$SCRATCH/toolchain/fake-" JOBS=1 bb_main) \
|
||||
> "$SCRATCH/wiring-log" 2>&1
|
||||
status=$?
|
||||
set -e
|
||||
if [ "$status" -ne 42 ]; then
|
||||
cat "$SCRATCH/wiring-log" >&2
|
||||
echo 'FAIL production source call did not stop at the verified downloader' >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -qx 'production mirror call verified' "$SCRATCH/wired"
|
||||
echo 'PASS production source fetch supplies pinned mirror'
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/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 (the module gate fixtures
|
||||
# and the collection step use find and cp) 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 cp find)
|
||||
|
||||
# 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"
|
||||
Executable
+180
@@ -0,0 +1,180 @@
|
||||
#!/usr/bin/env bash
|
||||
# Hermetic tests for the collected-module gate (build/lib-module-gate.sh): a
|
||||
# module whose vermagic is not this kernel's is refused before it is copied,
|
||||
# in the test-only list and in a release list (aic8800), and the test-only
|
||||
# directory needs CONFIG_WARDEN_TEST_HANG=m. Fixtures only: no kernel tree, no
|
||||
# compiler, no network. The refusal paths run with a module of the wrong
|
||||
# vermagic, which the grep-only checks in run-test-hang-tests.sh never did.
|
||||
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; }
|
||||
|
||||
# shellcheck source=build/lib-module-gate.sh
|
||||
. "$REPO/build/lib-module-gate.sh"
|
||||
|
||||
KREL=6.18.46
|
||||
GOOD="6.18.46 SMP preempt mod_unload ARMv7 p2v8"
|
||||
STALE="5.10.0 SMP preempt mod_unload ARMv7"
|
||||
|
||||
# mkko <file> <vermagic>: a fixture module whose .modinfo holds the vermagic as
|
||||
# a NUL-separated string, the way a built .ko does.
|
||||
mkko() {
|
||||
mkdir -p "$(dirname "$1")"
|
||||
printf '\177ELF\000\000\000modinfo\000license=GPL\000vermagic=%s\000depends=\000' "$2" > "$1"
|
||||
}
|
||||
|
||||
# expect <label> <want status> <command...>: the command's status is checked.
|
||||
expect() {
|
||||
local label=$1 want=$2 rc
|
||||
shift 2
|
||||
"$@" > "$TMP/out" 2>&1; rc=$?
|
||||
if [ "$rc" -eq "$want" ]; then ok "$label"; else bad "$label (status $rc, want $want): $(tr '\n' ' ' < "$TMP/out")"; fi
|
||||
}
|
||||
|
||||
# expect_msg <label> <want status> <text> <command...>: the status and the
|
||||
# FATAL text (a fixed string) must both be there.
|
||||
expect_msg() {
|
||||
local label=$1 want=$2 text=$3 rc
|
||||
shift 3
|
||||
"$@" > "$TMP/out" 2>&1; rc=$?
|
||||
if [ "$rc" -eq "$want" ] && grep -qF -- "$text" "$TMP/out"; then
|
||||
ok "$label"
|
||||
else
|
||||
bad "$label (status $rc, want $want, text '$text'): $(tr '\n' ' ' < "$TMP/out")"
|
||||
fi
|
||||
}
|
||||
|
||||
# --- the vermagic of one module ---------------------------------------------
|
||||
|
||||
mkko "$TMP/v/good.ko" "$GOOD"
|
||||
expect "a module of this kernel's vermagic passes" 0 module_vermagic_check "$KREL" "$TMP/v/good.ko"
|
||||
mkko "$TMP/v/stale.ko" "$STALE"
|
||||
expect_msg "a 5.10 module is refused, the vermagic named" 1 "is not this kernel's '6.18.46'" \
|
||||
module_vermagic_check "$KREL" "$TMP/v/stale.ko"
|
||||
mkko "$TMP/v/rc.ko" "6.18.46-rc1 SMP preempt mod_unload ARMv7"
|
||||
expect_msg "a release that only starts with this kernel's string is refused" 1 "is not this kernel's" \
|
||||
module_vermagic_check "$KREL" "$TMP/v/rc.ko"
|
||||
printf '\177ELF\000\000\000modinfo\000license=GPL\000depends=\000' > "$TMP/v/none.ko"
|
||||
expect_msg "a module with no vermagic is refused" 1 "has no vermagic" \
|
||||
module_vermagic_check "$KREL" "$TMP/v/none.ko"
|
||||
expect_msg "an empty kernel release is refused" 1 "kernel release is empty" \
|
||||
module_vermagic_check "" "$TMP/v/good.ko"
|
||||
|
||||
# --- the collected list: copied only when every module passes ----------------
|
||||
|
||||
# The test-only list: a module of this kernel is collected and counted.
|
||||
T1="$TMP/tree-good"
|
||||
mkko "$T1/drivers/warden-test/warden_hang.ko" "$GOOD"
|
||||
mkdir -p "$TMP/out-good"
|
||||
if collect_modules "$T1" drivers/warden-test "$KREL" "$TMP/out-good" \
|
||||
&& [ "$COLLECTED" = 1 ] && [ -f "$TMP/out-good/warden_hang.ko" ]; then
|
||||
ok "the test-only list collects the module of this kernel (count 1, copied)"
|
||||
else
|
||||
bad "the test-only list collects the module of this kernel (count ${COLLECTED:-unset})"
|
||||
fi
|
||||
|
||||
# The test-only list with a stale module: refused, and the stale .ko is not copied.
|
||||
T2="$TMP/tree-stale-test"
|
||||
mkko "$T2/drivers/warden-test/warden_hang.ko" "$STALE"
|
||||
mkdir -p "$TMP/out-stale-test"
|
||||
collect_modules "$T2" drivers/warden-test "$KREL" "$TMP/out-stale-test" > "$TMP/out" 2>&1; rc=$?
|
||||
if [ "$rc" -eq 1 ] && grep -qF "is not this kernel's '6.18.46'" "$TMP/out" \
|
||||
&& [ ! -e "$TMP/out-stale-test/warden_hang.ko" ]; then
|
||||
ok "a stale module in the test-only list is refused and not copied"
|
||||
else
|
||||
bad "a stale module in the test-only list is refused and not copied (status $rc): $(tr '\n' ' ' < "$TMP/out")"
|
||||
fi
|
||||
|
||||
# A release list (aic8800, as ci.yml lists it) gets the same gate: one stale
|
||||
# module among good ones refuses the list and the stale module is not copied.
|
||||
T3="$TMP/tree-stale-release"
|
||||
D3=drivers/net/wireless/aic8800
|
||||
mkko "$T3/$D3/aic8800_fdrv.ko" "$STALE"
|
||||
mkko "$T3/$D3/aic8800_btlpm.ko" "$GOOD"
|
||||
mkdir -p "$TMP/out-stale-release"
|
||||
collect_modules "$T3" "$D3" "$KREL" "$TMP/out-stale-release" > "$TMP/out" 2>&1; rc=$?
|
||||
if [ "$rc" -eq 1 ] && grep -qF "is not this kernel's" "$TMP/out" \
|
||||
&& [ ! -e "$TMP/out-stale-release/aic8800_fdrv.ko" ]; then
|
||||
ok "a stale module in a release list (aic8800) is refused and not copied"
|
||||
else
|
||||
bad "a stale module in a release list (aic8800) is refused and not copied (status $rc)"
|
||||
fi
|
||||
|
||||
# A good release list collects every module.
|
||||
T4="$TMP/tree-good-release"
|
||||
mkko "$T4/$D3/aic8800_fdrv.ko" "$GOOD"
|
||||
mkko "$T4/$D3/aic8800_btlpm.ko" "$GOOD"
|
||||
mkdir -p "$TMP/out-good-release"
|
||||
if collect_modules "$T4" "$D3" "$KREL" "$TMP/out-good-release" && [ "$COLLECTED" = 2 ]; then
|
||||
ok "a good release list collects both modules (count 2)"
|
||||
else
|
||||
bad "a good release list collects both modules (count ${COLLECTED:-unset})"
|
||||
fi
|
||||
|
||||
expect_msg "a listed directory missing from the tree is refused" 1 "not in tree" \
|
||||
collect_modules "$TMP/tree-absent" drivers/warden-test "$KREL" "$TMP/out-good"
|
||||
mkdir -p "$TMP/tree-empty/drivers/warden-test"
|
||||
expect_msg "a listed directory with no module is refused" 1 "no .ko produced" \
|
||||
collect_modules "$TMP/tree-empty" drivers/warden-test "$KREL" "$TMP/out-good"
|
||||
|
||||
# --- the test symbol: which directory needs it, and what it must be ----------
|
||||
|
||||
if [ "$(test_symbol_of drivers/warden-test)" = WARDEN_TEST_HANG ]; then
|
||||
ok "the test-only directory maps to CONFIG_WARDEN_TEST_HANG"
|
||||
else
|
||||
bad "the test-only directory maps to CONFIG_WARDEN_TEST_HANG"
|
||||
fi
|
||||
if [ -z "$(test_symbol_of drivers/net/wireless/aic8800)" ]; then
|
||||
ok "a release directory needs no test symbol"
|
||||
else
|
||||
bad "a release directory needs no test symbol"
|
||||
fi
|
||||
|
||||
printf 'CONFIG_WARDEN_TEST_HANG=m\n' > "$TMP/cfg-m"
|
||||
expect "=m after olddefconfig passes for the test-only directory" 0 \
|
||||
require_test_config "$TMP/cfg-m" drivers/warden-test
|
||||
printf 'CONFIG_WARDEN_TEST_HANG=y\n' > "$TMP/cfg-y"
|
||||
expect_msg "=y is refused (it would not give a .ko)" 1 "needs CONFIG_WARDEN_TEST_HANG=m" \
|
||||
require_test_config "$TMP/cfg-y" drivers/warden-test
|
||||
printf '# CONFIG_WARDEN_TEST_HANG is not set\n' > "$TMP/cfg-unset"
|
||||
expect_msg "an unset symbol is refused (the dependency was unmet)" 1 "did not survive olddefconfig" \
|
||||
require_test_config "$TMP/cfg-unset" drivers/warden-test
|
||||
: > "$TMP/cfg-none"
|
||||
expect_msg "a configuration without the symbol is refused" 1 "did not survive olddefconfig" \
|
||||
require_test_config "$TMP/cfg-none" drivers/warden-test
|
||||
expect "a missing configuration file is refused" 1 \
|
||||
require_test_config "$TMP/cfg-absent" drivers/warden-test
|
||||
expect "a release list needs no symbol in any configuration" 0 \
|
||||
require_test_config "$TMP/cfg-none" drivers/net/wireless/aic8800
|
||||
|
||||
# --- build-kernel.sh runs the gate on every collected list ------------------
|
||||
|
||||
BK="$REPO/build/build-kernel.sh"
|
||||
if grep -q '^\. "\$HERE/lib-module-gate\.sh"$' "$BK"; then
|
||||
ok "build-kernel.sh sources the module gate"
|
||||
else
|
||||
bad "build-kernel.sh sources the module gate"
|
||||
fi
|
||||
if grep -q 'collect_modules "\$SRC" "\$d" "\$KREL" "\$MODOUT" || exit 1' "$BK"; then
|
||||
ok "build-kernel.sh collects every listed directory through collect_modules"
|
||||
else
|
||||
bad "build-kernel.sh collects every listed directory through collect_modules"
|
||||
fi
|
||||
if grep -q 'require_test_config "\$SRC/.config" "\$d" || exit 1' "$BK"; then
|
||||
ok "build-kernel.sh asserts the test symbol after olddefconfig"
|
||||
else
|
||||
bad "build-kernel.sh asserts the test symbol after olddefconfig"
|
||||
fi
|
||||
if grep -v '^[[:space:]]*#' "$BK" | grep -q 'WARDEN_TEST_HANG\|warden-test'; then
|
||||
bad "build-kernel.sh names the test directory or symbol in code (it belongs in the gate)"
|
||||
else
|
||||
ok "build-kernel.sh names the test directory and symbol only in comments"
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then echo "module-gate: all checks passed"; else echo "module-gate: FAILED"; fi
|
||||
exit "$FAIL"
|
||||
Executable
+148
@@ -0,0 +1,148 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user