Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5494b87dc3 | ||
|
|
13cd0c63be | ||
|
|
d279bc4c9f | ||
|
|
44b96074ed | ||
|
|
b7be6f7fbe | ||
|
|
7d18896a0d | ||
|
|
b94fd156b4 | ||
|
|
f435a7d665 | ||
|
|
be4ad86230 | ||
|
|
aadf0e7f07 | ||
|
|
6f931bf3ad | ||
|
|
5507842878 | ||
|
|
35dc64714e | ||
|
|
cf72a6dcbc | ||
|
|
0589829619 | ||
|
|
8615f7c13a | ||
|
|
469f31c278 | ||
|
|
aa6956f595 | ||
|
|
445b2082f5 | ||
|
|
0360b8dc46 |
@@ -112,7 +112,9 @@ jobs:
|
||||
qemu/rootfs/etc/warden-lib.sh qemu/rootfs/etc/rc \
|
||||
qemu/rootfs/sbin/init qemu/rootfs/init tests/mk-bootimg/*.sh \
|
||||
tests/fetch-vendor/*.sh tests/fetch-buildroot-tarball/*.sh \
|
||||
tests/unpack-buildroot/*.sh
|
||||
tests/fetch-kernel-tarball/*.sh tests/unpack-buildroot/*.sh
|
||||
- name: qemu init shellcheck regression test
|
||||
run: bash tests/qemu-init/run-init-shellcheck-tests.sh
|
||||
- name: cache apt archives (python3-pil)
|
||||
# Same cost class as the busybox binary cached below: a system package
|
||||
# plus its libjpeg/libpng transitive deps, downloaded fresh on every
|
||||
@@ -153,6 +155,16 @@ jobs:
|
||||
run: bash qemu/tests/init-power-signals-test.sh
|
||||
- name: rig init daemon order matches the panel (flare-edge#348)
|
||||
run: bash qemu/tests/init-daemon-order-test.sh
|
||||
- name: rig bus starts when the payload carries a broker (flare-edge#1754)
|
||||
# A stub broker stands in for mosquitto (the runner has none), and
|
||||
# once more under busybox sh, the rig's own shell.
|
||||
run: |
|
||||
bash qemu/tests/init-rig-bus-test.sh
|
||||
if command -v busybox >/dev/null; then
|
||||
WARDEN_TEST_SH="busybox sh" bash qemu/tests/init-rig-bus-test.sh
|
||||
fi
|
||||
- name: rig control bridge waits out a slow UI (flare-edge#1448)
|
||||
run: bash qemu/tests/ctl-bridge-test.sh
|
||||
- name: mkimage.sh SEED_DIR regression test
|
||||
# Only ui-drive.sh --seed (a real VM boot) exercises this hook
|
||||
# otherwise; this builds the same unprivileged mkfs.ext4 image and
|
||||
@@ -171,6 +183,14 @@ jobs:
|
||||
# Retry-on-mismatch, cleanup, and the already-verified
|
||||
# short-circuit, against a fake curl on PATH: no network.
|
||||
run: bash tests/fetch-buildroot-tarball/run-fetch-buildroot-tarball-tests.sh
|
||||
- name: fetch-kernel-tarball regression tests
|
||||
# Bounded curl and no partial tarball after a failed fetch (#1588),
|
||||
# against a fake curl on PATH: no network.
|
||||
run: bash tests/fetch-kernel-tarball/run-fetch-kernel-tarball-tests.sh
|
||||
- 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
|
||||
- name: unpack-buildroot regression tests
|
||||
# Fresh unpack, leave-existing-tree-alone, and every refusal path
|
||||
# (unpatched selectors, bad tarball, half-present tree, failed
|
||||
@@ -201,6 +221,65 @@ jobs:
|
||||
- name: build A/B disk image
|
||||
run: bash qemu/mkimage.sh
|
||||
|
||||
kernel-symbols:
|
||||
# The symbol gate (rebuild M0, kernel_symbols_exist): expand the real
|
||||
# configuration (pristine tarball + patch series + warden_defconfig) and
|
||||
# assert build/required-symbols.txt and probe-symbols.txt against the final
|
||||
# .config, without compiling. olddefconfig drops a symbol that does not exist
|
||||
# or whose dependencies are unmet without a word; this is what turns that
|
||||
# into a red check on every push, in seconds rather than the ~9 minutes of a
|
||||
# kernel build. The generic arm cross toolchain is enough: only the compiler
|
||||
# version text of the configuration depends on it.
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: offline symbol-list tests
|
||||
run: bash tests/required-symbols/run-required-symbols-tests.sh
|
||||
- name: install cross toolchain + kernel config deps
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq gcc-arm-linux-gnueabihf bc bison flex libssl-dev
|
||||
- name: provision `python` (SDK quirk, the build calls bare python)
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/bin"
|
||||
ln -sf "$(command -v python3)" "$RUNNER_TEMP/bin/python"
|
||||
echo "$RUNNER_TEMP/bin" >> "$GITHUB_PATH"
|
||||
- name: cache pristine kernel tarball
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/linux-6.18.46.tar.xz
|
||||
key: linux-6.18.46-tarball
|
||||
- name: expand the configuration and assert the symbols
|
||||
env:
|
||||
# WORK must be OUTSIDE the repo checkout (git apply, issue #1).
|
||||
WORK: ${{ runner.temp }}/kcfg-work
|
||||
CONFIG_OUT: ${{ runner.temp }}/final.config
|
||||
CROSS_COMPILE: arm-linux-gnueabihf-
|
||||
WARDEN_CONFIG_ONLY: "1"
|
||||
run: |
|
||||
export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz"
|
||||
bash build/build-kernel.sh
|
||||
test -s "$CONFIG_OUT" && test -s "$CONFIG_OUT.sha256"
|
||||
# the sidecar is the sha256 of the file it sits beside
|
||||
test "$(sha256sum "$CONFIG_OUT" | cut -d' ' -f1)" = "$(cat "$CONFIG_OUT.sha256")"
|
||||
- name: the expansion is deterministic (same inputs, same digest)
|
||||
env:
|
||||
WORK: ${{ runner.temp }}/kcfg-work-2
|
||||
CONFIG_OUT: ${{ runner.temp }}/final-2.config
|
||||
CROSS_COMPILE: arm-linux-gnueabihf-
|
||||
WARDEN_CONFIG_ONLY: "1"
|
||||
run: |
|
||||
export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz"
|
||||
bash build/build-kernel.sh
|
||||
cmp "${{ runner.temp }}/final.config" "$CONFIG_OUT"
|
||||
- name: the digest does not depend on the host python (issue #19)
|
||||
env:
|
||||
CROSS_COMPILE: arm-linux-gnueabihf-
|
||||
run: |
|
||||
export KERNEL_TARBALL="$HOME/linux-6.18.46.tar.xz"
|
||||
bash tests/required-symbols/run-config-determinism-tests.sh
|
||||
|
||||
patches-apply:
|
||||
# The RV1106 series must apply cleanly onto pristine linux-6.18.46.
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -47,6 +47,13 @@ Add `WARDEN_KCONFIG_FRAGMENT=qemu/configs/virt.fragment` to step 1 for the
|
||||
kernel variant with the simulator's extra devices; `qemu/README.md` has the
|
||||
scenario tests (portal, OTA apply, display + touch, watchdog).
|
||||
|
||||
Every kernel symbol the platform needs is listed in `build/required-symbols.txt`
|
||||
(and `build/probe-symbols.txt` for a symbol under test). `build-kernel.sh` asserts
|
||||
both against the final `.config`, because `olddefconfig` drops an unknown or
|
||||
unsatisfied symbol without a word. `WARDEN_CONFIG_ONLY=1 CONFIG_OUT=<file>` stops
|
||||
after that assertion, so the gate takes seconds; `<file>.sha256` holds the digest
|
||||
of the final `.config` that firmware images record as `KCONFIG_SHA256`.
|
||||
|
||||
## Layout
|
||||
|
||||
| Directory | Contents |
|
||||
|
||||
+52
-15
@@ -19,6 +19,15 @@
|
||||
# (qemu/configs/virt.fragment builds the QEMU -M virt variant);
|
||||
# every fragment option is verified to have taken effect
|
||||
# WARDEN_CCACHE=1 compile through ccache (CI caches ~/.ccache)
|
||||
# WARDEN_CONFIG_ONLY=1
|
||||
# stop after the configuration and the symbol assertions
|
||||
# (no compile): a seconds-long symbol gate for CI and the
|
||||
# pre-build identity of /etc/warden-release. Needs CONFIG_OUT
|
||||
# or an explicit WORK, because a scratch WORK is removed.
|
||||
# CONFIG_OUT where the final .config is copied (default
|
||||
# $WORK/final.config); ${CONFIG_OUT}.sha256 gets its sha256
|
||||
# (hex only). Written by both modes: the config-only value
|
||||
# must equal the full build's, and the build checks it.
|
||||
# WARDEN_MODULES_COLLECT
|
||||
# space-separated in-tree dirs whose .ko files are wanted
|
||||
# (e.g. "drivers/net/wireless/aic8800"). Runs a full
|
||||
@@ -32,6 +41,10 @@ set -euo pipefail
|
||||
|
||||
KVER=6.18.46
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # build/
|
||||
# shellcheck source=build/lib-required-symbols.sh
|
||||
. "$HERE/lib-required-symbols.sh"
|
||||
REQ_SYMBOLS="$HERE/required-symbols.txt"
|
||||
PROBE_SYMBOLS="$HERE/probe-symbols.txt"
|
||||
REPO="$(cd "$HERE/.." && pwd)"
|
||||
PATCHES="$REPO/patches"
|
||||
JOBS="${JOBS:-$(nproc)}"
|
||||
@@ -48,6 +61,16 @@ else
|
||||
WORK_OWNED=1
|
||||
fi
|
||||
trap '[ "${WORK_OWNED:-0}" = 1 ] && rm -rf "$WORK"' EXIT
|
||||
CONFIG_ONLY="${WARDEN_CONFIG_ONLY:-0}"
|
||||
case "$CONFIG_ONLY" in
|
||||
0|1) ;;
|
||||
*) echo "FATAL: WARDEN_CONFIG_ONLY must be 0 or 1, got '$CONFIG_ONLY'" >&2; exit 1 ;;
|
||||
esac
|
||||
if [ "$CONFIG_ONLY" = 1 ] && [ "$WORK_OWNED" = 1 ] && [ -z "${CONFIG_OUT:-}" ]; then
|
||||
echo "FATAL: WARDEN_CONFIG_ONLY=1 needs CONFIG_OUT (or an explicit WORK): a scratch WORK is removed on exit" >&2
|
||||
exit 1
|
||||
fi
|
||||
CONFIG_OUT="${CONFIG_OUT:-$WORK/final.config}"
|
||||
|
||||
log() { printf '\033[36m== %s\033[0m\n' "$*"; }
|
||||
|
||||
@@ -121,21 +144,17 @@ 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
|
||||
|
||||
# Took-effect assertion for the symbols whose silent loss is a security hole,
|
||||
# not a build failure. olddefconfig drops a defconfig line whose dependencies
|
||||
# are unmet without a word, and the panel's firewall then quietly stops
|
||||
# covering IPv6 (flare-edge#533: no ip6tables filter table, so the IPv4
|
||||
# default-drop never applied to IPv6). Every symbol here must be built in
|
||||
# (=y): the panel has no /lib/modules.
|
||||
req_fail=0
|
||||
for sym in CONFIG_NF_DEFRAG_IPV6 CONFIG_IP6_NF_IPTABLES \
|
||||
CONFIG_IP6_NF_IPTABLES_LEGACY CONFIG_IP6_NF_FILTER; do
|
||||
grep -qxF "$sym=y" "$SRC/.config" || {
|
||||
echo "FATAL: required option $sym is not =y in the final .config (unmet Kconfig dependency?)" >&2
|
||||
req_fail=1
|
||||
}
|
||||
done
|
||||
[ "$req_fail" = 0 ] || exit 1
|
||||
# Took-effect assertion for every symbol the platform needs. olddefconfig drops
|
||||
# a defconfig line whose dependencies are unmet, or whose symbol does not exist,
|
||||
# without a word: flare-edge#533 shipped a firewall that quietly stopped
|
||||
# covering IPv6 that way. build/required-symbols.txt (and build/probe-symbols.txt
|
||||
# for a probe kernel) is the one list; every symbol in it is built in (=y, the
|
||||
# panel has no /lib/modules) or explicitly unset.
|
||||
# The probe list may be empty (every probe has passed); the required list may not.
|
||||
PROBE_LISTS=()
|
||||
[ -n "$(req_assertions "$PROBE_SYMBOLS")" ] && PROBE_LISTS=("$PROBE_SYMBOLS")
|
||||
req_assert_config "$SRC/.config" "$REQ_SYMBOLS" ${PROBE_LISTS[@]+"${PROBE_LISTS[@]}"} || exit 1
|
||||
log "required symbols verified in final .config ($(req_assertions "$REQ_SYMBOLS" | wc -l) required, $(req_assertions "$PROBE_SYMBOLS" | wc -l) probe)"
|
||||
|
||||
# Fragment took-effect assertion: merge_config -m only pastes text, and
|
||||
# olddefconfig silently resolves any symbol whose dependencies are unmet:
|
||||
@@ -167,6 +186,21 @@ if [ -n "${WARDEN_KCONFIG_FRAGMENT:-}" ]; then
|
||||
log "fragment options verified in final .config"
|
||||
fi
|
||||
|
||||
# The final .config, and its identity. KCONFIG_SHA256 in /etc/warden-release is
|
||||
# this digest (the whole file, compiler version text included): CONFIG_IKCONFIG_PROC
|
||||
# embeds a byte copy, so /proc/config.gz hashes to the same value.
|
||||
emit_config_identity() {
|
||||
mkdir -p "$(dirname "$CONFIG_OUT")"
|
||||
cp "$SRC/.config" "$CONFIG_OUT"
|
||||
sha256sum "$CONFIG_OUT" | awk '{print $1}' > "$CONFIG_OUT.sha256"
|
||||
echo "final.config sha256: $(cat "$CONFIG_OUT.sha256")"
|
||||
}
|
||||
if [ "$CONFIG_ONLY" = 1 ]; then
|
||||
emit_config_identity
|
||||
log "config-only: symbols verified, stopping before the compile"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Optional ccache (CI: cache ~/.ccache across dispatches; harmless if unset).
|
||||
KCC="${CROSS_COMPILE}gcc"
|
||||
if [ "${WARDEN_CCACHE:-0}" = 1 ]; then
|
||||
@@ -201,6 +235,9 @@ if [ -n "${WARDEN_MODULES_COLLECT:-}" ]; then
|
||||
ls -la "$MODOUT"
|
||||
fi
|
||||
|
||||
# Identity of the .config the compile actually used, not the one before it.
|
||||
emit_config_identity
|
||||
|
||||
Z="$SRC/arch/arm/boot/zImage"
|
||||
D="$SRC/arch/arm/boot/dts/rockchip/rv1106-warden.dtb"
|
||||
log "build OK"
|
||||
|
||||
@@ -22,7 +22,16 @@ TB="${1:?usage: fetch-kernel-tarball.sh <destination-path>}"
|
||||
}
|
||||
if [ ! -f "$TB" ]; then
|
||||
echo "== downloading $URL"
|
||||
curl --retry 3 --retry-delay 5 --retry-connrefused -fSL "$URL" -o "$TB"
|
||||
# Bounded (#1588): a connection that opens and then stalls gives up after
|
||||
# 30 s below 10 KiB/s and is retried, instead of holding the job until its
|
||||
# own timeout. The download lands beside $TB and is renamed only when curl
|
||||
# succeeds, so a failed fetch never leaves a partial tarball that the next
|
||||
# run would take as present and then reject on its sha256.
|
||||
tmp="$TB.download.$$"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
curl --retry 2 --retry-delay 5 --retry-connrefused --connect-timeout 20 \
|
||||
--speed-limit 10240 --speed-time 30 --max-time 600 -fSL "$URL" -o "$tmp"
|
||||
mv -f "$tmp" "$TB"
|
||||
fi
|
||||
want="$(cat "$SHA_FILE")"
|
||||
got="$(sha256sum "$TB" | awk '{print $1}')"
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# shellcheck shell=bash
|
||||
# Shared by build-kernel.sh and the symbol tests (tests/required-symbols/).
|
||||
#
|
||||
# build/required-symbols.txt is the source of record for every kernel symbol
|
||||
# the platform needs (rebuild M0, names.md 21.1). Format, one item per line:
|
||||
#
|
||||
# CONFIG_X=y assert the symbol is =y in the final .config
|
||||
# # CONFIG_X is not set assert the symbol is NOT set (an explicit unset)
|
||||
# ## tier R section header (R required, C recommended,
|
||||
# A assertion only / derived, never in a defconfig)
|
||||
# # any other text comment
|
||||
# (blank lines ignored)
|
||||
#
|
||||
# build/probe-symbols.txt has the same format for tier P: symbols built into
|
||||
# the test kernel to run a probe. They are asserted like the others, and join
|
||||
# required-symbols.txt only when the probe passes.
|
||||
|
||||
# req_assertions FILE: print the assertion lines of FILE.
|
||||
req_assertions() {
|
||||
grep -E '^(CONFIG_[A-Za-z0-9_]+=[ymn]|# CONFIG_[A-Za-z0-9_]+ is not set)$' "$1" || true
|
||||
}
|
||||
|
||||
# req_assert_config CONFIG LIST...: check each assertion of each LIST against
|
||||
# CONFIG (a final .config). Prints one FATAL line per failure and returns 1 if
|
||||
# any failed. A missing or empty LIST is itself a failure (fail closed).
|
||||
req_assert_config() {
|
||||
local cfg="$1" list line opt n bad=0
|
||||
shift
|
||||
[ -s "$cfg" ] || { echo "FATAL: config '$cfg' is missing or empty" >&2; return 1; }
|
||||
for list in "$@"; do
|
||||
[ -f "$list" ] || { echo "FATAL: symbol list '$list' is missing" >&2; return 1; }
|
||||
n=0
|
||||
while IFS= read -r line; do
|
||||
n=$((n + 1))
|
||||
case "$line" in
|
||||
CONFIG_*=*)
|
||||
grep -qxF "$line" "$cfg" || {
|
||||
echo "FATAL: required option $line is not in the final .config (unmet Kconfig dependency, or the symbol does not exist?)" >&2
|
||||
bad=1
|
||||
} ;;
|
||||
"# CONFIG_"*" is not set")
|
||||
# An unset holds if the symbol is absent or shown as "is not set";
|
||||
# only a live =value fails (a dependency may hide the symbol).
|
||||
opt="${line#\# }"; opt="${opt% is not set}"
|
||||
grep -qE "^$opt=" "$cfg" && {
|
||||
echo "FATAL: option $opt must not be set but is in the final .config" >&2
|
||||
bad=1
|
||||
} ;;
|
||||
esac
|
||||
done < <(req_assertions "$list")
|
||||
[ "$n" -gt 0 ] || { echo "FATAL: symbol list '$list' holds no assertions" >&2; return 1; }
|
||||
done
|
||||
return "$bad"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
## Tier P: symbols built into a test kernel to run a probe (rebuild M0).
|
||||
## Asserted like required-symbols.txt. A symbol moves to required-symbols.txt when its probe
|
||||
## passes on the panel, and leaves this file and the defconfig when it fails.
|
||||
##
|
||||
## Empty on purpose: probe V3 (hardware RNG, N-36, d06 O14, d09 T14) passed on 2026-10-09, so
|
||||
## CONFIG_HW_RANDOM and CONFIG_HW_RANDOM_ROCKCHIP moved to required-symbols.txt. An empty list
|
||||
## is valid for this file (build-kernel.sh skips it); required-symbols.txt may never be empty.
|
||||
@@ -0,0 +1,83 @@
|
||||
## Kernel symbols the platform needs. Source of record (rebuild M0, names.md
|
||||
## 21.1): build-kernel.sh asserts every line against the final .config, the
|
||||
## tests/required-symbols guards read this file, and the FE kernel_symbols_exist
|
||||
## gate checks every CONFIG_ name in the specs against it and the Kconfig tree.
|
||||
## Format: see build/lib-required-symbols.sh. Tier P lives in probe-symbols.txt.
|
||||
##
|
||||
## tier R already shipped (flare-edge#533)
|
||||
CONFIG_NF_DEFRAG_IPV6=y
|
||||
CONFIG_IP6_NF_IPTABLES=y
|
||||
CONFIG_IP6_NF_IPTABLES_LEGACY=y
|
||||
CONFIG_IP6_NF_FILTER=y
|
||||
##
|
||||
## tier R cgroup v2 controllers (W-D7)
|
||||
CONFIG_MEMCG=y
|
||||
CONFIG_CGROUP_PIDS=y
|
||||
CONFIG_CGROUP_SCHED=y
|
||||
CONFIG_FAIR_GROUP_SCHED=y
|
||||
CONFIG_CFS_BANDWIDTH=y
|
||||
##
|
||||
## tier R byte metering (D50 D51 D52)
|
||||
CONFIG_NETFILTER_XT_MATCH_CGROUP=y
|
||||
CONFIG_NETFILTER_XT_CONNMARK=y
|
||||
CONFIG_NETFILTER_XT_MARK=y
|
||||
CONFIG_IP6_NF_MANGLE=y
|
||||
##
|
||||
## tier R /proc/config.gz (D51)
|
||||
CONFIG_IKCONFIG=y
|
||||
CONFIG_IKCONFIG_PROC=y
|
||||
##
|
||||
## tier R uid fallback and NOTRACK (SCH-04, flare-edge#537)
|
||||
CONFIG_NETFILTER_XT_MATCH_OWNER=y
|
||||
CONFIG_IP_NF_RAW=y
|
||||
CONFIG_IP6_NF_RAW=y
|
||||
CONFIG_NETFILTER_XT_TARGET_CT=y
|
||||
##
|
||||
## tier R namespaces and PSI (SCH-04, NN-11)
|
||||
CONFIG_NAMESPACES=y
|
||||
CONFIG_UTS_NS=y
|
||||
CONFIG_IPC_NS=y
|
||||
CONFIG_PID_NS=y
|
||||
CONFIG_NET_NS=y
|
||||
CONFIG_USER_NS=y
|
||||
CONFIG_PSI=y
|
||||
##
|
||||
## tier R nftables (N-40)
|
||||
CONFIG_NF_TABLES=y
|
||||
CONFIG_NF_TABLES_IPV4=y
|
||||
CONFIG_NF_TABLES_IPV6=y
|
||||
CONFIG_NFT_CT=y
|
||||
CONFIG_NFT_MASQ=y
|
||||
CONFIG_NFT_NAT=y
|
||||
CONFIG_NFT_LIMIT=y
|
||||
CONFIG_NFT_SOCKET=y
|
||||
CONFIG_NFT_REJECT=y
|
||||
##
|
||||
## tier R hardware RNG (N-36, d06 O14). Probe V3 passed on the bench panel on 2026-10-09
|
||||
## (/dev/hwrng from rockchip-rng, 2.6 MB read in 2.4 s, 1 FIPS 140-2 failure in 1000 blocks), so
|
||||
## the two symbols moved here from probe-symbols.txt.
|
||||
CONFIG_HW_RANDOM=y
|
||||
CONFIG_HW_RANDOM_ROCKCHIP=y
|
||||
##
|
||||
## tier A power: no suspend (Noah 2026-10-09). The two lines below are derived
|
||||
## off with it; assert them so a Kconfig change cannot bring them back.
|
||||
# CONFIG_SUSPEND is not set
|
||||
# CONFIG_PM_SLEEP is not set
|
||||
##
|
||||
## tier C recommended
|
||||
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
|
||||
CONFIG_NF_CONNTRACK_PROCFS=y
|
||||
##
|
||||
## tier A assertion only (a defconfig line is optional)
|
||||
CONFIG_SECCOMP=y
|
||||
CONFIG_SECCOMP_FILTER=y
|
||||
CONFIG_MULTIUSER=y
|
||||
CONFIG_SYSVIPC=y
|
||||
# CONFIG_RT_GROUP_SCHED is not set
|
||||
# CONFIG_TIME_NS is not set
|
||||
##
|
||||
## tier A derived (selected or defaulted by other symbols; never in a defconfig)
|
||||
CONFIG_NF_CONNTRACK_MARK=y
|
||||
CONFIG_SOCK_CGROUP_DATA=y
|
||||
CONFIG_NFT_REJECT_IPV4=y
|
||||
CONFIG_NFT_REJECT_IPV6=y
|
||||
@@ -1395,3 +1395,101 @@ CONFIG_NF_DEFRAG_IPV6=y
|
||||
CONFIG_IP6_NF_IPTABLES=y
|
||||
CONFIG_IP6_NF_IPTABLES_LEGACY=y
|
||||
CONFIG_IP6_NF_FILTER=y
|
||||
#
|
||||
# Cgroup v2 controllers, byte metering, raw table, namespaces and PSI
|
||||
# (rebuild M0; D50 D51 D52 W-D7 SCH-04 N-40 NN-11). The single kernel flash:
|
||||
# every option later work needs, so no second t2 update reaches a panel.
|
||||
# build/required-symbols.txt is the source of record and build-kernel.sh
|
||||
# asserts every line of it against the final .config. All built in: the panel
|
||||
# has no /lib/modules.
|
||||
#
|
||||
# Per-app limits (W-D7): memory.max / memory.events / memory.oom.group,
|
||||
# pids.max, cpu.weight and the cpu.max hard cap.
|
||||
CONFIG_MEMCG=y
|
||||
CONFIG_CGROUP_PIDS=y
|
||||
CONFIG_CGROUP_SCHED=y
|
||||
CONFIG_FAIR_GROUP_SCHED=y
|
||||
CONFIG_CFS_BANDWIDTH=y
|
||||
# RT group scheduling would block the v2 cpu controller; it must stay off.
|
||||
# CONFIG_RT_GROUP_SCHED is not set
|
||||
#
|
||||
# Byte metering by cgroup (D50 D51 D52): the cgroup match, CONNMARK so inbound
|
||||
# replies inherit the service, the mark match, and the ip6tables mangle table
|
||||
# (it defaults to =m under legacy). The meter itself is nftables since N-40.
|
||||
CONFIG_NETFILTER_XT_MATCH_CGROUP=y
|
||||
CONFIG_NETFILTER_XT_CONNMARK=y
|
||||
CONFIG_NETFILTER_XT_MARK=y
|
||||
CONFIG_IP6_NF_MANGLE=y
|
||||
#
|
||||
# /proc/config.gz (D51). IKCONFIG is a tristate: it must be =y, no module tree.
|
||||
# The whole .config digest (KCONFIG_SHA256 in /etc/warden-release) equals the
|
||||
# sha256 of the decompressed embed.
|
||||
CONFIG_IKCONFIG=y
|
||||
CONFIG_IKCONFIG_PROC=y
|
||||
#
|
||||
# Uid fallback metering (SCH-04), and the raw table with the CT target for the
|
||||
# NOTRACK of the discovery sweep (flare-edge#537). The legacy tables stay for
|
||||
# that interim and for any legacy tool in the image.
|
||||
CONFIG_NETFILTER_XT_MATCH_OWNER=y
|
||||
CONFIG_IP_NF_RAW=y
|
||||
CONFIG_IP6_NF_RAW=y
|
||||
CONFIG_NETFILTER_XT_TARGET_CT=y
|
||||
#
|
||||
# Cheap rule helpers. CONNTRACK_PROCFS keeps /proc/net/nf_conntrack so the
|
||||
# cause of #537 and its fix can be proven (C14).
|
||||
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
|
||||
CONFIG_NF_CONNTRACK_PROCFS=y
|
||||
#
|
||||
# Namespaces for future app sandboxing (SCH-04, NN-11): NAMESPACES is a prompt
|
||||
# only under EXPERT and defaults off there, so it needs this line. All five
|
||||
# sub-options are set; USER_NS stays closed at runtime by
|
||||
# user.max_user_namespaces=0 (S02warden-sysctl) until the app sandbox needs it.
|
||||
# TIME_NS defaults on, so it is unset explicitly.
|
||||
CONFIG_NAMESPACES=y
|
||||
CONFIG_UTS_NS=y
|
||||
CONFIG_IPC_NS=y
|
||||
CONFIG_PID_NS=y
|
||||
CONFIG_NET_NS=y
|
||||
CONFIG_USER_NS=y
|
||||
# CONFIG_TIME_NS is not set
|
||||
#
|
||||
# Pressure stall information (SCH-04): /proc/pressure/* and per-cgroup
|
||||
# cpu.pressure and memory.pressure. On at boot (PSI_DEFAULT_DISABLED stays off).
|
||||
CONFIG_PSI=y
|
||||
#
|
||||
# nftables (N-40): the applier and the meter target nft in the families ip and
|
||||
# ip6. Counters, meta, payload, sets and jump are nf_tables core; there is no
|
||||
# NFT_COUNTER symbol. NFT_REJECT_IPV4 and NFT_REJECT_IPV6 have no prompt and
|
||||
# derive from NFT_REJECT, so they are asserted in required-symbols.txt and
|
||||
# never set here (a line for a promptless symbol is dropped).
|
||||
CONFIG_NF_TABLES=y
|
||||
CONFIG_NF_TABLES_IPV4=y
|
||||
CONFIG_NF_TABLES_IPV6=y
|
||||
CONFIG_NFT_CT=y
|
||||
CONFIG_NFT_MASQ=y
|
||||
CONFIG_NFT_NAT=y
|
||||
CONFIG_NFT_LIMIT=y
|
||||
CONFIG_NFT_SOCKET=y
|
||||
CONFIG_NFT_REJECT=y
|
||||
#
|
||||
# No suspend (rebuild M0, Noah 2026-10-09): the panel is wall powered and never
|
||||
# sleeps the SoC, and nothing in the product wakes it. Turning SUSPEND off lets
|
||||
# Kconfig drop everything that existed only for it: PM_SLEEP and PM_SLEEP_SMP,
|
||||
# SUSPEND_FREEZER and FREEZER, PM_GENERIC_DOMAINS_SLEEP, FW_CACHE (firmware
|
||||
# cached across a suspend) and VT_CONSOLE_SLEEP. PM_SLEEP_SMP was also the only
|
||||
# thing selecting HOTPLUG_CPU on this one-core SoC, and an SMP ARM kernel offers
|
||||
# KEXEC and CRASH_DUMP only with it, so those go too (nothing uses them: the
|
||||
# kexec flash path was a 5.10 experiment). PM, PM_CLK, runtime PM and
|
||||
# ARM_CPU_SUSPEND (kept by ARM_PSCI_FW) stay, because the USB, DRM and Wi-Fi
|
||||
# drivers use runtime PM. Hibernation was already off. The AIC8800 driver must
|
||||
# keep building and loading; the SDK build and the slot test prove it.
|
||||
# CONFIG_SUSPEND is not set
|
||||
# PM_SLEEP has no prompt and follows SUSPEND; the line records the expected result, and
|
||||
# required-symbols.txt asserts it against the final .config.
|
||||
# CONFIG_PM_SLEEP is not set
|
||||
#
|
||||
# Probe tier (N-36, d06 O14, probe V3): the Rockchip hardware RNG, built into
|
||||
# the test kernel. build/probe-symbols.txt lists it; it moves to
|
||||
# required-symbols.txt only if V3 passes on the panel, and comes out of this
|
||||
# file if it fails.
|
||||
CONFIG_HW_RANDOM_ROCKCHIP=y
|
||||
|
||||
@@ -337,12 +337,21 @@ static struct rockchip_clk_branch rv1106_clk_branches[] __initdata = {
|
||||
/* PD_CORE */
|
||||
GATE(CLK_PVTM_CORE, "clk_pvtm_core", "xin24m", 0,
|
||||
RV1106_CORECLKGATE_CON(0), 14, GFLAGS),
|
||||
GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", 0,
|
||||
/* clk_core_mcu_rtc is the 24 MHz mtime of the HPMCU, kept up for the
|
||||
* mtime safety tick. Nothing in Linux claims it, so clk_disable_unused()
|
||||
* would gate it after boot; IGNORE_UNUSED keeps it running, like
|
||||
* clk_core_mcu below (rebuild M0, SCH-01). */
|
||||
GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", CLK_IGNORE_UNUSED,
|
||||
RV1106_CORECLKGATE_CON(1), 6, GFLAGS),
|
||||
COMPOSITE(HCLK_CPU, "hclk_cpu", mux_gpll_24m_p, CLK_IS_CRITICAL,
|
||||
RV1106_CORECLKSEL_CON(2), 5, 1, MFLAGS, 0, 5, DFLAGS,
|
||||
RV1106_CORECLKGATE_CON(0), 12, GFLAGS),
|
||||
COMPOSITE(CLK_CORE_MCU, "clk_core_mcu", mux_gpll_24m_p, 0,
|
||||
/* The HPMCU (RISC-V SCR1 coprocessor) runs on clk_core_mcu, but nothing in
|
||||
* Linux claims it, so clk_disable_unused() switches it off at boot and any
|
||||
* firmware loaded into the coprocessor never executes. Mark it
|
||||
* IGNORE_UNUSED so the coprocessor clock stays up (5.10 left it running;
|
||||
* our 6.18 disabled it). A future remoteproc/coproc driver could claim it. */
|
||||
COMPOSITE(CLK_CORE_MCU, "clk_core_mcu", mux_gpll_24m_p, CLK_IGNORE_UNUSED,
|
||||
RV1106_CORECLKSEL_CON(3), 11, 1, MFLAGS, 6, 5, DFLAGS,
|
||||
RV1106_CORECLKGATE_CON(1), 1, GFLAGS),
|
||||
COMPOSITE_NOMUX(0, "pclk_dbg", "armclk", CLK_IS_CRITICAL,
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
From: BlueFlare Warden <noah@wildrosemining.com>
|
||||
Subject: [PATCH] datatype: take the cgroupv2 id from the directory's file handle
|
||||
|
||||
"socket cgroupv2 level N <path>" compares the 64-bit kernfs id of the cgroup.
|
||||
nft built it from st_ino, which equals the id only on 64-bit kernels. On a
|
||||
32-bit kernel (armv7) the id is (generation << 32) | ino and st_ino carries the
|
||||
low half, so every rule built from a path compared against the wrong value and
|
||||
never matched: nothing was counted per service.
|
||||
|
||||
The directory's file handle holds the whole id on both. It is read with the raw
|
||||
name_to_handle_at syscall because uClibc has no wrapper. The listing path (id
|
||||
back to a name) uses the same helper.
|
||||
|
||||
Found on the WardenOS panel kernel (6.18.46, armv7) with nftables 1.1.0.
|
||||
|
||||
diff --git a/src/datatype.c b/src/datatype.c
|
||||
index d398a9c..289f930 100644
|
||||
--- a/src/datatype.c
|
||||
+++ b/src/datatype.c
|
||||
@@ -19,7 +19,10 @@
|
||||
#include <linux/netfilter.h>
|
||||
#include <linux/icmpv6.h>
|
||||
#include <dirent.h>
|
||||
+#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <sys/syscall.h>
|
||||
+#include <unistd.h>
|
||||
|
||||
#include <nftables.h>
|
||||
#include <datatype.h>
|
||||
@@ -1605,12 +1608,47 @@ const struct datatype policy_type = {
|
||||
|
||||
#define SYSFS_CGROUPSV2_PATH "/sys/fs/cgroup"
|
||||
|
||||
+/* The id the kernel compares in "socket cgroupv2" is the 64-bit kernfs id of
|
||||
+ * the cgroup directory. On 64-bit kernels that is st_ino, but on 32-bit kernels
|
||||
+ * it is (generation << 32) | ino and st_ino carries only the low half, so a
|
||||
+ * rule built from st_ino never matches. The file handle of the directory holds
|
||||
+ * the full id on both. The handle is read with the raw syscall: uClibc has no
|
||||
+ * name_to_handle_at() or struct file_handle. Fall back to st_ino where the
|
||||
+ * syscall is missing. */
|
||||
+static bool cgroupv2_path_id(const char *path, uint64_t *id)
|
||||
+{
|
||||
+#ifdef __NR_name_to_handle_at
|
||||
+ struct {
|
||||
+ unsigned int handle_bytes;
|
||||
+ int handle_type;
|
||||
+ unsigned char f_handle[sizeof(uint64_t)];
|
||||
+ } h;
|
||||
+ int mount_id;
|
||||
+
|
||||
+ h.handle_bytes = sizeof(h.f_handle);
|
||||
+ if (syscall(__NR_name_to_handle_at, AT_FDCWD, path, &h, &mount_id, 0) == 0 &&
|
||||
+ h.handle_bytes == sizeof(*id)) {
|
||||
+ memcpy(id, h.f_handle, sizeof(*id));
|
||||
+ return true;
|
||||
+ }
|
||||
+#endif
|
||||
+ {
|
||||
+ struct stat st;
|
||||
+
|
||||
+ if (stat(path, &st) < 0)
|
||||
+ return false;
|
||||
+ *id = st.st_ino;
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static char *cgroupv2_get_path(const char *path, uint64_t id)
|
||||
{
|
||||
char dent_name[PATH_MAX + 1];
|
||||
char *cgroup_path = NULL;
|
||||
struct dirent *dent;
|
||||
struct stat st;
|
||||
+ uint64_t dent_id;
|
||||
DIR *d;
|
||||
|
||||
d = opendir(path);
|
||||
@@ -1626,7 +1664,7 @@ static char *cgroupv2_get_path(const char *path, uint64_t id)
|
||||
path, dent->d_name);
|
||||
dent_name[sizeof(dent_name) - 1] = '\0';
|
||||
|
||||
- if (dent->d_ino == id) {
|
||||
+ if (cgroupv2_path_id(dent_name, &dent_id) && dent_id == id) {
|
||||
cgroup_path = xstrdup(dent_name);
|
||||
break;
|
||||
}
|
||||
@@ -1674,7 +1712,9 @@ static struct error_record *cgroupv2_type_parse(struct parse_ctx *ctx,
|
||||
return error(&sym->location, "cgroupv2 path fails: %s",
|
||||
strerror(errno));
|
||||
|
||||
- ino = st.st_ino;
|
||||
+ if (!cgroupv2_path_id(cgroupv2_path, &ino))
|
||||
+ return error(&sym->location, "cgroupv2 path fails: %s",
|
||||
+ strerror(errno));
|
||||
*res = constant_expr_alloc(&sym->location, &cgroupv2_type,
|
||||
BYTEORDER_HOST_ENDIAN,
|
||||
sizeof(ino) * BITS_PER_BYTE, &ino);
|
||||
@@ -33,7 +33,7 @@ new file mode 100644
|
||||
index 000000000..b44eeeadd
|
||||
--- /dev/null
|
||||
+++ b/drivers/clk/rockchip/clk-rv1106.c
|
||||
@@ -0,0 +1,1299 @@
|
||||
@@ -0,0 +1,1303 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0
|
||||
+/*
|
||||
+ * Copyright (c) 2022 Rockchip Electronics Co. Ltd.
|
||||
@@ -373,7 +373,11 @@ index 000000000..b44eeeadd
|
||||
+ /* PD_CORE */
|
||||
+ GATE(CLK_PVTM_CORE, "clk_pvtm_core", "xin24m", 0,
|
||||
+ RV1106_CORECLKGATE_CON(0), 14, GFLAGS),
|
||||
+ GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", 0,
|
||||
+ /* clk_core_mcu_rtc is the 24 MHz mtime of the HPMCU, kept up for the
|
||||
+ * mtime safety tick. Nothing in Linux claims it, so clk_disable_unused()
|
||||
+ * would gate it after boot; IGNORE_UNUSED keeps it running, like
|
||||
+ * clk_core_mcu below (rebuild M0, SCH-01). */
|
||||
+ GATE(CLK_CORE_MCU_RTC, "clk_core_mcu_rtc", "xin24m", CLK_IGNORE_UNUSED,
|
||||
+ RV1106_CORECLKGATE_CON(1), 6, GFLAGS),
|
||||
+ COMPOSITE(HCLK_CPU, "hclk_cpu", mux_gpll_24m_p, CLK_IS_CRITICAL,
|
||||
+ RV1106_CORECLKSEL_CON(2), 5, 1, MFLAGS, 0, 5, DFLAGS,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
Remove the DRM_MSM_VALIDATE_XML Kconfig symbol (rebuild M0, bfe-core1106-sdk#19).
|
||||
|
||||
Its dependency $(success,$(PYTHON3) -c "import lxml") makes the expanded .config differ by host: with
|
||||
python3-lxml importable the file gains '# CONFIG_DRM_MSM_VALIDATE_XML is not set', without it the line is
|
||||
absent, so KCONFIG_SHA256 was not reproducible across hosts. The symbol only validates Qualcomm GPU register
|
||||
XML for DRM MSM developers; the panel has no Qualcomm GPU. No binary changes.
|
||||
|
||||
diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
|
||||
--- a/drivers/gpu/drm/msm/Kconfig
|
||||
+++ b/drivers/gpu/drm/msm/Kconfig
|
||||
@@ -50,14 +50,6 @@
|
||||
Only use this if you are a driver developer. This should *not*
|
||||
be enabled for production kernels. If unsure, say N.
|
||||
|
||||
-config DRM_MSM_VALIDATE_XML
|
||||
- bool "Validate XML register files against schema"
|
||||
- depends on DRM_MSM && EXPERT
|
||||
- depends on $(success,$(PYTHON3) -c "import lxml")
|
||||
- help
|
||||
- Validate XML files with register definitions against rules-fd schema.
|
||||
- This option is mostly targeting DRM MSM developers. If unsure, say N.
|
||||
-
|
||||
config DRM_MSM_KMS
|
||||
def_bool n
|
||||
depends on DRM_MSM
|
||||
@@ -28,6 +28,7 @@ with `../build/warden_defconfig` -> `zImage` + `rv1106-warden.dtb`).
|
||||
| `60-wifi-aic8800.patch` | out-of-tree AIC8800 wifi/BT (the 88.5K-line vendor blob) |
|
||||
| `70-audio-codec.patch` | `rv1106_codec` + I2S wiring |
|
||||
| `80-misc-thermal-rtc-adc.patch` | tsadc, rtc-rockchip, saradc, trng, otp, gmac, goodix touch |
|
||||
| `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) |
|
||||
|
||||
## License
|
||||
|
||||
|
||||
@@ -73,6 +73,11 @@ daemons a bench panel already runs: flare-edge `tools/rig-pull-daemons.sh
|
||||
chardev without `--rs485`), so `warden-modbus` polls a port with nothing on
|
||||
it, as on a panel with an empty header, and never the control channel.
|
||||
|
||||
A `mosquitto` in the payload starts the panel's device bus first (socket
|
||||
`/run/warden/bus/bus.sock`, one credential file per bus user under
|
||||
`/run/warden/bus/cred/`), as S10bus does before every bus client on a panel;
|
||||
see `payload/README.md`. The rig broker takes any user and loads no plugin.
|
||||
|
||||
The VT cursor is kept off (`vt.global_cursor_default=0`): fbcon shares the
|
||||
virtio-gpu framebuffer with warden-ui and its blinking cursor would otherwise
|
||||
show up in screendumps at random (issue #18).
|
||||
@@ -106,6 +111,8 @@ All take the virt-fragment `<zImage>`; `FLARE_EDGE=<checkout>` where noted.
|
||||
| `real-image-boot.sh` | matched `rootfs.img` + `oem.img` | an ACTUAL flare-edge build (placed by `mkimage.sh --rootfs-image/--oem-image`) boots its own init chain to getty; binaries predating known fixes reproduce their bugs faithfully, a time machine for field issues |
|
||||
| `test-ui-drive-rs485.sh` | - | offline, no VM: a fake `run.sh` and (for one case) a fake `socat` stand in so `ui-drive.sh --rs485-devices`'s startup fails closed instead of printing a false "== rs485 simulator: ..." over a bus nothing is serving, for each of a qemu rs.sock that never appears, a socat that never links rs.pty, and an mbsim.py that dies before opening rs.ctl; also proves `cleanup()` escalates to SIGKILL for a sim process that ignores SIGTERM |
|
||||
| `run-sh-args-test.sh` | - | offline, no VM: a fake `qemu-system-arm` captures run.sh's own argv and pins the ctl/rs485 pci-serial ordering contract rootfs/sbin/init's ttyS0-vs-ttyS1 alias depends on -- the ctl device always enumerates before rs485, warden.ctl only lands on the cmdline when --ctl is given, and an rs485 pci-serial device (real or null-backed) is always present so the port count never shifts |
|
||||
| `ctl-bridge-test.sh` | - | offline, no VM: runs the control bridge (`warden_ctl_bridge` in rootfs/etc/warden-lib.sh) against a fake warden-ui that answers some commands late. A reply slower than the old 5 s bound still arrives (the bound is now 30 s, `WARDEN_CTL_WAIT_S`), a timeout answers `bridge: no reply from warden-ui ...` (qmp.py raises it as a rig fault), and a timed-out command's late reply is drained instead of being read as the next command's answer (flare-edge #1448) |
|
||||
| `init-rig-bus-test.sh` | - | offline, no VM: `warden_rig_bus` in rootfs/etc/warden-lib.sh against stub brokers. No broker in the payload creates nothing; a broker that listens gets the panel's layout (the `bus.sock` link, a 0400 64-hex credential per bus user, a config without password file, ACL or plugin); a broker that exits or never listens is reported within the bound; init starts the bus before the payload daemons. `WARDEN_TEST_MOSQUITTO_DIR` adds a real mosquitto carrying one message between two users logged in by credential file (flare-edge #1754) |
|
||||
| watchdog (`run.sh --watchdog`) | - | arm `/dev/watchdog`, don't pet: the VM resets ~30 s later (verified) |
|
||||
|
||||
Scenario fine print:
|
||||
|
||||
+10
-1
@@ -33,11 +33,20 @@ qemu_get_busybox() {
|
||||
qemu_log "cached busybox failed verification; fetching a clean copy"
|
||||
fi
|
||||
|
||||
# Every attempt is bounded: a server that answers and then stalls would
|
||||
# otherwise hold the job until its own timeout, with no retry (#1588). Below
|
||||
# 1 KiB/s for the stall window, or past the total cap, curl gives up and the
|
||||
# loop moves on. Defaults cap the worst case near 6 minutes; the tests
|
||||
# shorten them through the environment.
|
||||
local stall="${BB_FETCH_STALL_SECS:-20}" max="${BB_FETCH_MAX_SECS:-60}"
|
||||
local delay="${BB_FETCH_RETRY_DELAY:-5}"
|
||||
local attempt tmp="${BB}.download.$$"
|
||||
rm -f "$tmp"
|
||||
for attempt in 1 2 3; do
|
||||
qemu_log "downloading $BB_URL (attempt $attempt/3)"
|
||||
if curl --retry 3 --retry-delay 5 --retry-connrefused -fSL "$BB_URL" -o "$tmp"; then
|
||||
if curl --retry 1 --retry-delay "$delay" --retry-connrefused \
|
||||
--connect-timeout "$stall" --speed-limit 1024 --speed-time "$stall" \
|
||||
--max-time "$max" -fSL "$BB_URL" -o "$tmp"; then
|
||||
got="$(sha256sum "$tmp" | awk '{print $1}')"
|
||||
if [ "$want" = "$got" ]; then
|
||||
mv -f "$tmp" "$BB"
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
# Env:
|
||||
# BUSYBOX path to a local busybox binary (skips the download; still verified)
|
||||
# OUT output dir (default: qemu/out); initramfs at $OUT/initramfs.cpio.gz
|
||||
# EXTRA_DIR a directory merged into the initramfs root (a test's scripts and
|
||||
# static binaries; init runs one on warden.run=<path>)
|
||||
set -euo pipefail
|
||||
|
||||
QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
@@ -20,6 +22,12 @@ qemu_get_busybox
|
||||
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/warden-qemu-initramfs.XXXXXX")"
|
||||
trap 'rm -rf "$SCRATCH"' EXIT
|
||||
qemu_stage_rootfs "$SCRATCH/root"
|
||||
# The kernel symbol list, so init can check it against /proc/config.gz.
|
||||
install -D -m 0644 "$QEMU_DIR/../build/required-symbols.txt" "$SCRATCH/root/etc/required-symbols.txt"
|
||||
if [ -n "${EXTRA_DIR:-}" ]; then
|
||||
[ -d "$EXTRA_DIR" ] || { echo "FATAL: EXTRA_DIR is not a directory: $EXTRA_DIR" >&2; exit 1; }
|
||||
cp -a "$EXTRA_DIR/." "$SCRATCH/root/"
|
||||
fi
|
||||
|
||||
# Pack (newc cpio, gzip). No device nodes required: /init mounts devtmpfs and
|
||||
# reopens the console itself, so the archive builds unprivileged.
|
||||
|
||||
@@ -26,6 +26,13 @@ musl binary, so flare-edge `tools/rig-pull-daemons.sh --host <panel>` copies
|
||||
release and each md5 in `PULLED.txt`), minus `warden-ui`, which the rig
|
||||
needs as the fbdev+evdev build.
|
||||
|
||||
A `mosquitto` here (the static armhf broker of flare-edge
|
||||
`tools/mosquitto-build.sh armhf`) gives the guest the panel's device bus:
|
||||
stage-2 init starts it on `/run/warden/bus/bus.sock` before any daemon and
|
||||
writes a credential file per bus user to `/run/warden/bus/cred/<user>`
|
||||
(`warden_rig_bus` in `qemu/rootfs/etc/warden-lib.sh`; the broker log is
|
||||
`/tmp/mosquitto.log`). Without it the guest has no bus, as before.
|
||||
|
||||
Stage-2 init starts every `warden-*` daemon it finds here, in the panel's
|
||||
own S-number order (ai, automation, modbus, mikrotik, asic, starlink,
|
||||
stratum, flared), then `warden-ui` (the UI also needs `--display
|
||||
|
||||
@@ -62,3 +62,180 @@ warden_idle_forever() {
|
||||
wait $!
|
||||
done
|
||||
}
|
||||
|
||||
# The control bridge's command loop (/sbin/init runs it on the ctl serial
|
||||
# port): one command per line on stdin, the reply then the sentinel line
|
||||
# <<END>> on stdout. qmp.py's Ctl matches the sentinel byte for byte.
|
||||
#
|
||||
# `@cat PATH` is answered here and never forwarded: PATH's contents (or one
|
||||
# "bridge: no such file: PATH" line), which is how the json flow channel
|
||||
# reads webstatus.c's snapshot from outside the VM. `@procs` is answered
|
||||
# here too: every /proc/<pid>/stat line, for qmp.py's stall probe
|
||||
# (flare-edge #1528). Everything else goes to
|
||||
# warden-ui's FIFO, and the bridge waits for the reply file the UI renames
|
||||
# into place whole. The previous reply is removed BEFORE sending: a fixed
|
||||
# settle handed back the previous command's reply (flare-edge #152).
|
||||
#
|
||||
# The wait is bounded by WARDEN_CTL_WAIT_S (default 30 s of polling). It was
|
||||
# 5 s, and a slow QEMU host (lenovo-x3650, two TCG guests) let a page build
|
||||
# outrun it: the bridge answered an empty reply, and the UI's late reply
|
||||
# then landed after the NEXT command's remove and was read as that
|
||||
# command's answer (flare-edge #1448). Now a timeout answers one
|
||||
# "bridge: no reply from warden-ui ..." line (qmp.py treats it as a rig
|
||||
# fault), and the next command first waits, on the same bound, for the late
|
||||
# reply and discards it. A reply slower than 5 s is logged on stderr (the
|
||||
# console) with its time, for the host-speed baselines.
|
||||
#
|
||||
# WARDEN_CTL_FIFO and WARDEN_CTL_REPLY exist for the host test only.
|
||||
warden_ctl_bridge() {
|
||||
_wcb_fifo="${WARDEN_CTL_FIFO:-/tmp/warden-ui.ctl}"
|
||||
_wcb_reply="${WARDEN_CTL_REPLY:-/tmp/warden-ui.dbg}"
|
||||
_wcb_limit=$(( ${WARDEN_CTL_WAIT_S:-30} * 20 ))
|
||||
_wcb_stale=0
|
||||
while IFS= read -r cmd; do
|
||||
[ -n "$cmd" ] || continue
|
||||
case "$cmd" in
|
||||
"@cat "*)
|
||||
path="${cmd#@cat }"
|
||||
if [ -f "$path" ]; then
|
||||
cat "$path"
|
||||
# The status json has no trailing newline; without this
|
||||
# the sentinel would share its line and the line-based
|
||||
# reader would never see it.
|
||||
echo
|
||||
else
|
||||
echo "bridge: no such file: $path"
|
||||
fi
|
||||
;;
|
||||
"@procs")
|
||||
# Every process's stat line, for the driver's stall probe
|
||||
# (qmp.py stall_report, flare-edge #1528); needs no UI.
|
||||
cat /proc/[0-9]*/stat 2>/dev/null
|
||||
;;
|
||||
*)
|
||||
if [ -p "$_wcb_fifo" ]; then
|
||||
if [ "$_wcb_stale" = 1 ]; then
|
||||
_wcb_wait_reply
|
||||
_wcb_stale=0
|
||||
fi
|
||||
rm -f "$_wcb_reply"
|
||||
printf '%s\n' "$cmd" > "$_wcb_fifo"
|
||||
if _wcb_wait_reply; then
|
||||
cat "$_wcb_reply" 2>/dev/null
|
||||
else
|
||||
echo "bridge: no reply from warden-ui within $((_wcb_limit / 20)) s: $cmd"
|
||||
_wcb_stale=1
|
||||
fi
|
||||
if [ "$_wcb_n" -gt 100 ]; then
|
||||
echo "ctl bridge: slow reply, $((_wcb_n / 20)) s of polling: $cmd" >&2
|
||||
fi
|
||||
else
|
||||
echo "bridge: warden-ui control FIFO not present"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "<<END>>"
|
||||
done
|
||||
}
|
||||
|
||||
# Polls for a non-empty reply file every 0.05 s, up to the bridge's bound;
|
||||
# leaves the poll count in _wcb_n.
|
||||
_wcb_wait_reply() {
|
||||
_wcb_n=0
|
||||
while [ ! -s "$_wcb_reply" ]; do
|
||||
[ "$_wcb_n" -ge "$_wcb_limit" ] && return 1
|
||||
sleep 0.05
|
||||
_wcb_n=$((_wcb_n + 1))
|
||||
done
|
||||
}
|
||||
|
||||
# The rig's device bus (flare-edge #1754, the #1050 QEMU half). A panel runs
|
||||
# one mosquitto on /run/warden/bus/bus.sock (flare-edge S10bus) and every
|
||||
# daemon, the UI included, talks over it. The rig starts the same broker
|
||||
# when the payload carries one (/usr/bin/mosquitto, the static armhf build of
|
||||
# flare-edge tools/mosquitto-build.sh); a payload without it boots exactly as
|
||||
# before, with no bus.
|
||||
#
|
||||
# Same paths as the panel, so the production clients need no rig switch:
|
||||
# the socket at <bus>/sock/bus.sock with the <bus>/bus.sock link clients
|
||||
# dial, and one credential file per bus user at <bus>/cred/<user>, which a
|
||||
# client reads at every CONNECT. What the rig leaves out, on purpose: the
|
||||
# password file and ACL (the broker takes any user; the rig is a test
|
||||
# instrument and every process in it runs as root anyway) and the retain gate
|
||||
# plugin (a static broker loads no plugins). The credential files hold a
|
||||
# fresh random secret all the same, so a client finds what it expects.
|
||||
#
|
||||
# WARDEN_RIG_BUS_USERS lists the bus users that get a credential file: the
|
||||
# panel's /etc/warden/bus/users and bundled-users (flare-edge busgen output).
|
||||
# WARDEN_RIG_BROKER, WARDEN_BUS_RUN, WARDEN_RIG_BUS_LOG and
|
||||
# WARDEN_RIG_BUS_WAIT_S exist for the host test only.
|
||||
warden_rig_bus() {
|
||||
_wrb_broker="${WARDEN_RIG_BROKER:-/usr/bin/mosquitto}"
|
||||
[ -x "$_wrb_broker" ] || return 0
|
||||
_wrb_dir="${WARDEN_BUS_RUN:-/run/warden/bus}"
|
||||
_wrb_log="${WARDEN_RIG_BUS_LOG:-/tmp/mosquitto.log}"
|
||||
_wrb_users="${WARDEN_RIG_BUS_USERS:-flared ui io modbus appd telemetry automation.main}"
|
||||
if ! mkdir -p "$_wrb_dir/cred" "$_wrb_dir/sock"; then
|
||||
echo "init: rig bus FAILED: cannot create $_wrb_dir"
|
||||
return 1
|
||||
fi
|
||||
chmod 0751 "$_wrb_dir"
|
||||
chmod 0710 "$_wrb_dir/cred"
|
||||
# The panel's broker settings (flare-edge
|
||||
# overlay-flare-warden-ui/etc/warden/bus/mosquitto.conf) minus the
|
||||
# password file, ACL and plugin lines (see above). `user root` keeps the
|
||||
# broker from dropping to an account the rig rootfs does not have.
|
||||
cat > "$_wrb_dir/mosquitto.conf" <<WRB_CONF
|
||||
# QEMU rig broker, written by warden_rig_bus (qemu/rootfs/etc/warden-lib.sh).
|
||||
user root
|
||||
listener 0 $_wrb_dir/sock/bus.sock
|
||||
allow_anonymous true
|
||||
pid_file $_wrb_dir/sock/mosquitto.pid
|
||||
use_username_as_clientid true
|
||||
persistence false
|
||||
message_size_limit 131072
|
||||
max_packet_size 135168
|
||||
max_connections 128
|
||||
max_queued_messages 1000
|
||||
max_queued_bytes 2097152
|
||||
max_inflight_messages 20
|
||||
max_qos 1
|
||||
max_keepalive 60
|
||||
sys_interval 0
|
||||
connection_messages false
|
||||
log_dest stderr
|
||||
log_type error
|
||||
log_type warning
|
||||
WRB_CONF
|
||||
for _wrb_u in $_wrb_users; do
|
||||
case "$_wrb_u" in
|
||||
''|*/*|.*) echo "init: rig bus: bad user name '$_wrb_u' skipped"; continue ;;
|
||||
esac
|
||||
rm -f "$_wrb_dir/cred/$_wrb_u"
|
||||
(umask 077; od -An -tx1 -N32 /dev/urandom | tr -d ' \n' > "$_wrb_dir/cred/$_wrb_u")
|
||||
chmod 0400 "$_wrb_dir/cred/$_wrb_u"
|
||||
done
|
||||
ln -sfn sock/bus.sock "$_wrb_dir/bus.sock"
|
||||
ln -sfn sock/mosquitto.pid "$_wrb_dir/mosquitto.pid"
|
||||
"$_wrb_broker" -c "$_wrb_dir/mosquitto.conf" > "$_wrb_log" 2>&1 &
|
||||
_wrb_pid=$!
|
||||
# Clients retry a missing socket, but a daemon started before the broker
|
||||
# listens logs a refused first dial: wait for the socket (0.1 s polls,
|
||||
# bounded) so the payload daemons find it on their first try.
|
||||
_wrb_n=0
|
||||
_wrb_limit=$(( ${WARDEN_RIG_BUS_WAIT_S:-10} * 10 ))
|
||||
while [ ! -S "$_wrb_dir/sock/bus.sock" ]; do
|
||||
if ! kill -0 "$_wrb_pid" 2>/dev/null; then
|
||||
echo "init: rig bus FAILED: the broker exited; log tail:"
|
||||
tail -n 5 "$_wrb_log" 2>/dev/null
|
||||
return 1
|
||||
fi
|
||||
if [ "$_wrb_n" -ge "$_wrb_limit" ]; then
|
||||
echo "init: rig bus FAILED: no socket after $((_wrb_limit / 10)) s"
|
||||
return 1
|
||||
fi
|
||||
sleep 0.1
|
||||
_wrb_n=$((_wrb_n + 1))
|
||||
done
|
||||
echo "init: rig bus up on $_wrb_dir/bus.sock (broker pid $_wrb_pid)"
|
||||
}
|
||||
|
||||
@@ -18,6 +18,53 @@ mount -t sysfs sysfs /sys
|
||||
|
||||
echo "WARDEN-QEMU-BOOT-OK"
|
||||
|
||||
# Kernel contract (rebuild M0): every symbol of build/required-symbols.txt (staged
|
||||
# as /etc/required-symbols.txt by mkinitramfs.sh) is in the running kernel's
|
||||
# /proc/config.gz, the cgroup v2 controllers the platform limits with are there,
|
||||
# and pressure stall information is on. boot-smoke.sh greps these markers.
|
||||
if [ -r /etc/required-symbols.txt ]; then
|
||||
if [ -e /proc/config.gz ] && zcat /proc/config.gz > /config.run 2>/dev/null; then
|
||||
miss=""; nsym=0
|
||||
while read -r line; do
|
||||
case "$line" in
|
||||
CONFIG_*=*)
|
||||
nsym=$((nsym + 1))
|
||||
grep -qxF "$line" /config.run || miss="$miss $line" ;;
|
||||
"# CONFIG_"*" is not set")
|
||||
sym="${line#\# }"; sym="${sym% is not set}"; nsym=$((nsym + 1))
|
||||
grep -q "^$sym=" /config.run && miss="$miss ${sym}(set)" ;;
|
||||
esac
|
||||
done < /etc/required-symbols.txt
|
||||
if [ -z "$miss" ]; then echo "WARDEN-QEMU-SYMBOLS-OK $nsym"
|
||||
else echo "WARDEN-QEMU-SYMBOLS-MISSING$miss"; fi
|
||||
else
|
||||
echo "WARDEN-QEMU-SYMBOLS-MISSING /proc/config.gz"
|
||||
fi
|
||||
mkdir -p /sys/fs/cgroup
|
||||
mount -t cgroup2 none /sys/fs/cgroup 2>/dev/null
|
||||
echo "WARDEN-QEMU-CGROUP-CONTROLLERS $(cat /sys/fs/cgroup/cgroup.controllers 2>/dev/null)"
|
||||
psi_missing=""
|
||||
for f in cpu memory io; do [ -r "/proc/pressure/$f" ] || psi_missing="$psi_missing $f"; done
|
||||
if [ -z "$psi_missing" ]; then echo "WARDEN-QEMU-PSI-OK"; else echo "WARDEN-QEMU-PSI-MISSING$psi_missing"; fi
|
||||
fi
|
||||
|
||||
# warden.run=<path>: run a script that mkinitramfs.sh staged from EXTRA_DIR, then
|
||||
# power off. Used by the M0 limit tests (tools/m0/limits-test.sh in flare-edge).
|
||||
read -r CMDLINE < /proc/cmdline
|
||||
for w in $CMDLINE; do
|
||||
case "$w" in warden.run=*) RUN_SCRIPT="${w#warden.run=}" ;; esac
|
||||
done
|
||||
if [ -n "${RUN_SCRIPT:-}" ]; then
|
||||
if [ -x "$RUN_SCRIPT" ]; then
|
||||
echo "WARDEN-QEMU-RUN-BEGIN $RUN_SCRIPT"
|
||||
"$RUN_SCRIPT"
|
||||
echo "WARDEN-QEMU-RUN-END rc=$?"
|
||||
else
|
||||
echo "WARDEN-QEMU-RUN-MISSING $RUN_SCRIPT"
|
||||
fi
|
||||
poweroff -f
|
||||
fi
|
||||
|
||||
# With a virtio disk attached, hand over to the stage-1 rc (by-name symlinks,
|
||||
# slot select, switch_root). It only returns on failure; then fall through to
|
||||
# the diskless shell/poweroff behavior below.
|
||||
|
||||
+8
-48
@@ -108,6 +108,11 @@ export WARDEN_HARD_RESET=0
|
||||
# Production init scripts create this volatile socket directory before their
|
||||
# daemons start. The compact QEMU rootfs must provide the same contract.
|
||||
mkdir -p /run/warden
|
||||
# The device bus, when the payload carries a broker (warden_rig_bus): up
|
||||
# before the daemons, as S10bus is before every bus client on the panel. A
|
||||
# failed start is logged and the boot goes on: the clients keep dialing, and
|
||||
# a flow that needs the bus fails on its own checks.
|
||||
warden_rig_bus || true
|
||||
# OTA apply is opt-in per boot (run.sh --allow-apply): writing rootfs_b is
|
||||
# safe inside disk.img but must never be the default posture.
|
||||
if grep -qw warden.fwapply /proc/cmdline; then
|
||||
@@ -192,54 +197,9 @@ if grep -qw warden.ctl /proc/cmdline && [ -c /dev/ttyS0 ]; then
|
||||
# mode: the host discards echoed input, and a whole line arrives per
|
||||
# read.
|
||||
exec 3<> "$ctl"
|
||||
while IFS= read -r cmd <&3; do
|
||||
[ -n "$cmd" ] || continue
|
||||
case "$cmd" in
|
||||
"@cat "*)
|
||||
# A bridge-local command, never forwarded to warden-ui's
|
||||
# FIFO: `@cat PATH` reads PATH directly off the GUEST's
|
||||
# own filesystem and answers with it, which is how the
|
||||
# json flow channel gets webstatus.c's snapshot out to
|
||||
# the host driving the VM from outside. `-f` so a
|
||||
# directory or device node reports as missing rather than
|
||||
# cat hanging or erroring oddly.
|
||||
path="${cmd#@cat }"
|
||||
if [ -f "$path" ]; then
|
||||
cat "$path" >&3
|
||||
# Force a newline after the file's own bytes: the
|
||||
# status json (webstatus.c) is written with NO
|
||||
# trailing newline, and without this the sentinel
|
||||
# below would land on the SAME line as the content
|
||||
# and the reader (qmp.py Ctl.send, line-based) would
|
||||
# block forever waiting for a line that never comes.
|
||||
echo >&3
|
||||
else
|
||||
echo "bridge: no such file: $path" >&3
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if [ -p /tmp/warden-ui.ctl ]; then
|
||||
# Remove the previous reply BEFORE sending, then wait
|
||||
# for the new one to appear (the UI renames it into
|
||||
# place whole). A fixed settle used to hand back the
|
||||
# previous command's reply whenever a page took longer
|
||||
# than 0.3 s to build (flare-edge #152); this is the
|
||||
# same recipe tools/warden-ctl uses over SSH.
|
||||
rm -f /tmp/warden-ui.dbg
|
||||
printf '%s\n' "$cmd" > /tmp/warden-ui.ctl
|
||||
n=0
|
||||
while [ ! -s /tmp/warden-ui.dbg ] && [ "$n" -lt 100 ]; do
|
||||
sleep 0.05
|
||||
n=$((n + 1))
|
||||
done
|
||||
cat /tmp/warden-ui.dbg 2>/dev/null >&3
|
||||
else
|
||||
echo "bridge: warden-ui control FIFO not present" >&3
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
echo "<<END>>" >&3
|
||||
done
|
||||
# The loop itself is warden_ctl_bridge (/etc/warden-lib.sh), where
|
||||
# the host test reaches it.
|
||||
warden_ctl_bridge <&3 >&3
|
||||
) &
|
||||
fi
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
# --http-port N hostfwd 127.0.0.1:N -> guest :80 (default 8080; 0 disables)
|
||||
# --api-port N hostfwd 127.0.0.1:N -> guest :28443 (default 28443; 0 disables)
|
||||
# --shell interactive shell in the guest instead of daemon hold
|
||||
# --append STR extra kernel command line words (for example
|
||||
# warden.run=/m0/limits-test.sh: init runs that script from
|
||||
# the initramfs and powers off)
|
||||
# --allow-apply let flared ACTUALLY apply OTA firmware (writes rootfs_b
|
||||
# inside disk.img, safe in the VM, never the default)
|
||||
set -euo pipefail
|
||||
@@ -38,6 +41,7 @@ KERNEL="" INITRD="$OUT/initramfs.cpio.gz" DISK="" NO_DISK=0 SLOT="_a"
|
||||
RTC="" RS485="" CTL="" WATCHDOG=0 QMP="" DISPLAY_MODE="off" SHELL_FLAG=0 ALLOW_APPLY=0
|
||||
SSH_PORT=2222 HTTP_PORT=8080 API_PORT=28443
|
||||
EXTRA=()
|
||||
EXTRA_APPEND=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
@@ -56,6 +60,7 @@ while [ $# -gt 0 ]; do
|
||||
--http-port) HTTP_PORT="${2:?}"; shift 2 ;;
|
||||
--api-port) API_PORT="${2:?}"; shift 2 ;;
|
||||
--shell) SHELL_FLAG=1; shift ;;
|
||||
--append) EXTRA_APPEND="${2:?}"; shift 2 ;;
|
||||
--allow-apply) ALLOW_APPLY=1; shift ;;
|
||||
--) shift; EXTRA=("$@"); break ;;
|
||||
*) echo "FATAL: unknown argument '$1' (see header of $0)" >&2; exit 1 ;;
|
||||
@@ -111,6 +116,7 @@ if [ -n "$DISK" ] && [ "$NO_DISK" -eq 0 ]; then
|
||||
-device "virtio-blk-device,drive=vd0" )
|
||||
fi
|
||||
[ "$SHELL_FLAG" -eq 1 ] && APPEND="$APPEND warden.shell"
|
||||
[ -n "$EXTRA_APPEND" ] && APPEND="$APPEND $EXTRA_APPEND"
|
||||
# Tells init the FIRST 8250 is the control bridge. Without this marker init
|
||||
# bridges nothing, so a VM launched with --rs485 alone never has its Modbus
|
||||
# wire mistaken for the debug channel.
|
||||
|
||||
@@ -44,4 +44,20 @@ grep -q "WARDEN-QEMU-BOOT-OK" "$LOG" || {
|
||||
echo "FATAL: boot sentinel WARDEN-QEMU-BOOT-OK not found in console log" >&2
|
||||
exit 1
|
||||
}
|
||||
echo "boot smoke OK"
|
||||
# Kernel contract (rebuild M0): init checked build/required-symbols.txt against the
|
||||
# running kernel's /proc/config.gz, the cgroup v2 controllers and PSI. A missing
|
||||
# marker is as fatal as a MISSING one: the check must have run.
|
||||
grep -q "^WARDEN-QEMU-SYMBOLS-OK " "$LOG" || {
|
||||
echo "FATAL: the required-symbols check did not pass: $(grep -E 'WARDEN-QEMU-SYMBOLS' "$LOG" | head -1)" >&2
|
||||
exit 1
|
||||
}
|
||||
ctl="$(sed -n 's/^WARDEN-QEMU-CGROUP-CONTROLLERS //p' "$LOG" | head -1 | tr -d '\r')"
|
||||
for c in cpu memory pids; do
|
||||
case " $ctl " in *" $c "*) ;; *)
|
||||
echo "FATAL: cgroup v2 controller '$c' missing in the guest (have: '$ctl')" >&2; exit 1 ;; esac
|
||||
done
|
||||
grep -q "^WARDEN-QEMU-PSI-OK" "$LOG" || {
|
||||
echo "FATAL: pressure stall information is not available: $(grep -E 'WARDEN-QEMU-PSI' "$LOG" | head -1)" >&2
|
||||
exit 1
|
||||
}
|
||||
echo "boot smoke OK (symbols, cgroup controllers [$ctl], PSI)"
|
||||
|
||||
@@ -69,4 +69,54 @@ cp "$SCRATCH/good" "$SCRATCH/cached/busybox-armv7l"
|
||||
OUT="$SCRATCH/cached" qemu_get_busybox
|
||||
test "$(cat "$FAKE_CURL_COUNT")" = 0
|
||||
|
||||
# A server that answers and then stalls must not hang the fetch (#1588). This
|
||||
# runs the real curl against a local listener that sends headers and a few
|
||||
# bytes, then goes silent; the short limits keep the test fast.
|
||||
PATH="${PATH//"$FAKE_BIN:"/}"
|
||||
python3 - "$SCRATCH/stall-port" <<'STALL' &
|
||||
import os, socket, sys, threading, time
|
||||
srv = socket.socket()
|
||||
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
srv.bind(("127.0.0.1", 0))
|
||||
srv.listen(16)
|
||||
with open(sys.argv[1] + ".tmp", "w") as f:
|
||||
f.write(str(srv.getsockname()[1]))
|
||||
os.rename(sys.argv[1] + ".tmp", sys.argv[1])
|
||||
held = []
|
||||
def serve(conn):
|
||||
try:
|
||||
conn.recv(4096)
|
||||
conn.sendall(b"HTTP/1.1 200 OK\r\nContent-Length: 1000000\r\n\r\nstall")
|
||||
held.append(conn)
|
||||
time.sleep(600)
|
||||
except OSError:
|
||||
pass
|
||||
while True:
|
||||
c, _ = srv.accept()
|
||||
threading.Thread(target=serve, args=(c,), daemon=True).start()
|
||||
STALL
|
||||
STALL_PID=$!
|
||||
trap 'kill "$STALL_PID" 2>/dev/null || true; rm -rf "$SCRATCH"' EXIT
|
||||
for _ in $(seq 100); do [ -s "$SCRATCH/stall-port" ] && break; sleep 0.1; done
|
||||
test -s "$SCRATCH/stall-port"
|
||||
BB_URL="http://127.0.0.1:$(cat "$SCRATCH/stall-port")/busybox"
|
||||
start=$SECONDS
|
||||
# The bash -c program expands its own positional arguments.
|
||||
# shellcheck disable=SC2016
|
||||
if (OUT="$SCRATCH/stalled" BB_FETCH_STALL_SECS=1 BB_FETCH_MAX_SECS=3 \
|
||||
BB_FETCH_RETRY_DELAY=1 timeout 60 bash -c \
|
||||
'set -euo pipefail; source "$1"; QEMU_DIR="$2"; BB_URL="$3"; qemu_get_busybox' \
|
||||
_ "$TEST_DIR/../lib.sh" "$QEMU_DIR" "$BB_URL") >"$SCRATCH/stall.log" 2>&1; then
|
||||
echo "FAIL: a stalled download was accepted" >&2
|
||||
exit 1
|
||||
fi
|
||||
elapsed=$((SECONDS - start))
|
||||
if ! grep -q 'after 3 verified attempts' "$SCRATCH/stall.log"; then
|
||||
echo "FAIL: a stalled download hung instead of failing (${elapsed}s)" >&2
|
||||
cat "$SCRATCH/stall.log" >&2
|
||||
exit 1
|
||||
fi
|
||||
test "$elapsed" -lt 45
|
||||
test ! -e "$SCRATCH/stalled/busybox-armv7l"
|
||||
|
||||
echo "busybox fetch tests passed"
|
||||
|
||||
Executable
+119
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bash
|
||||
# Host test for the rig's control bridge, warden_ctl_bridge in
|
||||
# qemu/rootfs/etc/warden-lib.sh (flare-edge #1448). A fake warden-ui reads
|
||||
# the FIFO and renames each reply into place, as warden_debug.c does; some
|
||||
# commands answer late. Checks: a reply slower than the old 5 s bound still
|
||||
# arrives, a timeout answers the explicit no-reply line, and the late reply
|
||||
# of a timed-out command is never handed to the next command.
|
||||
set -uo pipefail
|
||||
# Job control: the fake UI leads its own process group, so one kill stops
|
||||
# its pending sleep too.
|
||||
set -m
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
LIB="$HERE/../rootfs/etc/warden-lib.sh"
|
||||
SH="${WARDEN_TEST_SH:-sh}"
|
||||
WORK="$(mktemp -d)" || exit 1
|
||||
UI_PID=
|
||||
stop_ui() {
|
||||
[ -n "$UI_PID" ] || return 0
|
||||
{ kill -KILL -- "-$UI_PID"; wait "$UI_PID"; } 2>/dev/null
|
||||
UI_PID=
|
||||
}
|
||||
cleanup() {
|
||||
stop_ui
|
||||
rm -rf "$WORK"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
FAIL=0
|
||||
CHECKS=0
|
||||
|
||||
check() { # check <label> <command...>
|
||||
CHECKS=$((CHECKS + 1))
|
||||
if "${@:2}"; then
|
||||
echo "[PASS] $1"
|
||||
else
|
||||
echo "[FAIL] $1"
|
||||
FAIL=1
|
||||
fi
|
||||
}
|
||||
|
||||
# The fake UI: "slowN" answers after N tenths of a second, anything else at
|
||||
# once. Replies are "reply:<command>", written to a temp file and renamed.
|
||||
start_ui() {
|
||||
mkfifo "$WORK/ctl"
|
||||
(
|
||||
while :; do
|
||||
IFS= read -r cmd < "$WORK/ctl" || continue
|
||||
case "$cmd" in
|
||||
slow*) sleep "$(awk -v t="${cmd#slow}" 'BEGIN { print t / 10 }')" ;;
|
||||
esac
|
||||
printf 'reply:%s\n' "$cmd" > "$WORK/dbg.tmp"
|
||||
mv "$WORK/dbg.tmp" "$WORK/dbg"
|
||||
done
|
||||
) &
|
||||
UI_PID=$!
|
||||
}
|
||||
|
||||
run_bridge() { # run_bridge <name> <wait s or ""> <lines...>
|
||||
local name="$1" wait="$2"
|
||||
shift 2
|
||||
printf '%s\n' "$@" |
|
||||
env WARDEN_CTL_FIFO="$WORK/ctl" WARDEN_CTL_REPLY="$WORK/dbg" \
|
||||
${wait:+WARDEN_CTL_WAIT_S="$wait"} \
|
||||
"$SH" -c ". '$LIB'; warden_ctl_bridge" > "$WORK/$name.out" 2> "$WORK/$name.err"
|
||||
}
|
||||
|
||||
same() { # same <file> <expected lines...>
|
||||
local file="$1"
|
||||
shift
|
||||
diff <(printf '%s\n' "$@") "$file" > "$WORK/diff" || { cat "$WORK/diff"; return 1; }
|
||||
}
|
||||
|
||||
start_ui
|
||||
|
||||
# A 1 s bound, a 1.5 s reply: the explicit no-reply line, then the next
|
||||
# command gets ITS reply, not the late one (the desync behind #1448).
|
||||
run_bridge timeout 1 fast1 slow15 fast2
|
||||
check "timeout answers no-reply; the late reply is not the next answer" \
|
||||
same "$WORK/timeout.out" reply:fast1 '<<END>>' \
|
||||
'bridge: no reply from warden-ui within 1 s: slow15' '<<END>>' \
|
||||
reply:fast2 '<<END>>'
|
||||
|
||||
# The default bound: a 6 s reply (over the old 5 s) still arrives, and the
|
||||
# console note gives its time.
|
||||
run_bridge slow "" slow60 after
|
||||
check "default bound: a 6 s reply arrives" \
|
||||
same "$WORK/slow.out" reply:slow60 '<<END>>' reply:after '<<END>>'
|
||||
check "slow reply logged on stderr" grep -Eq "^ctl bridge: slow reply, [5-7] s of polling: slow60\$" "$WORK/slow.err"
|
||||
check "fast reply not logged" bash -c "! grep -q after '$WORK/slow.err'"
|
||||
|
||||
# @cat is answered by the bridge itself, with a newline after the file.
|
||||
printf '{"a":1}' > "$WORK/status.json"
|
||||
run_bridge cat 1 "@cat $WORK/status.json" "@cat $WORK/missing"
|
||||
check "@cat answers the file and a missing-file line" \
|
||||
same "$WORK/cat.out" '{"a":1}' '<<END>>' "bridge: no such file: $WORK/missing" '<<END>>'
|
||||
|
||||
# No FIFO: one line, no wait.
|
||||
stop_ui
|
||||
rm -f "$WORK/ctl"
|
||||
run_bridge nofifo 1 page
|
||||
check "missing FIFO answers at once" \
|
||||
same "$WORK/nofifo.out" 'bridge: warden-ui control FIFO not present' '<<END>>'
|
||||
|
||||
# @procs: the process table for the stall probe (flare-edge #1528), answered
|
||||
# by the bridge itself, so it works with no UI at all.
|
||||
procs_ok() {
|
||||
grep -Eq '^[0-9]+ \(.*\) [A-Z] ' "$WORK/procs.out" &&
|
||||
[ "$(tail -n 1 "$WORK/procs.out")" = '<<END>>' ] &&
|
||||
! grep -q 'FIFO not present' "$WORK/procs.out"
|
||||
}
|
||||
run_bridge procs 1 @procs
|
||||
check "@procs lists process stat lines without the UI" procs_ok
|
||||
|
||||
if [ "$FAIL" = 0 ]; then
|
||||
echo "ctl-bridge tests: OK ($CHECKS checks)"
|
||||
else
|
||||
echo "ctl-bridge tests: FAILED"
|
||||
exit 1
|
||||
fi
|
||||
Executable
+176
@@ -0,0 +1,176 @@
|
||||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2317 # the checks and the cleanup run through check() and trap
|
||||
# Host test for the rig's device bus, warden_rig_bus in
|
||||
# qemu/rootfs/etc/warden-lib.sh (flare-edge #1754, #1050). Checks:
|
||||
# - a payload without a broker boots as before: nothing created, status 0
|
||||
# - with a broker: the panel's layout (sock/bus.sock and the bus.sock link,
|
||||
# one 0400 credential file of 64 hex digits per bus user, each its own),
|
||||
# a config with the listener and no password file, ACL or plugin
|
||||
# - a broker that exits, or never listens, is reported and returns 1
|
||||
# within the wait bound
|
||||
# - a user name that is not a plain file name gets no file
|
||||
# - /sbin/init starts the bus before the payload daemons
|
||||
# A stub broker (python3, binds the configured listener) stands in for
|
||||
# mosquitto. With WARDEN_TEST_MOSQUITTO_DIR set to a directory holding
|
||||
# mosquitto, mosquitto_pub and mosquitto_sub (flare-edge
|
||||
# tools/build-host-mosquitto.sh), the real broker also carries one message
|
||||
# between two users that log in with their credential files.
|
||||
set -uo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
LIB="$HERE/../rootfs/etc/warden-lib.sh"
|
||||
INIT="$HERE/../rootfs/sbin/init"
|
||||
SH="${WARDEN_TEST_SH:-sh}"
|
||||
WORK="$(mktemp -d)" || exit 1
|
||||
cleanup() {
|
||||
# The brokers outlive the shell that started them, as on the rig; each
|
||||
# has this test's folder in its argv (the stub that never listens writes
|
||||
# its pid instead).
|
||||
pkill -f -- "$WORK/" 2>/dev/null
|
||||
[ -f "$STUB/mute.pid" ] && kill "$(cat "$STUB/mute.pid")" 2>/dev/null
|
||||
rm -rf "$WORK"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
STUB="$WORK/stubs"
|
||||
mkdir -p "$STUB"
|
||||
FAIL=0
|
||||
|
||||
check() { # check <label> <command...>
|
||||
if "${@:2}"; then
|
||||
echo "[PASS] $1"
|
||||
else
|
||||
echo "[FAIL] $1"
|
||||
FAIL=1
|
||||
fi
|
||||
}
|
||||
|
||||
# Stub brokers: argv is "-c <conf>", as the lib calls mosquitto.
|
||||
# good: binds the listener path from the config and stays.
|
||||
# exits: dies at once. mute: stays and never listens.
|
||||
cat > "$STUB/good" <<'PY'
|
||||
#!/usr/bin/env python3
|
||||
import socket, sys, time
|
||||
conf = sys.argv[sys.argv.index("-c") + 1]
|
||||
lines = open(conf).read().splitlines()
|
||||
path = [l.split()[2] for l in lines if l.startswith("listener ")][0]
|
||||
time.sleep(0.3)
|
||||
s = socket.socket(socket.AF_UNIX)
|
||||
s.bind(path)
|
||||
s.listen(1)
|
||||
print("stub broker listening", flush=True)
|
||||
time.sleep(600)
|
||||
PY
|
||||
printf '#!/bin/sh\necho "Error: stub broker refused" >&2\nexit 3\n' > "$STUB/exits"
|
||||
cat > "$STUB/mute" <<'EOF'
|
||||
#!/bin/sh
|
||||
echo $$ > "${0%/*}/mute.pid"
|
||||
exec sleep 600
|
||||
EOF
|
||||
chmod +x "$STUB/good" "$STUB/exits" "$STUB/mute"
|
||||
|
||||
run_bus() { # run_bus <case> <broker> [VAR=value...]: output in <case>/out, status in <case>/rc
|
||||
local name="$1" broker="$2"
|
||||
shift 2
|
||||
mkdir -p "$WORK/$name"
|
||||
# $SH unquoted: WARDEN_TEST_SH may be "busybox sh". The lib is sourced
|
||||
# inside, so the quoted script is meant literally.
|
||||
# shellcheck disable=SC2086,SC2016
|
||||
env WARDEN_RIG_BROKER="$broker" WARDEN_BUS_RUN="$WORK/$name/bus" \
|
||||
WARDEN_RIG_BUS_LOG="$WORK/$name/broker.log" "$@" \
|
||||
$SH -c '. "$1"; warden_rig_bus' sh "$LIB" > "$WORK/$name/out" 2>&1
|
||||
echo $? > "$WORK/$name/rc"
|
||||
}
|
||||
rc_is() { [ "$(cat "$WORK/$1/rc")" = "$2" ]; }
|
||||
out_has() { grep -qF -- "$2" "$WORK/$1/out"; }
|
||||
|
||||
# 1. No broker in the payload.
|
||||
run_bus none "$WORK/no-such-broker"
|
||||
check "no broker: status 0" rc_is none 0
|
||||
check "no broker: nothing created" test ! -e "$WORK/none/bus"
|
||||
check "no broker: silent" test ! -s "$WORK/none/out"
|
||||
|
||||
# 2. A broker that listens.
|
||||
run_bus good "$STUB/good" WARDEN_RIG_BUS_USERS="flared ui modbus ../evil .hidden automation.main"
|
||||
B="$WORK/good/bus"
|
||||
check "broker up: status 0" rc_is good 0
|
||||
check "broker up: reported" out_has good "init: rig bus up on $B/bus.sock"
|
||||
check "broker up: socket listens" test -S "$B/sock/bus.sock"
|
||||
check "broker up: bus.sock link resolves to the socket" test "$(readlink "$B/bus.sock")" = sock/bus.sock -a -S "$B/bus.sock"
|
||||
creds_ok() {
|
||||
local u f seen=""
|
||||
for u in flared ui modbus automation.main; do
|
||||
f="$B/cred/$u"
|
||||
[ -f "$f" ] || { echo "missing $f"; return 1; }
|
||||
[ "$(stat -c %a "$f")" = 400 ] || { echo "$f mode $(stat -c %a "$f")"; return 1; }
|
||||
grep -qxE '[0-9a-f]{64}' "$f" || { echo "$f is not 64 hex digits"; return 1; }
|
||||
case " $seen " in *" $(cat "$f") "*) echo "$f repeats a secret"; return 1 ;; esac
|
||||
seen="$seen $(cat "$f")"
|
||||
done
|
||||
}
|
||||
check "broker up: one 0400 64-hex credential per user, all different" creds_ok
|
||||
check "broker up: a name with a slash gets no file" test ! -e "$B/evil"
|
||||
check "broker up: a dot name gets no file" test ! -e "$B/cred/.hidden"
|
||||
check "broker up: bad names reported" out_has good "bad user name '../evil' skipped"
|
||||
check "broker up: cred/ is 0710" test "$(stat -c %a "$B/cred")" = 710
|
||||
conf_ok() {
|
||||
local c="$B/mosquitto.conf"
|
||||
grep -qx "listener 0 $B/sock/bus.sock" "$c" &&
|
||||
grep -qx 'allow_anonymous true' "$c" &&
|
||||
grep -qx 'use_username_as_clientid true' "$c" &&
|
||||
! grep -qE '^(password_file|acl_file|plugin)' "$c"
|
||||
}
|
||||
check "broker up: config has the listener and no password file, ACL or plugin" conf_ok
|
||||
|
||||
# 3. A broker that exits at once.
|
||||
run_bus exits "$STUB/exits" WARDEN_RIG_BUS_WAIT_S=5
|
||||
check "broker exits: status 1" rc_is exits 1
|
||||
check "broker exits: reported with its log" out_has exits "init: rig bus FAILED: the broker exited"
|
||||
check "broker exits: log tail shown" out_has exits "stub broker refused"
|
||||
|
||||
# 4. A broker that never listens.
|
||||
start=$(date +%s)
|
||||
run_bus mute "$STUB/mute" WARDEN_RIG_BUS_WAIT_S=1
|
||||
took=$(( $(date +%s) - start ))
|
||||
[ -f "$STUB/mute.pid" ] && kill "$(cat "$STUB/mute.pid")" 2>/dev/null
|
||||
check "silent broker: status 1" rc_is mute 1
|
||||
check "silent broker: reported" out_has mute "init: rig bus FAILED: no socket after 1 s"
|
||||
check "silent broker: gave up within the bound (${took} s)" test "$took" -le 4
|
||||
|
||||
# 5. /sbin/init: the bus before the payload daemon loop.
|
||||
order_ok() {
|
||||
local bus loop
|
||||
bus=$(grep -n '^warden_rig_bus' "$INIT" | head -1 | cut -d: -f1)
|
||||
loop=$(grep -n '^for d in /usr/bin/warden-' "$INIT" | head -1 | cut -d: -f1)
|
||||
[ -n "$bus" ] && [ -n "$loop" ] && [ "$bus" -lt "$loop" ]
|
||||
}
|
||||
check "init: the rig bus starts before the payload daemons" order_ok
|
||||
|
||||
# 6. The real broker, when one is given.
|
||||
MQ="${WARDEN_TEST_MOSQUITTO_DIR:-}"
|
||||
if [ -n "$MQ" ] && [ -x "$MQ/mosquitto" ] && [ -x "$MQ/mosquitto_sub" ] && [ -x "$MQ/mosquitto_pub" ]; then
|
||||
run_bus real "$MQ/mosquitto" WARDEN_RIG_BUS_USERS="modbus ui"
|
||||
R="$WORK/real/bus"
|
||||
check "real broker: up" rc_is real 0
|
||||
real_message() {
|
||||
local got
|
||||
"$MQ/mosquitto_sub" --unix "$R/bus.sock" -u ui -P "$(cat "$R/cred/ui")" \
|
||||
-t 'modbus/state/test' -C 1 -W 10 > "$WORK/real/sub.out" 2>&1 &
|
||||
local sub=$!
|
||||
sleep 0.5
|
||||
"$MQ/mosquitto_pub" --unix "$R/bus.sock" -u modbus -P "$(cat "$R/cred/modbus")" \
|
||||
-t 'modbus/state/test' -m rig-bus-ok || return 1
|
||||
wait "$sub"
|
||||
got=$(cat "$WORK/real/sub.out")
|
||||
[ "$got" = rig-bus-ok ] || { echo "subscriber got: $got"; return 1; }
|
||||
}
|
||||
check "real broker: ui receives what modbus publishes, both logged in by credential file" real_message
|
||||
else
|
||||
echo "[SKIP] real broker (set WARDEN_TEST_MOSQUITTO_DIR)"
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then
|
||||
echo "PASS: rig bus"
|
||||
else
|
||||
echo "FAIL: rig bus"
|
||||
fi
|
||||
exit "$FAIL"
|
||||
+202
-5
@@ -172,6 +172,17 @@ INPUT_SLOW_NOTE_S = 2.0
|
||||
# wedged qemu-system-arm cannot outlive the script.
|
||||
QMP_TIMEOUT_S = 20.0
|
||||
|
||||
# Bounds each recv() on the control channel. It must outlast the bridge's
|
||||
# own reply wait (WARDEN_CTL_WAIT_S, 30 s of 0.05 s polls, which take longer
|
||||
# in wall time on a slow TCG guest), so a slow UI reaches the driver as the
|
||||
# bridge's explicit "no reply" line rather than a bare socket timeout.
|
||||
CTL_TIMEOUT_S = 90.0
|
||||
|
||||
# The bridge's own answer when warden-ui did not reply within its bound
|
||||
# (Ctl.NO_REPLY; a module constant too because the offline tests swap the
|
||||
# Ctl class out).
|
||||
BRIDGE_NO_REPLY = "bridge: no reply from warden-ui"
|
||||
|
||||
# Where webstatus.c (ui-src/src/warden/webstatus.c) publishes its atomic
|
||||
# snapshot inside the guest. assert_json/wait_json `@cat` this path over the
|
||||
# control channel; see the bridge in rootfs/sbin/init.
|
||||
@@ -350,12 +361,12 @@ class Ctl:
|
||||
# rootfs/sbin/init's ctl bridge (the FIFO-to-socket relay this class
|
||||
# talks to). Nothing enforces the two staying in sync -- a sentinel
|
||||
# changed on one side and not the other means send() below blocks until
|
||||
# its own 15s timeout on every ctl-dependent step, with nothing at that
|
||||
# its own CTL_TIMEOUT_S on every ctl-dependent step, with nothing at that
|
||||
# point pointing back at this mismatch as the cause.
|
||||
SENTINEL = "<<END>>"
|
||||
|
||||
# A real reply (a hit's box, the status JSON) is at most a few KB. The
|
||||
# 15s socket timeout below bounds each individual recv(), not the total
|
||||
# socket timeout below bounds each individual recv(), not the total
|
||||
# bytes accepted, so a peer that keeps streaming data fast enough to beat
|
||||
# that per-call timeout, but never emits a newline or SENTINEL, would
|
||||
# otherwise grow self.buf without limit and exhaust host memory before
|
||||
@@ -363,7 +374,13 @@ class Ctl:
|
||||
# silent or closes outright already does.
|
||||
MAX_BUF = 256 * 1024
|
||||
|
||||
def __init__(self, path, timeout=15.0):
|
||||
# The bridge's own answer when warden-ui did not reply within its bound
|
||||
# (warden_ctl_bridge in rootfs/etc/warden-lib.sh, flare-edge #1448).
|
||||
NO_REPLY = BRIDGE_NO_REPLY
|
||||
|
||||
def __init__(self, path, timeout=None):
|
||||
if timeout is None:
|
||||
timeout = CTL_TIMEOUT_S
|
||||
self.sock = socket.socket(socket.AF_UNIX)
|
||||
self.sock.settimeout(timeout)
|
||||
self.sock.connect(path)
|
||||
@@ -392,7 +409,177 @@ class Ctl:
|
||||
if line.strip() == cmd.strip():
|
||||
continue
|
||||
lines.append(line)
|
||||
return "\n".join(lines).strip()
|
||||
reply = "\n".join(lines).strip()
|
||||
# A UI that did not answer in time is a rig fault, not evidence: an
|
||||
# empty reply judged as "page is ''" hid it (flare-edge #1448).
|
||||
if reply.startswith(self.NO_REPLY):
|
||||
raise RuntimeError(f"control channel: {reply}")
|
||||
return reply
|
||||
|
||||
|
||||
# Stall probe (flare-edge #1528). When a step fails because warden-ui did not
|
||||
# answer (the bridge's no-reply line) or did not consume an injected press,
|
||||
# the driver samples the host, the VM's vCPU thread and the guest over
|
||||
# STALL_WINDOW_S and appends one line to the step's detail, so the job log
|
||||
# itself says whether the host starved the VM, the guest CPU was saturated
|
||||
# (and by which processes), the guest waited on I/O, or the guest sat idle
|
||||
# while warden-ui was blocked. Re-run jobs lose their artifacts; the job log
|
||||
# keeps this line. At most STALL_REPORTS_MAX probes per run, since each one
|
||||
# costs the window.
|
||||
STALL_WINDOW_S = 2.0
|
||||
STALL_REPORTS_MAX = 3
|
||||
INPUT_NOT_CONSUMED = "was not consumed within"
|
||||
|
||||
|
||||
def is_stall(detail):
|
||||
"""Whether a failed step's detail is warden-ui not answering."""
|
||||
return BRIDGE_NO_REPLY in detail or INPUT_NOT_CONSUMED in detail
|
||||
|
||||
|
||||
def parse_proc_stat(text):
|
||||
"""Guest /proc/stat -> (cpu jiffies list, procs_running, procs_blocked);
|
||||
None when the text has no aggregate cpu line."""
|
||||
cpu, running, blocked = None, None, None
|
||||
for line in text.splitlines():
|
||||
parts = line.split()
|
||||
if not parts:
|
||||
continue
|
||||
if parts[0] == "cpu":
|
||||
cpu = [int(x) for x in parts[1:] if x.isdigit()]
|
||||
elif parts[0] == "procs_running" and len(parts) > 1:
|
||||
running = int(parts[1])
|
||||
elif parts[0] == "procs_blocked" and len(parts) > 1:
|
||||
blocked = int(parts[1])
|
||||
if not cpu or len(cpu) < 5:
|
||||
return None
|
||||
return cpu, running, blocked
|
||||
|
||||
|
||||
def parse_procs(text):
|
||||
"""/proc/<pid>/stat lines (the bridge's `@procs`) -> {pid: (comm, state,
|
||||
utime + stime)}. The comm may hold spaces or parentheses, so the fields
|
||||
are counted from its last ')'."""
|
||||
out = {}
|
||||
for line in text.splitlines():
|
||||
head, sep, tail = line.rpartition(")")
|
||||
if not sep or " (" not in head:
|
||||
continue
|
||||
pid, _, comm = head.partition(" (")
|
||||
fields = tail.split()
|
||||
if not pid.strip().isdigit() or len(fields) < 13:
|
||||
continue
|
||||
try:
|
||||
ticks = int(fields[11]) + int(fields[12])
|
||||
except ValueError:
|
||||
continue
|
||||
out[int(pid)] = (comm, fields[0], ticks)
|
||||
return out
|
||||
|
||||
|
||||
def guest_cpu_delta(a, b):
|
||||
"""Two parse_proc_stat() samples -> (busy share, iowait share) of the
|
||||
guest CPU over the window, or None when nothing was counted."""
|
||||
if a is None or b is None:
|
||||
return None
|
||||
d = [y - x for x, y in zip(a[0], b[0])]
|
||||
total = sum(d)
|
||||
if total <= 0:
|
||||
return None
|
||||
idle, iowait = d[3], d[4]
|
||||
return (total - idle - iowait) / total, iowait / total
|
||||
|
||||
|
||||
def top_procs(a, b, total_ticks, n=3):
|
||||
"""The N guest processes that used the most CPU between two parse_procs()
|
||||
samples, as 'comm share%' strings, and the comms in state D at the end."""
|
||||
used = []
|
||||
for pid, (comm, _state, ticks) in b.items():
|
||||
before = a.get(pid)
|
||||
if before is not None and ticks > before[2]:
|
||||
used.append((ticks - before[2], comm))
|
||||
used.sort(reverse=True)
|
||||
top = [f"{comm} {100 * t / total_ticks:.0f}%" for t, comm in used[:n]] if total_ticks > 0 else []
|
||||
dstate = sorted({comm for comm, state, _ in b.values() if state == "D"})
|
||||
return top, dstate
|
||||
|
||||
|
||||
def stall_verdict(vcpu_share, guest, blocked, dstate):
|
||||
"""One phrase naming the most likely cause from the probe's numbers."""
|
||||
if vcpu_share is not None and vcpu_share < 0.6:
|
||||
return "the host starves the VM (its vCPU thread ran under 60% of a core)"
|
||||
if guest is None:
|
||||
return "the guest did not answer the probe"
|
||||
busy, iowait = guest
|
||||
if busy >= 0.9:
|
||||
return "the guest CPU is saturated"
|
||||
if iowait >= 0.3 or blocked or dstate:
|
||||
return "the guest waits on I/O"
|
||||
return "the guest is mostly idle: warden-ui is blocked, not starved"
|
||||
|
||||
|
||||
def _read(path):
|
||||
try:
|
||||
with open(path) as fh:
|
||||
return fh.read()
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
|
||||
def _host_psi(kind):
|
||||
m = re.search(r"some avg10=([0-9.]+)", _read(f"/proc/pressure/{kind}"))
|
||||
return f"{float(m.group(1)):.0f}%" if m else "n/a"
|
||||
|
||||
|
||||
def _thread_ticks(tids):
|
||||
total = 0
|
||||
for tid in tids:
|
||||
fields = _read(f"/proc/{tid}/stat").rpartition(")")[2].split()
|
||||
if len(fields) < 13:
|
||||
return None
|
||||
total += int(fields[11]) + int(fields[12])
|
||||
return total
|
||||
|
||||
|
||||
def _guest_sample(ctl):
|
||||
try:
|
||||
return parse_proc_stat(ctl.send("@cat /proc/stat")), parse_procs(ctl.send("@procs"))
|
||||
except (RuntimeError, OSError):
|
||||
return None, {}
|
||||
|
||||
|
||||
def stall_report(ctx):
|
||||
"""Sample the host, the vCPU thread and the guest over STALL_WINDOW_S and
|
||||
describe them in one line (see the block comment above STALL_WINDOW_S)."""
|
||||
try:
|
||||
tids = [c["thread-id"] for c in rpc(ctx.s, ctx.f, {"execute": "query-cpus-fast"})]
|
||||
except (RuntimeError, OSError, KeyError, TypeError, ValueError):
|
||||
tids = []
|
||||
hz = os.sysconf("SC_CLK_TCK")
|
||||
v0 = _thread_ticks(tids) if tids else None
|
||||
g0, p0 = _guest_sample(ctx.ctl) if ctx.ctl else (None, {})
|
||||
t0 = time.monotonic()
|
||||
time.sleep(STALL_WINDOW_S)
|
||||
v1 = _thread_ticks(tids) if tids else None
|
||||
g1, p1 = _guest_sample(ctx.ctl) if ctx.ctl else (None, {})
|
||||
window = time.monotonic() - t0
|
||||
vcpu = (v1 - v0) / (hz * window) if v0 is not None and v1 is not None else None
|
||||
guest = guest_cpu_delta(g0, g1)
|
||||
blocked = g1[2] if g1 else None
|
||||
total_ticks = sum(y - x for x, y in zip(g0[0], g1[0])) if g0 and g1 else 0
|
||||
top, dstate = top_procs(p0, p1, total_ticks)
|
||||
load = os.getloadavg()[0]
|
||||
parts = [f"stall probe ({window:.1f} s): {stall_verdict(vcpu, guest, blocked, dstate)}",
|
||||
f"host load {load:.1f}/{os.cpu_count()} cpus, psi cpu {_host_psi('cpu')} "
|
||||
f"io {_host_psi('io')}",
|
||||
"vcpu " + (f"{100 * vcpu:.0f}% of a core" if vcpu is not None else "n/a")]
|
||||
if guest is None:
|
||||
parts.append("guest n/a")
|
||||
else:
|
||||
parts.append(f"guest busy {100 * guest[0]:.0f}% iowait {100 * guest[1]:.0f}%, "
|
||||
f"running {g1[1]} blocked {g1[2]}")
|
||||
parts.append("top " + (", ".join(top) if top else "n/a"))
|
||||
parts.append("D " + (", ".join(dstate) if dstate else "none"))
|
||||
return "; ".join(parts)
|
||||
|
||||
|
||||
HIT_RE = re.compile(r'^hit \d+,\d+: (\S+)(?: text="(.*)" box=(-?\d+),(-?\d+),(\d+)x(\d+))?$')
|
||||
@@ -425,7 +612,7 @@ def poll_until(check, timeout_s, period=0.5):
|
||||
they all mean the same thing by a timeout.
|
||||
|
||||
A CHECK that raises RuntimeError or OSError -- the control channel
|
||||
dying mid-poll, e.g. a socket.timeout past Ctl's own 15s per-call
|
||||
dying mid-poll, e.g. a socket.timeout past Ctl's own CTL_TIMEOUT_S per-call
|
||||
timeout -- stops polling right there instead of retrying a channel
|
||||
that is probably gone, and comes back with FATAL true so the caller
|
||||
records a `fatal` row (the same idea as ConsoleWatch.check() turning a
|
||||
@@ -758,6 +945,8 @@ class Ctx:
|
||||
self.prev_step_console = 0
|
||||
# The longest input-count wait of the current tap, swipe or fling.
|
||||
self.input_wait_s = 0.0
|
||||
# Stall probes run so far (STALL_REPORTS_MAX bounds them).
|
||||
self.stall_reports = 0
|
||||
|
||||
def need_ctl(self, lineno, cmd):
|
||||
if self.ctl is None:
|
||||
@@ -1272,6 +1461,14 @@ def drive(s, f, script_path, outdir, size, ctl_path=None, console_path=None, ref
|
||||
# Recorded the same as any other fatal row: the run keeps going
|
||||
# past it.
|
||||
result = ("fatal", str(e))
|
||||
if (result is not None and result[0] != "ok" and len(result) > 1
|
||||
and is_stall(str(result[1])) and ctx.stall_reports < STALL_REPORTS_MAX):
|
||||
ctx.stall_reports += 1
|
||||
try:
|
||||
probe = stall_report(ctx)
|
||||
except (RuntimeError, OSError, ValueError) as e:
|
||||
probe = f"stall probe failed: {e}"
|
||||
result = (result[0], f"{result[1]}; {probe}")
|
||||
if result is not None:
|
||||
record(lineno, line, *result)
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ was never compared with the one the reference was captured under.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import socket
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -1159,6 +1160,49 @@ class CtlSocketProtocol(unittest.TestCase):
|
||||
th.join(timeout=2)
|
||||
self.assertEqual(got, "the actual reply")
|
||||
|
||||
def test_bridge_no_reply_line_raises_as_a_rig_fault(self):
|
||||
# flare-edge #1448: a UI slower than the bridge's wait came back as
|
||||
# an empty reply and was judged "page is ''". The bridge now says
|
||||
# so, and that line must stop the flow as a rig fault.
|
||||
def server():
|
||||
self.server_sock.recv(4096)
|
||||
self.server_sock.sendall(
|
||||
b"bridge: no reply from warden-ui within 30 s: page\n<<END>>\n")
|
||||
|
||||
th = threading.Thread(target=server, daemon=True)
|
||||
th.start()
|
||||
try:
|
||||
with self.assertRaises(RuntimeError) as cm:
|
||||
self.ctl.send("page")
|
||||
finally:
|
||||
th.join(timeout=2)
|
||||
self.assertIn("no reply from warden-ui", str(cm.exception))
|
||||
|
||||
def test_bridge_no_such_file_stays_an_ordinary_reply(self):
|
||||
# Only the no-reply line is a fault; @cat's missing-file answer is
|
||||
# a detail the json channel handles itself.
|
||||
def server():
|
||||
self.server_sock.recv(4096)
|
||||
self.server_sock.sendall(b"bridge: no such file: /x\n<<END>>\n")
|
||||
|
||||
th = threading.Thread(target=server, daemon=True)
|
||||
th.start()
|
||||
try:
|
||||
got = self.ctl.send("@cat /x")
|
||||
finally:
|
||||
th.join(timeout=2)
|
||||
self.assertEqual(got, "bridge: no such file: /x")
|
||||
|
||||
def test_ctl_timeout_outlasts_the_bridge_wait(self):
|
||||
# The bridge polls up to 30 s (more wall time on a slow guest); a
|
||||
# shorter socket timeout would turn its explicit answer into a bare
|
||||
# socket.timeout. Read the bridge default from the rootfs itself.
|
||||
lib = os.path.join(HERE, "..", "rootfs", "etc", "warden-lib.sh")
|
||||
with open(lib) as f:
|
||||
m = re.search(r"WARDEN_CTL_WAIT_S:-(\d+)", f.read())
|
||||
self.assertIsNotNone(m, "warden_ctl_bridge default wait not found")
|
||||
self.assertGreaterEqual(qmp.CTL_TIMEOUT_S, 2 * int(m.group(1)))
|
||||
|
||||
def test_leftover_bytes_after_sentinel_carry_over_to_the_next_send(self):
|
||||
# One write carries this reply's SENTINEL immediately followed by
|
||||
# bytes belonging to the NEXT command's reply -- proving self.buf
|
||||
@@ -1317,5 +1361,109 @@ class JsonStatusFetch(unittest.TestCase):
|
||||
self.assertGreaterEqual(time.monotonic() - t0, 0.6)
|
||||
|
||||
|
||||
|
||||
def _proc_stat(user, idle, iowait=0, running=1, blocked=0):
|
||||
return (f"cpu {user} 0 0 {idle} {iowait} 0 0 0 0 0\ncpu0 {user} 0 0 {idle} {iowait} 0 0 0 0 0\n"
|
||||
f"ctxt 1\nprocs_running {running}\nprocs_blocked {blocked}\n")
|
||||
|
||||
|
||||
def _pid_line(pid, comm, state, utime, stime=0):
|
||||
rest = " ".join(["0"] * 10)
|
||||
return f"{pid} ({comm}) {state} 1 1 1 0 -1 0 0 0 0 0 {utime} {stime} {rest}"
|
||||
|
||||
|
||||
class StallProbe(unittest.TestCase):
|
||||
"""flare-edge #1528: a step that fails because warden-ui did not answer
|
||||
carries one probe line saying why (host starving the VM, guest CPU
|
||||
saturated, guest I/O wait, or an idle guest with a blocked UI)."""
|
||||
|
||||
def test_parsers(self):
|
||||
st = qmp.parse_proc_stat(_proc_stat(5, 7, 2, running=3, blocked=1))
|
||||
self.assertEqual(st, ([5, 0, 0, 7, 2, 0, 0, 0, 0, 0], 3, 1))
|
||||
self.assertIsNone(qmp.parse_proc_stat("bridge: no such file: /proc/stat"))
|
||||
procs = qmp.parse_procs(_pid_line(7, "warden ui) x", "R", 40, 2) + "\n"
|
||||
+ _pid_line(9, "sh", "D", 1) + "\njunk\n")
|
||||
self.assertEqual(procs, {7: ("warden ui) x", "R", 42), 9: ("sh", "D", 1)})
|
||||
|
||||
def test_verdicts(self):
|
||||
self.assertIn("starves the VM", qmp.stall_verdict(0.3, (1.0, 0.0), 0, []))
|
||||
self.assertIn("did not answer", qmp.stall_verdict(0.99, None, None, []))
|
||||
self.assertIn("saturated", qmp.stall_verdict(0.99, (0.95, 0.0), 0, []))
|
||||
self.assertIn("I/O", qmp.stall_verdict(0.99, (0.2, 0.5), 1, ["warden-ui"]))
|
||||
self.assertIn("I/O", qmp.stall_verdict(None, (0.1, 0.0), 0, ["warden-ui"]))
|
||||
self.assertIn("idle", qmp.stall_verdict(0.99, (0.05, 0.0), 0, []))
|
||||
|
||||
def test_cpu_delta_and_top(self):
|
||||
a = qmp.parse_proc_stat(_proc_stat(100, 100))
|
||||
b = qmp.parse_proc_stat(_proc_stat(190, 110))
|
||||
busy, iowait = qmp.guest_cpu_delta(a, b)
|
||||
self.assertAlmostEqual(busy, 0.9)
|
||||
self.assertEqual(iowait, 0.0)
|
||||
p0 = qmp.parse_procs(_pid_line(7, "warden-ui", "R", 10) + "\n" + _pid_line(8, "flared", "S", 5))
|
||||
p1 = qmp.parse_procs(_pid_line(7, "warden-ui", "R", 80) + "\n" + _pid_line(8, "flared", "D", 25))
|
||||
top, dstate = qmp.top_procs(p0, p1, 100)
|
||||
self.assertEqual(top, ["warden-ui 70%", "flared 20%"])
|
||||
self.assertEqual(dstate, ["flared"])
|
||||
|
||||
def _drive_no_reply(self, script):
|
||||
class NoReplyCtl(FakeCtl):
|
||||
samples = 0
|
||||
|
||||
def send(self, cmd):
|
||||
if cmd == "@cat /proc/stat":
|
||||
NoReplyCtl.samples += 1
|
||||
n = NoReplyCtl.samples
|
||||
return _proc_stat(100 * n, 10)
|
||||
if cmd == "@procs":
|
||||
n = NoReplyCtl.samples
|
||||
return _pid_line(7, "warden-ui", "R", 95 * n) + "\n" + _pid_line(8, "sh", "S", 5 * n)
|
||||
if cmd == "page":
|
||||
raise RuntimeError("control channel: bridge: no reply from warden-ui "
|
||||
"within 30 s: page")
|
||||
return super().send(cmd)
|
||||
|
||||
def rpc_fn(sock, sock_file, obj):
|
||||
if obj.get("execute") == "query-cpus-fast":
|
||||
# No vCPU thread to sample here (test_vcpu_thread_ticks
|
||||
# covers the sampling); the verdict then rests on the guest.
|
||||
return []
|
||||
return fake_rpc(sock, sock_file, obj)
|
||||
|
||||
saved = qmp.STALL_WINDOW_S
|
||||
qmp.STALL_WINDOW_S = 0.05
|
||||
try:
|
||||
return run_script(script, ctl_cls=NoReplyCtl, rpc_fn=rpc_fn)
|
||||
finally:
|
||||
qmp.STALL_WINDOW_S = saved
|
||||
|
||||
def test_no_reply_steps_carry_a_bounded_probe(self):
|
||||
rc, _by, rows = self._drive_no_reply("assert_page Demo/Rows\n" * 4 + "assert_stat fps lt 0\n")
|
||||
self.assertEqual(rc, 1)
|
||||
self.assertEqual([r["status"] for r in rows], ["fatal"] * 4 + ["fail"])
|
||||
probed = [r["detail"] for r in rows if "stall probe" in r["detail"]]
|
||||
self.assertEqual(len(probed), qmp.STALL_REPORTS_MAX, rows)
|
||||
first = rows[0]["detail"]
|
||||
self.assertTrue(first.startswith("control channel: bridge: no reply"), first)
|
||||
self.assertIn("the guest CPU is saturated", first)
|
||||
self.assertIn("top warden-ui 95%, sh 5%", first)
|
||||
self.assertIn("vcpu n/a", first)
|
||||
self.assertIn("guest busy 100% iowait 0%", first)
|
||||
# A plain mismatch is not a stall and gets no probe.
|
||||
self.assertNotIn("stall probe", rows[4]["detail"])
|
||||
|
||||
def test_vcpu_thread_ticks(self):
|
||||
tid = threading.get_native_id()
|
||||
before = qmp._thread_ticks([tid])
|
||||
end = time.process_time() + 0.3
|
||||
while time.process_time() < end:
|
||||
pass
|
||||
self.assertGreater(qmp._thread_ticks([tid]), before)
|
||||
self.assertIsNone(qmp._thread_ticks([2 ** 22 + 12345]))
|
||||
|
||||
def test_unconsumed_input_is_a_stall(self):
|
||||
self.assertTrue(qmp.is_stall(qmp.input_verdict(SimpleNamespace(), False)[1]))
|
||||
self.assertTrue(qmp.is_stall("control channel: bridge: no reply from warden-ui within 30 s: hit"))
|
||||
self.assertFalse(qmp.is_stall("obj moved: box=1,2,3x4"))
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=1)
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regression tests for build/fetch-kernel-tarball.sh (#1588).
|
||||
#
|
||||
# Runs the real script, copied into a fixture dir so its own HERE-relative pin
|
||||
# lookup finds a pin we control, with a fake curl first on PATH: no network,
|
||||
# and the outcome of each fetch is exact. Covers:
|
||||
# - curl is bounded (connect timeout, stall abort, total cap), so a server
|
||||
# that answers and then stalls cannot hold the job until its timeout;
|
||||
# - a failed fetch leaves no partial tarball behind, so the next run fetches
|
||||
# again instead of taking the partial file as present;
|
||||
# - a good fetch is verified and kept; a present, matching tarball is reused.
|
||||
set -uo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
SCRIPT="$HERE/../../build/fetch-kernel-tarball.sh"
|
||||
[ -f "$SCRIPT" ] || { echo "FAIL: script not found at $SCRIPT"; exit 1; }
|
||||
KVER="$(sed -n 's/^KVER=//p' "$SCRIPT")"
|
||||
[ -n "$KVER" ] || { echo "FAIL: no KVER in $SCRIPT"; exit 1; }
|
||||
|
||||
FAIL=0
|
||||
ok() { printf '[PASS] %s\n' "$1"; }
|
||||
bad() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
||||
|
||||
TMP="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
setup() { # setup <case-name> -> prints the fixture dir
|
||||
local dir="$TMP/$1"
|
||||
mkdir -p "$dir/bin"
|
||||
cp "$SCRIPT" "$dir/fetch-kernel-tarball.sh"
|
||||
printf 'good-bytes' | sha256sum | awk '{print $1}' \
|
||||
> "$dir/linux-$KVER.tar.xz.sha256"
|
||||
printf '%s' "$dir"
|
||||
}
|
||||
|
||||
# fake_curl <dir> <mode>: records its argv in <dir>/argv and its call count in
|
||||
# <dir>/count. Modes: good (writes the pinned bytes), partial (writes a few
|
||||
# bytes, then fails the way curl does on a timeout), never (must not run).
|
||||
fake_curl() {
|
||||
local dir="$1" mode="$2"
|
||||
# These single-quoted lines are the literal source of the fake program.
|
||||
# shellcheck disable=SC2016
|
||||
printf '%s\n' '#!/bin/sh' \
|
||||
'dir=$(dirname "$(dirname "$0")")' \
|
||||
'printf "%s\n" "$*" > "$dir/argv"' \
|
||||
'echo x >> "$dir/count"' \
|
||||
'out=' \
|
||||
'while [ "$#" -gt 0 ]; do' \
|
||||
' if [ "$1" = "-o" ]; then shift; out="$1"; fi' \
|
||||
' shift' \
|
||||
'done' \
|
||||
'[ -n "$out" ] || exit 2' \
|
||||
"case $mode in" \
|
||||
' good) printf good-bytes > "$out" ;;' \
|
||||
' partial) printf good > "$out"; exit 28 ;;' \
|
||||
' *) echo "curl should not have run" >&2; exit 1 ;;' \
|
||||
'esac' > "$dir/bin/curl"
|
||||
chmod +x "$dir/bin/curl"
|
||||
}
|
||||
|
||||
run() { # run <dir> <dest> -> output in $OUT, status in $RC
|
||||
local dir="$1" dest="$2"
|
||||
OUT="$(PATH="$dir/bin:$PATH" bash "$dir/fetch-kernel-tarball.sh" "$dest" 2>&1)"
|
||||
RC=$?
|
||||
}
|
||||
|
||||
# --- case A: a good fetch is bounded, verified and kept ---------------------
|
||||
dir="$(setup case-a)"
|
||||
fake_curl "$dir" good
|
||||
run "$dir" "$dir/linux.tar.xz"
|
||||
if [ "$RC" -eq 0 ] && [ -f "$dir/linux.tar.xz" ] \
|
||||
&& printf '%s' "$OUT" | grep -q 'tarball sha256 verified'; then
|
||||
ok "good fetch: verified and kept"
|
||||
else
|
||||
bad "good fetch: verified and kept (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
for flag in --connect-timeout --speed-limit --speed-time --max-time; do
|
||||
if grep -q -- "$flag" "$dir/argv"; then
|
||||
ok "curl carries $flag"
|
||||
else
|
||||
bad "curl carries $flag (argv: $(cat "$dir/argv"))"
|
||||
fi
|
||||
done
|
||||
if ls "$dir"/linux.tar.xz.download.* >/dev/null 2>&1; then
|
||||
bad "good fetch: no download temp file left"
|
||||
else
|
||||
ok "good fetch: no download temp file left"
|
||||
fi
|
||||
|
||||
# --- case B: a failed fetch leaves nothing, and the next run fetches again --
|
||||
dir="$(setup case-b)"
|
||||
fake_curl "$dir" partial
|
||||
run "$dir" "$dir/linux.tar.xz"
|
||||
if [ "$RC" -ne 0 ] && [ ! -e "$dir/linux.tar.xz" ] \
|
||||
&& ! ls "$dir"/linux.tar.xz.download.* >/dev/null 2>&1; then
|
||||
ok "failed fetch: no partial tarball left"
|
||||
else
|
||||
bad "failed fetch: no partial tarball left (rc=$RC, files: $(ls "$dir"))"
|
||||
fi
|
||||
fake_curl "$dir" good
|
||||
run "$dir" "$dir/linux.tar.xz"
|
||||
if [ "$RC" -eq 0 ] && [ "$(wc -l < "$dir/count")" -eq 2 ]; then
|
||||
ok "run after a failed fetch downloads again and passes"
|
||||
else
|
||||
bad "run after a failed fetch downloads again and passes (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
# --- case C: a present, matching tarball is reused without curl -------------
|
||||
dir="$(setup case-c)"
|
||||
printf 'good-bytes' > "$dir/linux.tar.xz"
|
||||
fake_curl "$dir" never
|
||||
run "$dir" "$dir/linux.tar.xz"
|
||||
if [ "$RC" -eq 0 ] && [ ! -e "$dir/count" ]; then
|
||||
ok "present tarball: reused, curl never invoked"
|
||||
else
|
||||
bad "present tarball: reused, curl never invoked (rc=$RC, out=$OUT)"
|
||||
fi
|
||||
|
||||
[ "$FAIL" -eq 0 ] && echo "fetch-kernel-tarball tests passed"
|
||||
exit "$FAIL"
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
# Offline test: the QEMU initramfs scripts pass the same shellcheck the qemu-tools CI job runs
|
||||
# (issue #18: `for w in $(cat /proc/cmdline)` failed it with SC2013), and the check really fires.
|
||||
# Skips with a notice when shellcheck is not installed (CI installs it).
|
||||
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; }
|
||||
|
||||
if ! command -v shellcheck >/dev/null 2>&1; then
|
||||
echo "[SKIP] shellcheck is not installed"; exit 0
|
||||
fi
|
||||
|
||||
cd "$REPO" || exit 1
|
||||
if shellcheck -x qemu/rootfs/init qemu/rootfs/etc/rc qemu/rootfs/sbin/init > "$TMP/out" 2>&1; then
|
||||
ok "qemu/rootfs scripts pass shellcheck"
|
||||
else
|
||||
bad "qemu/rootfs scripts fail shellcheck"; head -20 "$TMP/out"
|
||||
fi
|
||||
|
||||
if grep -q 'read -r CMDLINE < /proc/cmdline' qemu/rootfs/init; then
|
||||
ok "init reads /proc/cmdline into a variable"
|
||||
else
|
||||
bad "init no longer reads /proc/cmdline into a variable"
|
||||
fi
|
||||
|
||||
# the old form must be red
|
||||
# shellcheck disable=SC2016 # the text is the literal old source line
|
||||
old_loop='for w in $(cat /proc/cmdline); do'
|
||||
sed -e '/^read -r CMDLINE < \/proc\/cmdline$/d' -e "s|^for w in \\\$CMDLINE; do\$|$old_loop|" qemu/rootfs/init > "$TMP/init-old"
|
||||
grep -qF "$old_loop" "$TMP/init-old" || bad "the doctored copy was not built"
|
||||
out="$(shellcheck -x "$TMP/init-old" 2>&1 || true)"
|
||||
if printf '%s' "$out" | grep -q 'SC2013'; then
|
||||
ok "doctored: the cat-in-a-for-loop form is reported as SC2013"
|
||||
else
|
||||
bad "doctored: the old form was not caught"
|
||||
fi
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then echo "ALL QEMU-INIT SHELLCHECK TESTS PASSED"; else echo "QEMU-INIT SHELLCHECK TESTS FAILED"; fi
|
||||
exit $FAIL
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env bash
|
||||
# The final kernel .config, and so KCONFIG_SHA256, must not depend on the host's python (issue #19):
|
||||
# DRM_MSM_VALIDATE_XML used to be visible only where python3 could import lxml, adding one line to the
|
||||
# file. Runs the config-only expansion twice, once with a python3 whose `import lxml` works and once with
|
||||
# one where it fails, and requires the same digest. Proven red on a copy of the tree without
|
||||
# patches/90-kconfig-no-python-symbol.patch (when this host's python3 has lxml; otherwise the red case
|
||||
# is skipped with a notice). Needs the pinned kernel tarball: KERNEL_TARBALL=<path>, or skipped.
|
||||
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; }
|
||||
|
||||
if [ -z "${KERNEL_TARBALL:-}" ] || [ ! -f "$KERNEL_TARBALL" ]; then
|
||||
echo "[SKIP] set KERNEL_TARBALL to the pinned linux-6.18.46.tar.xz"; exit 0
|
||||
fi
|
||||
command -v python >/dev/null || { echo "[SKIP] needs 'python' on PATH (SDK quirk)"; exit 0; }
|
||||
REAL_PY="$(command -v python3)"
|
||||
|
||||
# a python3 on which `import lxml` fails, everything else passes through
|
||||
mkdir -p "$TMP/nolxml"
|
||||
cat > "$TMP/nolxml/python3" <<PYEOF
|
||||
#!/bin/sh
|
||||
case "\$*" in *"import lxml"*) exit 1 ;; esac
|
||||
exec "$REAL_PY" "\$@"
|
||||
PYEOF
|
||||
chmod +x "$TMP/nolxml/python3"
|
||||
# and one where it succeeds even if lxml is not installed
|
||||
mkdir -p "$TMP/lxml"
|
||||
cat > "$TMP/lxml/python3" <<PYEOF
|
||||
#!/bin/sh
|
||||
case "\$*" in *"import lxml"*) exit 0 ;; esac
|
||||
exec "$REAL_PY" "\$@"
|
||||
PYEOF
|
||||
chmod +x "$TMP/lxml/python3"
|
||||
|
||||
digest() { # digest <tree root> <path prefix dir>
|
||||
local root="$1" pfx="$2" work
|
||||
work="$(mktemp -d "$TMP/w.XXXXXX")"
|
||||
PATH="$pfx:$PATH" KERNEL_TARBALL="$KERNEL_TARBALL" WORK="$work" WARDEN_CONFIG_ONLY=1 \
|
||||
CONFIG_OUT="$work/final.config" CROSS_COMPILE="${CROSS_COMPILE:-arm-linux-gnueabihf-}" \
|
||||
bash "$root/build/build-kernel.sh" > "$work/log" 2>&1 || { tail -5 "$work/log" >&2; echo FAILED; return; }
|
||||
cat "$work/final.config.sha256"
|
||||
}
|
||||
|
||||
a="$(digest "$REPO" "$TMP/lxml")"; b="$(digest "$REPO" "$TMP/nolxml")"
|
||||
if [ "$a" != FAILED ] && [ "$a" = "$b" ]; then ok "the config digest is the same with and without a working import lxml ($a)"
|
||||
else bad "the config digest depends on the host python: with lxml $a, without $b"; fi
|
||||
|
||||
# red case: a tree without the patch
|
||||
mkdir -p "$TMP/old/patches"
|
||||
cp -r "$REPO/build" "$TMP/old/build"
|
||||
for p in "$REPO"/patches/*.patch; do [ "$(basename "$p")" = 90-kconfig-no-python-symbol.patch ] || cp "$p" "$TMP/old/patches/"; done
|
||||
oa="$(digest "$TMP/old" "$TMP/lxml")"; ob="$(digest "$TMP/old" "$TMP/nolxml")"
|
||||
if [ "$oa" = FAILED ] || [ "$ob" = FAILED ]; then bad "the doctored tree did not expand"
|
||||
elif [ "$oa" != "$ob" ]; then ok "doctored: without the patch the digests differ ($oa vs $ob), so this test can fail"
|
||||
else bad "doctored: the digests are equal even without the patch; the test proves nothing on this tarball"; fi
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then echo "ALL CONFIG-DETERMINISM TESTS PASSED"; else echo "CONFIG-DETERMINISM TESTS FAILED"; fi
|
||||
exit $FAIL
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env bash
|
||||
# Offline tests for the required-symbols mechanism (rebuild M0):
|
||||
# build/lib-required-symbols.sh, the symbol lists, and build-kernel.sh's
|
||||
# WARDEN_CONFIG_ONLY entry checks. No kernel tarball, no compiler.
|
||||
#
|
||||
# What a regression here costs: olddefconfig drops a defconfig line whose symbol
|
||||
# or dependencies are missing without a word (flare-edge#533 shipped a firewall
|
||||
# that quietly skipped IPv6 that way), so the assertion against the final
|
||||
# .config is the only thing between a dropped symbol and a panel. This proves the
|
||||
# assertion itself fires, on fake .config files, for every failure shape.
|
||||
set -uo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO="$(cd "$HERE/../.." && pwd)"
|
||||
LIB="$REPO/build/lib-required-symbols.sh"
|
||||
REQ="$REPO/build/required-symbols.txt"
|
||||
PROBE="$REPO/build/probe-symbols.txt"
|
||||
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-required-symbols.sh
|
||||
. "$LIB"
|
||||
|
||||
# A .config that satisfies a list: every =y line verbatim, every unset line
|
||||
# absent (Kconfig writes "# CONFIG_X is not set" for those).
|
||||
mkconfig() { # <list> <out>
|
||||
{ req_assertions "$1" | grep -v '^# '
|
||||
req_assertions "$1" | grep '^# '
|
||||
echo 'CONFIG_SOMETHING_ELSE=y'; } > "$2"
|
||||
}
|
||||
|
||||
# The probe list may be empty once every probe has passed (build-kernel.sh then skips it);
|
||||
# PROBES is the list to pass along: the probe list when it holds assertions, nothing otherwise.
|
||||
PROBES=(); [ -n "$(req_assertions "$PROBE")" ] && PROBES=("$PROBE")
|
||||
mkconfig "$REQ" "$TMP/good-req"; : > "$TMP/good-probe"; [ "${#PROBES[@]}" = 0 ] || mkconfig "$PROBE" "$TMP/good-probe"; cat "$TMP/good-req" "$TMP/good-probe" > "$TMP/good"
|
||||
req_assert_config "$TMP/good" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 \
|
||||
&& ok "a config that satisfies both lists passes" || bad "a satisfying config was refused"
|
||||
|
||||
n=$(req_assertions "$REQ" | wc -l)
|
||||
[ "$n" -ge 40 ] && ok "required-symbols.txt holds $n assertions" || bad "required-symbols.txt holds only $n assertions"
|
||||
|
||||
# every =y assertion must be refused when its line is missing, one at a time
|
||||
missing_ok=0; missing_bad=0
|
||||
while IFS= read -r line; do
|
||||
case "$line" in CONFIG_*=y) ;; *) continue ;; esac
|
||||
grep -vxF "$line" "$TMP/good" > "$TMP/cfg-missing"
|
||||
if req_assert_config "$TMP/cfg-missing" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1; then missing_bad=$((missing_bad+1)); echo " not caught: $line"
|
||||
else missing_ok=$((missing_ok+1)); fi
|
||||
done < <(req_assertions "$REQ"; req_assertions "$PROBE")
|
||||
[ "$missing_bad" = 0 ] && ok "dropping any one of $missing_ok =y assertions fails the check" || bad "$missing_bad dropped symbols were not caught"
|
||||
|
||||
# =m is not =y
|
||||
sed 's/^CONFIG_NFT_CT=y$/CONFIG_NFT_CT=m/' "$TMP/good" > "$TMP/cfg-m"
|
||||
req_assert_config "$TMP/cfg-m" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 && bad "a modular symbol was accepted" || ok "a symbol built as a module is refused"
|
||||
|
||||
# unset assertions: a live value fails, absence and 'is not set' pass
|
||||
for sym in $(req_assertions "$REQ" | sed -n 's/^# \(CONFIG_[A-Z0-9_]*\) is not set$/\1/p'); do
|
||||
{ cat "$TMP/good"; echo "$sym=y"; } > "$TMP/cfg-set"
|
||||
req_assert_config "$TMP/cfg-set" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 && bad "$sym=y was accepted although it must stay unset" || ok "$sym=y is refused (must stay unset)"
|
||||
grep -vF "$sym" "$TMP/good" > "$TMP/cfg-absent"
|
||||
req_assert_config "$TMP/cfg-absent" "$REQ" ${PROBES[@]+"${PROBES[@]}"} >/dev/null 2>&1 && ok "$sym absent from the config is accepted" || bad "$sym absent from the config was refused"
|
||||
done
|
||||
|
||||
# No suspend (Noah 2026-10-09): CONFIG_SUSPEND and CONFIG_PM_SLEEP are asserted unset, the
|
||||
# defconfig carries the explicit unset (SUSPEND defaults to y), and a config that
|
||||
# turns either back on is refused by name.
|
||||
DEFCONFIG="$REPO/build/warden_defconfig"
|
||||
for sym in CONFIG_SUSPEND CONFIG_PM_SLEEP; do
|
||||
req_assertions "$REQ" | grep -qxF "# $sym is not set" \
|
||||
&& ok "required-symbols.txt asserts $sym unset" || bad "required-symbols.txt does not assert $sym unset"
|
||||
{ cat "$TMP/good"; echo "$sym=y"; } > "$TMP/cfg-suspend"
|
||||
out=$(req_assert_config "$TMP/cfg-suspend" "$REQ" ${PROBES[@]+"${PROBES[@]}"} 2>&1) && bad "$sym=y was accepted" \
|
||||
|| { printf '%s' "$out" | grep -q "$sym" && ok "$sym=y is refused naming $sym" || bad "$sym=y was refused without naming it"; }
|
||||
done
|
||||
grep -qxF '# CONFIG_SUSPEND is not set' "$DEFCONFIG" \
|
||||
&& ok "warden_defconfig carries the explicit # CONFIG_SUSPEND is not set" \
|
||||
|| bad "warden_defconfig lost the explicit # CONFIG_SUSPEND is not set (the Kconfig default is y)"
|
||||
grep -qE '^CONFIG_SUSPEND=' "$DEFCONFIG" && bad "warden_defconfig sets CONFIG_SUSPEND" || ok "warden_defconfig does not set CONFIG_SUSPEND"
|
||||
|
||||
# Probe V3 passed (2026-10-09): the hardware RNG symbols are required, the probe list is empty, and
|
||||
# the config digest does not move because the defconfig already built them in.
|
||||
for sym in CONFIG_HW_RANDOM CONFIG_HW_RANDOM_ROCKCHIP; do
|
||||
req_assertions "$REQ" | grep -qxF "$sym=y" && ok "required-symbols.txt asserts $sym=y (V3 passed)" || bad "required-symbols.txt lost $sym=y"
|
||||
grep -qxF "$sym=y" "$DEFCONFIG" && ok "warden_defconfig builds $sym in" || bad "warden_defconfig does not set $sym=y"
|
||||
{ cat "$TMP/good"; } | grep -vxF "$sym=y" > "$TMP/cfg-norng"
|
||||
out=$(req_assert_config "$TMP/cfg-norng" "$REQ" 2>&1) && bad "a config without $sym was accepted" \
|
||||
|| { printf '%s' "$out" | grep -q "$sym" && ok "a config without $sym is refused naming it" || bad "refusal did not name $sym"; }
|
||||
done
|
||||
[ -z "$(req_assertions "$PROBE")" ] && ok "probe-symbols.txt is empty: every probe has passed" \
|
||||
|| ok "probe-symbols.txt holds $(req_assertions "$PROBE" | wc -l) pending probe symbol(s)"
|
||||
|
||||
# fail-closed shapes
|
||||
: > "$TMP/empty"
|
||||
req_assert_config "$TMP/empty" "$REQ" >/dev/null 2>&1 && bad "an empty config was accepted" || ok "an empty config is refused"
|
||||
req_assert_config "$TMP/good" "$TMP/no-such-list" >/dev/null 2>&1 && bad "a missing list was accepted" || ok "a missing symbol list is refused"
|
||||
printf '## only comments\n# a comment\n' > "$TMP/no-assertions"
|
||||
req_assert_config "$TMP/good" "$TMP/no-assertions" >/dev/null 2>&1 && bad "a list with no assertions was accepted" || ok "a list with no assertions is refused"
|
||||
|
||||
# comment handling: a prose line starting "# CONFIG_" without "is not set" is a comment
|
||||
printf '## c\n# CONFIG_PROSE is the name of a thing\nCONFIG_REAL=y\n' > "$TMP/prose"
|
||||
[ "$(req_assertions "$TMP/prose")" = "CONFIG_REAL=y" ] && ok "a prose comment is not an assertion" || bad "a prose comment was parsed as an assertion"
|
||||
|
||||
# the lists: a symbol is asserted once, in one list
|
||||
dups=$( { req_assertions "$REQ"; req_assertions "$PROBE"; } | sed 's/^# //; s/ is not set//; s/=.*//' | sort | uniq -d | tr '\n' ' ')
|
||||
# a symbol that passed its probe moves to the required list; it must not stay in both
|
||||
[ -z "$dups" ] && ok "no symbol is asserted twice across the lists" || bad "symbols asserted twice: $dups"
|
||||
|
||||
# build-kernel.sh entry checks (they run before the tarball is touched)
|
||||
BK="$REPO/build/build-kernel.sh"
|
||||
out=$(WARDEN_CONFIG_ONLY=2 bash "$BK" 2>&1); rc=$?
|
||||
[ "$rc" != 0 ] && printf '%s' "$out" | grep -q 'WARDEN_CONFIG_ONLY must be 0 or 1' \
|
||||
&& ok "WARDEN_CONFIG_ONLY=2 is refused" || bad "WARDEN_CONFIG_ONLY=2 was not refused"
|
||||
mkdir -p "$TMP/bin"; printf '#!/bin/sh\nexit 0\n' > "$TMP/bin/python"; chmod +x "$TMP/bin/python"
|
||||
out=$(env -u WORK -u CONFIG_OUT PATH="$TMP/bin:$PATH" WARDEN_CONFIG_ONLY=1 bash "$BK" 2>&1); rc=$?
|
||||
[ "$rc" != 0 ] && printf '%s' "$out" | grep -q 'needs CONFIG_OUT' \
|
||||
&& ok "config-only with a scratch WORK and no CONFIG_OUT is refused (the result would be deleted)" \
|
||||
|| bad "config-only without CONFIG_OUT was not refused: $out"
|
||||
|
||||
# wiring text
|
||||
grep -q 'req_assert_config "\$SRC/.config" "\$REQ_SYMBOLS" \${PROBE_LISTS' "$BK" \
|
||||
&& ok "build-kernel.sh asserts both lists" || bad "build-kernel.sh does not assert the lists"
|
||||
grep -q 'for sym in CONFIG_' "$BK" && bad "build-kernel.sh has a hand-written symbol list again" || ok "build-kernel.sh has no hand-written list"
|
||||
|
||||
if [ "$FAIL" -eq 0 ]; then echo "ALL REQUIRED-SYMBOLS TESTS PASSED"; else echo "REQUIRED-SYMBOLS TESTS FAILED"; fi
|
||||
exit $FAIL
|
||||
Reference in New Issue
Block a user