Compare commits

...
Author SHA1 Message Date
BFE EngineeringandClaude Haiku 5.5 a1bb3b4436 U-Boot: retune CPLL to 900 MHz for the 30 MHz panel mode
ci / qemu-tools (push) Successful in 6m11s
ci / patches-apply (push) Successful in 1m39s
ci / kernel-symbols (push) Successful in 5m17s
ci / test (push) Successful in 14s
ci / bench (push) Successful in 12s
ci / mcdc (push) Successful in 27s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 51s
ci / badges (push) Skipped
The dclk retune in 0001-display-and-boot-timing.patch used rate * 32
(960 MHz for a 30 MHz mode). Align it to 900 MHz so that the /30
divider gives the exact mode clock, as decided for SDK-vop-dclk-43
(pass 3). The retune still runs only when neither CPLL nor GPLL
divides the pixel clock exactly. The image built from this commit
has a new uboot digest and is not yet bench-gated or written.

Refs: flare-edge#3118 (cause 3), SDK-vop-dclk-43.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qGNpGNtFT7nhShpH56
2026-11-15 21:04:25 -06:00
BFE EngineeringandClaude Haiku 5.5 9705273f92 U-Boot flare_ab: drop the unproven p54 attribution from the reset note
ci / badges (push) Skipped
ci / test (push) Successful in 10s
ci / bench (push) Successful in 15s
ci / mcdc (push) Successful in 42s
ci / kernel-build (push) Skipped
ci / patches-apply (push) Successful in 1m25s
ci / prune-artifacts (push) Skipped
ci / kernel-symbols (push) Successful in 2m13s
ci / quality (push) Successful in 1m30s
ci / qemu-tools (push) Successful in 6m33s
The comment above flare_ab_global_reset() said that reset_cpu() ending in
hang() at the boot splash was the stall the p54 record shows
(flare-edge#3118). flare-edge#4569 records that this attribution has no
evidence: the p54 record shows attempt 3 on the recovery branch, where no
reset is issued, and the screen was never captured on serial.

Keep only the source-level finding (the WARM request writes CRU
glb_srst_snd, which does not reset this SoC; flare-edge#4554) and point to
flare-edge#4569 for the open p54 cause.

Comment-only change to 0003-flare-ab-slots.patch. The new-file index id of
common/flare_ab.c moves from 2b41ab8ca to ec685444d; the flare-edge pin and
the wiki pins that cite this commit move with it. check-patch-index.py
passes on the patch.

Refs flare-edge#5555, flare-edge#4554, flare-edge#4569.
Refs flare-edge#4565: the no-committed escalation message (printf in
flare_ab.c) was fixed in the previous commit, which did not cite it.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qGNpGNtFT7nhShpH56
2026-11-14 19:05:37 -06:00
BFE EngineeringandClaude Haiku 5.5 81d609fed3 U-Boot: no-committed ladder, USB download on failed boots [skip ci]
flare_ab keeps the frozen steady-state ladder. The selected committed
slot gets FLARE_AB_SLOT_TRIES (2) boot attempts per power session, then
the other committed slot if it is committed, then the recovery FIT, then
USB download. With no committed alternative the escalation goes from the
two attempts to the recovery FIT. The timed retry from an earlier attempt
(arm the DW watchdog, clear OS_REG4) was rejected by the item decision of
2026-11-06 and is not in this change.

A failed storage boot resets with the CRU glb_srst_fst poke
(flare_ab_global_reset) instead of do_reset(). On this SoC do_reset()
writes glb_srst_snd, which does not reset the chip, and reset_cpu() then
ends in hang() at the boot splash (flare-edge#4554). If the poke does not
take, the unit enters the USB download screens.

flare_ab_usb_download() draws logo_recovery.bmp, logs the return code,
runs download, and on return paints the screen again and re-enters
download after a pause. It never returns, and the unit never calls hang()
on these paths. The draw result was never logged before
(flare-edge#4564, flare-edge#4568).

The no-committed escalation message no longer says that both committed
slots failed when the other slot was never committed.

This does not establish the cause of the p54 splash-only screen
(flare-edge#4569). The bench serial lines (logo_recovery.bmp shown=N,
download returned N) decide it on bench a, which has not run yet.

Refs flare-edge#3118 (cause 3), flare-edge#3302, flare-edge#4554,
flare-edge#4564, flare-edge#4568, flare-edge#4569

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qGNpGNtFT7nhShpH56
2026-11-14 19:04:36 -06:00
Codex fc62400157 Use a pinned BusyBox source mirror
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / patches-apply (pull_request) Successful in 37s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / test (pull_request) Successful in 26s
ci / test (push) Successful in 27s
ci / bench (pull_request) Successful in 29s
ci / bench (push) Successful in 22s
ci / quality (pull_request) Successful in 1m54s
ci / patches-apply (push) Successful in 40s
ci / mcdc (pull_request) Successful in 32s
ci / mcdc (push) Successful in 22s
ci / badges (pull_request) Skipped
ci / kernel-symbols (push) Successful in 1m58s
ci / qemu-tools (pull_request) Successful in 5m7s
ci / kernel-symbols (pull_request) Successful in 5m28s
ci / quality (push) Successful in 1m49s
ci / badges (push) Skipped
ci / qemu-tools (push) Successful in 5m15s
Try the Buildroot release mirror after a failed primary download, retaining
the existing SHA256, bounded attempts and verified-cache behavior. Keep the
new timeout, corruption and production-call controls in regular CI.

Fixes #41.
2026-11-03 14:35:42 -06:00
BFE EngineeringandClaude Opus 5.5 1e182a44e4 qemu: agent-test.sh counts a zombie child as killed (CI containers reap nothing)
ci / patches-apply (push) Successful in 1m1s
ci / test (pull_request) Successful in 9s
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 28s
ci / mcdc (push) Successful in 35s
ci / bench (push) Successful in 7s
ci / test (push) Successful in 12s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / badges (push) Skipped
ci / qemu-tools (push) Successful in 2m21s
ci / bench (pull_request) Successful in 7s
ci / mcdc (pull_request) Successful in 35s
ci / kernel-symbols (push) Successful in 4m10s
ci / quality (push) Successful in 29s
ci / prune-artifacts (pull_request) Skipped
ci / qemu-tools (pull_request) Successful in 2m6s
ci / patches-apply (pull_request) Successful in 1m8s
ci / badges (pull_request) Skipped
ci / kernel-symbols (pull_request) Successful in 3m49s
Run 10403: under a CI job container's non-reaping PID 1 the script child
the deadline killed stays a zombie, and kill -0 still found it. The check
now reads the process state from /proc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdKQBQkJkq4zE7iPFMkAhS
2026-10-31 18:49:45 -06:00
BFE EngineeringandClaude Opus 5.5 bbc91618f8 qemu: agent-test.sh passes shellcheck (SC2016 on the guest-side script)
ci / quality (push) Successful in 34s
ci / badges (push) Skipped
ci / bench (pull_request) Successful in 1m5s
ci / prune-artifacts (pull_request) Skipped
ci / quality (pull_request) Successful in 35s
ci / badges (pull_request) Skipped
ci / test (push) Successful in 8s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / mcdc (push) Successful in 34s
ci / bench (push) Successful in 5s
ci / qemu-tools (push) Failing after 50s
ci / patches-apply (push) Successful in 21s
ci / test (pull_request) Successful in 20s
ci / mcdc (pull_request) Successful in 55s
ci / qemu-tools (pull_request) Failing after 49s
ci / patches-apply (pull_request) Successful in 1m29s
ci / kernel-build (pull_request) Skipped
ci / kernel-symbols (push) Successful in 4m52s
ci / kernel-symbols (pull_request) Successful in 5m54s
The qemu-tools job (run 10385) failed shellcheck on the single-quoted
script the test hands the agent: its expansions belong to the agent's
shell, so the info finding is disabled on that line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdKQBQkJkq4zE7iPFMkAhS
2026-10-31 18:11:34 -06:00
BFE EngineeringandClaude Opus 5.5 579ac260ca qemu: rig agent, a framed guest shell on its own serial port (flare-edge M9 soak-lite)
ci / test (push) Successful in 10s
ci / patches-apply (push) Successful in 25s
ci / quality (push) Successful in 36s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 4m38s
ci / mcdc (push) Successful in 37s
ci / bench (push) Successful in 6s
ci / qemu-tools (push) Failing after 15s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / test (pull_request) Successful in 9s
ci / prune-artifacts (pull_request) Skipped
ci / mcdc (pull_request) Successful in 34s
ci / bench (pull_request) Successful in 20s
ci / kernel-build (pull_request) Skipped
ci / qemu-tools (pull_request) Failing after 57s
ci / patches-apply (pull_request) Successful in 1m16s
ci / kernel-symbols (pull_request) Successful in 2m14s
ci / badges (pull_request) Skipped
ci / quality (pull_request) Successful in 2m51s
run.sh --agent SOCK adds a third pci-serial after ctl and rs485 (their
ttyS order is unchanged) and warden.agent on the command line. Stage-2
init then runs warden_agent (rootfs/etc/warden-lib.sh) on that port with
echo off: `@run ID SECS B64` runs a script and answers <<BEGIN ID>>, the
base64 of its output and <<END ID RC>>; `@chunk` pieces get past the
4095-byte cooked line; a script past its deadline is killed with its
process group and answers 124 (the panel BusyBox has no timeout). It is
the guest channel of flare-edge tools/soak/rig-qemu.py, which needs bus
reads and writes, the clock and /proc inside the gate image. Rig rootfs
only: no panel image carries it.

Tests: qemu/tests/agent-test.sh (sh and busybox sh, in CI) and new
run-sh-args-test.sh cases (agent last, warden.agent only with the flag).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BdKQBQkJkq4zE7iPFMkAhS
2026-10-31 17:05:50 -06:00
noah 0232823855 Merge pull request 'qemu: wait for the UI test hook to answer a ping before the first override (flare-edge#2602)' (#39) from rb/ln-hook-ready into rebuild
ci / prune-artifacts (push) Skipped
ci / test (push) Successful in 9s
ci / mcdc (push) Successful in 17s
ci / bench (push) Successful in 11s
ci / kernel-build (push) Skipped
ci / patches-apply (push) Successful in 46s
ci / quality (push) Successful in 1m39s
ci / badges (push) Skipped
ci / qemu-tools (push) Successful in 3m42s
ci / kernel-symbols (push) Successful in 7m49s
2026-10-30 22:29:59 -06:00
BFE EngineeringandClaude Opus 5.5 61ecfac844 qemu: wait for the UI test hook to answer a ping before the first override (flare-edge#2602)
ci / quality (pull_request) Successful in 1m43s
ci / badges (pull_request) Skipped
ci / test (push) Successful in 11s
ci / prune-artifacts (push) Skipped
ci / quality (push) Successful in 26s
ci / qemu-tools (push) Successful in 4m32s
ci / kernel-symbols (push) Successful in 5m22s
ci / bench (push) Successful in 11s
ci / mcdc (push) Successful in 21s
ci / kernel-build (push) Skipped
ci / badges (push) Skipped
ci / patches-apply (push) Successful in 54s
ci / mcdc (pull_request) Successful in 18s
ci / bench (pull_request) Successful in 15s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / patches-apply (pull_request) Successful in 40s
ci / qemu-tools (pull_request) Successful in 2m3s
ci / kernel-symbols (pull_request) Successful in 3m59s
ci / test (pull_request) Successful in 26s
Right after boot the UI is still taking the broker's retained replay under
its per-tick bus budget, so a hook request queued behind it missed wthctl's
5 s bound and its own 5 s message expiry: the failsafe-ack flow's first
override was lost, or applied with its reply lost.

qmp.py now sends a run's first hook request only after the hook has
answered a ping. ping changes nothing, so it is retried while the bridge
reports no answer, up to HOOK_READY_S (90 s); the override itself goes out
once. A hook that never answers stays a fatal step with its own message.
Three offline tests in test_qmp_drive.py; removing the wait fails them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
2026-10-30 22:07:14 -06:00
noah ff3d1de088 Merge pull request 'qemu: let a job without the cross compiler use a prebuilt panel BusyBox (flare-edge#2210)' (#38) from rb/ln-rig-busybox-prebuilt into rebuild
ci / bench (push) Successful in 13s
ci / mcdc (push) Successful in 32s
ci / test (push) Successful in 9s
ci / kernel-build (push) Skipped
ci / kernel-symbols (push) Successful in 1m52s
ci / prune-artifacts (push) Skipped
ci / patches-apply (push) Successful in 32s
ci / quality (push) Successful in 1m13s
ci / badges (push) Skipped
ci / qemu-tools (push) Successful in 6m10s
2026-10-29 09:23:27 -06:00
BFE EngineeringandClaude Opus 5.5 8fc32976a5 qemu: clear the two shellcheck notes in the prebuilt BusyBox check (flare-edge#2210)
ci / mcdc (push) Successful in 34s
ci / kernel-build (push) Skipped
ci / quality (push) Successful in 46s
ci / bench (push) Successful in 12s
ci / test (push) Successful in 9s
ci / test (pull_request) Successful in 24s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / patches-apply (pull_request) Successful in 21s
ci / prune-artifacts (push) Skipped
ci / patches-apply (push) Successful in 41s
ci / bench (pull_request) Successful in 6s
ci / mcdc (pull_request) Successful in 29s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 1m48s
ci / qemu-tools (push) Successful in 5m39s
ci / quality (pull_request) Successful in 1m44s
ci / badges (pull_request) Skipped
ci / qemu-tools (pull_request) Successful in 3m42s
ci / kernel-symbols (pull_request) Successful in 6m55s
CI's shellcheck 0.9.0 failed qemu-tools on #38: SC2015 on the
`[ -f ] && [ = ] || { ... }` refusal in qemu_get_busybox (now an if), and
SC2012 on the `ls | head` that picks a patch to edit in
busybox-panel-test.sh (now find | sort | head). No behaviour change.

Refs flare-edge#2210

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
2026-10-29 09:10:37 -06:00
noah 0c98a6018f Merge pull request 'qemu: build the panel's own BusyBox for the rig (flare-edge#2210)' (#37) from rb/ln-rig-busybox into rebuild
ci / quality (push) Successful in 1m17s
ci / badges (push) Skipped
ci / test (push) Successful in 9s
ci / patches-apply (push) Successful in 47s
ci / bench (push) Successful in 9s
ci / mcdc (push) Successful in 19s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / qemu-tools (push) Successful in 4m4s
ci / kernel-symbols (push) Successful in 6m39s
2026-10-29 08:46:18 -06:00
BFE EngineeringandClaude Opus 5.5 820af4baaa qemu: let a job without the cross compiler use a prebuilt panel BusyBox (flare-edge#2210)
ci / test (push) Successful in 7s
ci / bench (push) Successful in 9s
ci / mcdc (push) Successful in 22s
ci / patches-apply (push) Successful in 50s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / qemu-tools (push) Failing after 27s
ci / quality (push) Successful in 1m17s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 7m7s
ci / test (pull_request) Successful in 9s
ci / bench (pull_request) Successful in 11s
ci / mcdc (pull_request) Successful in 13s
ci / patches-apply (pull_request) Successful in 54s
ci / qemu-tools (pull_request) Failing after 11s
ci / prune-artifacts (pull_request) Skipped
ci / kernel-build (pull_request) Skipped
ci / quality (pull_request) Successful in 1m27s
ci / badges (pull_request) Skipped
ci / kernel-symbols (pull_request) Successful in 4m10s
The flare-edge flow jobs get the rig BusyBox from the image build job's
artifact and have no cross compiler, so RIG_BUSYBOX=panel, which always ran
build-busybox.sh, could not be used there.

- qemu/lib.sh: qemu_busybox_panel_inputs, one sha256 over the source pin
  and every committed input under qemu/busybox/ (no compiler). With
  RIG_BUSYBOX=panel and BUSYBOX set, qemu_get_busybox takes that binary only
  when BUSYBOX.inputs equals the value for this tree; otherwise it fails
  closed. The source pin moved here from build-busybox.sh.
- qemu/build-busybox.sh writes <binary>.inputs next to the binary (also on
  the up-to-date path) and removes a stale one before a rebuild.
- busybox-panel-test.sh: missing, foreign and matching .inputs, a missing
  binary, and a config or patch edit changing the inputs.
- CI qemu-tools: a panel initramfs from the prebuilt binary.

Refs flare-edge#2210

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KerYPVh72hhNgKi3wS5ijG
2026-10-29 08:34:45 -06:00
18 changed files with 717 additions and 40 deletions
+14 -1
View File
@@ -170,6 +170,14 @@ jobs:
if command -v busybox >/dev/null; then
WARDEN_TEST_SH="busybox sh" bash qemu/tests/ctl-bridge-test.sh
fi
- name: rig agent runs framed scripts under a deadline (flare-edge M9 soak-lite)
# warden_agent against request lines on stdin; once more under
# busybox sh, the rig's own shell.
run: |
bash qemu/tests/agent-test.sh
if command -v busybox >/dev/null; then
WARDEN_TEST_SH="busybox sh" bash qemu/tests/agent-test.sh
fi
- name: rig init boots through the shipped init chain (flare-edge#2210)
# warden_init_chain against stub scripts and the warden.initchain
# wiring in sbin/init; once more under busybox sh, the rig's own shell.
@@ -229,7 +237,9 @@ jobs:
- name: QEMU busybox fetch regression tests
# Retry on a bad sha256, the cached copy, and a server that answers
# and then stalls (#1588), against local listeners: no network.
run: bash qemu/tests/busybox-fetch.sh
run: |
bash qemu/tests/busybox-fetch.sh
bash qemu/tests/busybox-source-mirror.sh
- name: unpack-buildroot regression tests
# Fresh unpack, leave-existing-tree-alone, and every refusal path
# (unpatched selectors, bad tarball, half-present tree, failed
@@ -274,6 +284,9 @@ jobs:
bash qemu/build-busybox.sh
QEMU_USER="qemu-arm" bash qemu/tests/busybox-panel-help.sh
RIG_BUSYBOX=panel bash qemu/mkinitramfs.sh
# A job without the cross compiler takes the binary as BUSYBOX,
# checked by its .inputs (flare-edge flow jobs).
RIG_BUSYBOX=panel BUSYBOX=qemu/out/busybox-armv7l-panel bash qemu/mkinitramfs.sh
kernel-symbols:
# The symbol gate (rebuild M0, kernel_symbols_exist): expand the real
@@ -372,7 +372,7 @@ index a99846f4e..4fc64f33d 100644
+ * by this point, so nothing puts it back underneath us.
+ */
+ if ((priv->cpll_hz % rate) && (priv->gpll_hz % rate)) {
+ ulong want = rate * 32;
+ ulong want = 900 * MHz;
+
+ if (want >= 300 * MHz && want <= 1200 * MHz &&
+ !rockchip_pll_set_rate(&rv1106_pll_clks[CPLL],
@@ -142,10 +142,10 @@ index 52cd612d1..a81071566 100644
obj-$(CONFIG_AUTOBOOT) += autoboot.o
diff --git a/sysdrv/source/uboot/u-boot/common/flare_ab.c b/sysdrv/source/uboot/u-boot/common/flare_ab.c
new file mode 100644
index 000000000..6a5a07e37
index 000000000..ec685444d
--- /dev/null
+++ b/sysdrv/source/uboot/u-boot/common/flare_ab.c
@@ -0,0 +1,642 @@
@@ -0,0 +1,709 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * flare-edge A/B slot boot for U-Boot proper.
@@ -175,6 +175,9 @@ index 000000000..6a5a07e37
+#include <part.h>
+#include <flare_ab.h>
+#include <android_avb/avb_ab_flow.h>
+#if defined(CONFIG_DRM_ROCKCHIP)
+#include <video_rockchip.h>
+#endif
+
+/*
+ * Per-power-session boot-attempt escalation (warehouse deployment).
@@ -215,6 +218,8 @@ index 000000000..6a5a07e37
+ */
+#define FLARE_AB_GLB_RST_ST 0xff3b0c04u /* CRU reset-status: 0 on POR */
+#define FLARE_AB_SESSION_REG 0xff020210u /* PMU GRF OS_REG4: attempt count */
+#define FLARE_AB_GLB_SRST_FST 0xff3b0c08u /* CRU glb_srst_fst: global reset */
+#define FLARE_AB_GLB_SRST_KEY 0xfdb9u /* poke value that starts the reset */
+/*
+ * Attempts on the selected committed slot before failing over to the other
+ * committed slot; the other slot then gets the same budget before recovery.
@@ -551,7 +556,12 @@ index 000000000..6a5a07e37
+ return other;
+ }
+
+ printf("FLARE-AB: both committed slots failed this power session, recovery\n");
+ if (slot_is_bootable(&ab_data.slots[other]) &&
+ ab_data.slots[other].successful_boot)
+ printf("FLARE-AB: both committed slots failed this power session, recovery\n");
+ else
+ printf("FLARE-AB: slot %s failed %d attempts this session, no committed alternative, recovery\n",
+ pref ? "_b" : "_a", FLARE_AB_SLOT_TRIES);
+ flare_ab_force_recovery = 1;
+ return pref;
+}
@@ -707,6 +717,58 @@ index 000000000..6a5a07e37
+ ab_data_write(dev_desc, &ab_data);
+}
+
+/*
+ * Escalating reset after a failed storage boot.
+ *
+ * Do not call do_reset() here. On this SoC the U-Boot WARM request
+ * (sysreset_rockchip, ARM32 path) writes CRU glb_srst_snd (0xeca8), which
+ * does not reset the chip (flare-edge#4554). The p54 splash stall cause is
+ * not established (flare-edge#4569). The reset that works is the CRU
+ * glb_srst_fst poke that the Linux restart path and the bench scenarios use
+ * (docs/boot-flow.md, "Watchdog / reset facts"). It is a warm reset, so
+ * glb_rst_st stays nonzero and OS_REG4 carries the attempt count.
+ */
+static void flare_ab_global_reset(void)
+{
+ flare_ab_reg_write(FLARE_AB_GLB_SRST_FST, FLARE_AB_GLB_SRST_KEY);
+ /*
+ * A taken reset never returns. Reaching the next statement means the
+ * chip did not reset, so give the reset time to land before the caller
+ * falls through to the USB download screens.
+ */
+ udelay(100000);
+}
+
+/*
+ * USB download: the terminal state of every failed boot with no slot or
+ * recovery FIT left (decision 2026-11-06, flare-edge#3118 cause 3).
+ *
+ * The sad-face screen is logo_recovery.bmp. rockchip_show_bmp() can fail
+ * (-ENOMEM when the heap cannot hold the decode scratch after the failed FIT
+ * loads), and do_download() ignores that return, so the splash would stay up
+ * with no serial line saying why. The draw is made here and its result is
+ * logged. do_download() paints the same image again as its first step.
+ *
+ * `download` serves rockusb and is not expected to return. If it does (the
+ * USB session ended), the screen is painted again and download is re-entered
+ * after a pause, so the unit stays USB-flashable and never stops silently at
+ * the splash. This function does not return.
+ */
+static void flare_ab_usb_download(void)
+{
+ int rc;
+
+ for (;;) {
+#if defined(CONFIG_DRM_ROCKCHIP)
+ rc = rockchip_show_bmp("logo_recovery.bmp");
+ printf("FLARE-AB: logo_recovery.bmp shown=%d\n", rc);
+#endif
+ rc = run_command("download", 0);
+ printf("FLARE-AB: download returned %d, re-entering\n", rc);
+ udelay(1000000);
+ }
+}
+
+void flare_ab_boot_failed(void)
+{
+ if (!flare_ab_enabled())
@@ -723,8 +785,7 @@ index 000000000..6a5a07e37
+ * it over the existing USB port.
+ */
+ printf("FLARE-AB: recovery FIT unbootable, entering USB download\n");
+ run_command("download", 0);
+ hang();
+ flare_ab_usb_download();
+ }
+
+ /*
@@ -740,8 +801,14 @@ index 000000000..6a5a07e37
+ * written to flash for a committed slot.
+ */
+ printf("FLARE-AB: slot boot failed, resetting\n");
+ do_reset(NULL, 0, 0, NULL);
+ hang();
+ flare_ab_global_reset();
+ /*
+ * The reset did not take. Do not spin silently at the splash: enter the
+ * same USB download screens as the recovery branch above (sad face and
+ * USB plug, logo_recovery.bmp), where a host can reflash the unit.
+ */
+ printf("FLARE-AB: reset did not take, entering USB download\n");
+ flare_ab_usb_download();
+}
+
+void flare_ab_update_root_partition(void)
@@ -841,7 +908,7 @@ index 182c03771..ad73662eb 100644
return -1;
diff --git a/sysdrv/source/uboot/u-boot/include/flare_ab.h b/sysdrv/source/uboot/u-boot/include/flare_ab.h
new file mode 100644
index 000000000..d009525e0
index 000000000..6e51b405e
--- /dev/null
+++ b/sysdrv/source/uboot/u-boot/include/flare_ab.h
@@ -0,0 +1,73 @@
@@ -857,7 +924,7 @@ index 000000000..d009525e0
+ * per-attempt tries decrement, and fallback to the recovery FIT when
+ * both slots are exhausted.
+ *
+ * Linux-side counterpart: flared's slotctl module — the ONLY writer of
+ * Linux-side counterpart: flared's slotctl module, the ONLY writer of
+ * this metadata from userspace (CI-enforced).
+ */
+
@@ -891,7 +958,7 @@ index 000000000..d009525e0
+/*
+ * One boot attempt against the selected slot: decrement tries_remaining
+ * iff the slot is not yet successful (single-sector write, and no write
+ * at all in the successful steady state — spec fault 14 by construction).
+ * at all in the successful steady state, spec fault 14 by construction).
+ * No-op in recovery fallback mode or on a non-A/B layout.
+ */
+void flare_ab_boot_attempt(void);
+7 -2
View File
@@ -82,7 +82,11 @@ With a test-flavor `warden-ui` and `wthctl` (flare-edge `tools/wthctl.c`, the
test hook client) in the payload as well, a flow's `override` step pins a
state document inside the UI: qmp.py hands the request to the control bridge
(`@hookdoc` pieces, then `@hook override`), which sends it to `test/req/ui`
as bus user `testhook` and answers the hook's reply.
as bus user `testhook` and answers the hook's reply. The run's first hook
request waits until the hook answers a `ping` (retried while the bridge
reports no answer, up to `HOOK_READY_S`): right after boot the UI is still
taking the broker's retained replay, and an override sent then was lost
(flare-edge #2602).
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
@@ -137,11 +141,12 @@ All take the virt-fragment `<zImage>`; `FLARE_EDGE=<checkout>` where noted.
| `rootfs-overlay.sh` | - | offline, no VM: `mkimage.sh`'s `ROOTFS_OVERLAY` hook lays a directory of panel files (flare-edge's S03warden-accounts, S99lvgl, warden-ui-run) over the rootfs of both slots with their modes kept, beside the skeleton's own files; without it there is no `/etc/init.d`; an overlay that is not a directory, names anything but `etc/` and `usr/` at its top, or holds a symlink fails closed and writes no image; `ui-drive.sh --init-chain` refuses a missing directory or one without `etc/init.d/S99lvgl` before boot |
| `init-chain-test.sh` | - | offline, no VM: `warden_init_chain` (rootfs/etc/warden-lib.sh) starts the executable `S<NN>*` scripts of a number range in name order, names a failing one and goes on, and counts them; `warden_rig_bus_owners` hands a bus credential to its account only when the rootfs has it; sbin/init runs S00-S09 before the bus and S10-S99 instead of the direct UI start on a `warden.initchain` boot (flare-edge #2210) |
| `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 |
| `busybox-panel-test.sh` | - | offline, no VM: the panel BusyBox inputs (qemu/busybox/). panel.config carries every setting of the image's applet patch, rig.fragment changes only STATIC, USE_BB_PWD_GRP and USE_BB_SHADOW, a Kconfig rewrite of any setting and an applet the panel lacks fail the build, applets.txt and help.txt agree, and RIG_BUSYBOX refuses an unknown value or a prebuilt `BUSYBOX` (flare-edge#2210) |
| `busybox-panel-test.sh` | - | offline, no VM: the panel BusyBox inputs (qemu/busybox/). panel.config carries every setting of the image's applet patch, rig.fragment changes only STATIC, USE_BB_PWD_GRP and USE_BB_SHADOW, a Kconfig rewrite of any setting and an applet the panel lacks fail the build, applets.txt and help.txt agree, and RIG_BUSYBOX refuses an unknown value, and accepts a prebuilt panel `BUSYBOX` only when its `.inputs` match this tree (flare-edge#2210) |
| `busybox-panel-help.sh [BIN]` | an ARM runner (binfmt or `QEMU_USER=qemu-arm`) | the built panel BusyBox against the bench capture: its applet list and every applet's `--help` equal the panel's own binary's. CI runs it in qemu-tools after `build-busybox.sh` |
| `console-shell-test.sh` | - | offline, no VM: `warden_console_shell` (warden.shell) runs `setsid cttyhack sh` where cttyhack exists, else `setsid -c sh` on the console tty read from sysfs (the panel BusyBox has no cttyhack), else a plain sh. CI runs it under bash's `sh` and busybox `sh` |
| `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). A fake `wthctl` stands in for the hook client behind `@hookdoc`/`@hook` (flare-edge #2054): the pieces join into one request whose args are used once, only plain words reach the client, and a missing client or a request with no reply answers a `bridge:` line. CI runs it under bash's `sh` and busybox `sh` |
| `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) |
| `agent-test.sh` | - | offline, no VM: the rig agent (`warden_agent` in rootfs/etc/warden-lib.sh, armed by `run.sh --agent` and `warden.agent`) answers `@run ID SECS B64` with `<<BEGIN ID>>`, the base64 of the script's output and `<<END ID RC>>`; `@chunk` pieces join into one script used once; a script past its deadline is killed with its process group and answers 124; a malformed request answers one `<<ERR ...>>` line and runs nothing; init puts the agent's port after ctl and RS485. It is the guest shell of flare-edge `tools/soak/rig-qemu.py` (M9 soak-lite). CI runs it under bash's `sh` and busybox `sh` |
| watchdog (`run.sh --watchdog`) | - | arm `/dev/watchdog`, don't pet: the VM resets ~30 s later (verified) |
Scenario fine print:
+14 -11
View File
@@ -6,7 +6,9 @@
#
# Env:
# OUT output dir (default qemu/out); the binary lands at
# $OUT/busybox-armv7l-panel, its input key next to it
# $OUT/busybox-armv7l-panel, its rebuild key (.key) and its
# source inputs (.inputs, see qemu_busybox_panel_inputs in
# lib.sh) next to it
# CROSS_COMPILE cross toolchain prefix (default arm-linux-gnueabihf-)
# BB_SRC_TARBALL a local busybox-$BB_SRC_VER.tar.bz2 (skips the download;
# still verified against BB_SRC_SHA256)
@@ -29,12 +31,8 @@ set -euo pipefail
QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BB_DIR="$QEMU_DIR/busybox"
BB_SRC_VER=1.37.0
BB_SRC_URL="https://busybox.net/downloads/busybox-${BB_SRC_VER}.tar.bz2"
# From https://busybox.net/downloads/busybox-1.37.0.tar.bz2.sha256, the same
# pin as Buildroot 2025.02.8 package/busybox/busybox.hash.
BB_SRC_SHA256=3311dff32e746499f4df0d5df04d7eb396382d7e108bb9250e7b519b837043a4
# The source pin (BB_SRC_VER, BB_SRC_URL, BB_SRC_SHA256) lives in lib.sh,
# beside qemu_busybox_panel_inputs, which a prebuilt binary is checked by.
# shellcheck source=qemu/lib.sh disable=SC1091
. "$QEMU_DIR/lib.sh"
@@ -95,9 +93,7 @@ bb_check_applets() {
bb_input_key() {
local cc="$1"
{
echo "busybox $BB_SRC_VER $BB_SRC_SHA256"
sha256sum "$BB_DIR/panel.config" "$BB_DIR/rig.fragment" "$BB_DIR/applets.txt" \
"$BB_DIR"/patches/*.patch | awk '{print $1}'
qemu_busybox_panel_inputs
echo "$cc"
"${cc}gcc" --version | head -n 1
} | sha256sum | awk '{print $1}'
@@ -117,12 +113,16 @@ bb_main() {
mkdir -p "$out"
key="$(bb_input_key "$cc")"
if [ -f "$bin" ] && [ "$(cat "$bin.key" 2>/dev/null)" = "$key" ]; then
qemu_busybox_panel_inputs > "$bin.inputs"
qemu_log "panel busybox up to date ($bin)"
return
fi
# A stale .inputs must never vouch for a binary while it is rebuilt.
rm -f "$bin.inputs"
tar="${BB_SRC_TARBALL:-$out/busybox-${BB_SRC_VER}.tar.bz2}"
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source"
qemu_fetch_verified "$BB_SRC_URL" "$BB_SRC_SHA256" "$tar" "busybox ${BB_SRC_VER} source" \
"$BB_SRC_MIRROR_URL"
scratch="$(mktemp -d "${TMPDIR:-/tmp}/warden-busybox.XXXXXX")"
# Expanded now on purpose: the trap must remove this run's directory.
@@ -171,6 +171,9 @@ bb_main() {
install -m 0755 "$src/busybox" "$bin.tmp"
mv -f "$bin.tmp" "$bin"
printf '%s\n' "$key" > "$bin.key"
# For a job without the cross compiler: qemu_get_busybox accepts this
# binary as BUSYBOX under RIG_BUSYBOX=panel when the inputs match its tree.
qemu_busybox_panel_inputs > "$bin.inputs"
qemu_log "panel busybox: $bin ($(sha256sum "$bin" | awk '{print $1}'))"
}
+8
View File
@@ -26,3 +26,11 @@ The inputs are pinned (source tarball sha256, these files); the output is not,
because each host's compiler gives a different binary. The cache key in
`$OUT/busybox-armv7l-panel.key` covers the tarball, these files and the
compiler version.
A job without the cross compiler (a flare-edge flow job, given the binary its
image build job made) sets `RIG_BUSYBOX=panel BUSYBOX=<binary>`. The build
writes `<binary>.inputs` next to it: one sha256 over the source pin and these
files, without the compiler (`qemu_busybox_panel_inputs` in qemu/lib.sh).
`qemu_get_busybox` takes the prebuilt binary only when that file equals the
value for its own tree, so a binary built from another config is refused
rather than booted.
+50 -7
View File
@@ -4,15 +4,27 @@
BB_VER=1.31.0
BB_URL="https://busybox.net/downloads/binaries/${BB_VER}-defconfig-multiarch-musl/busybox-armv7l"
# The panel BusyBox source (RIG_BUSYBOX=panel, qemu/build-busybox.sh). From
# https://busybox.net/downloads/busybox-1.37.0.tar.bz2.sha256, the same pin as
# Buildroot 2025.02.8 package/busybox/busybox.hash.
BB_SRC_VER=1.37.0
# Read by build-busybox.sh, which sources this file.
# shellcheck disable=SC2034
BB_SRC_URL="https://busybox.net/downloads/busybox-${BB_SRC_VER}.tar.bz2"
# Buildroot mirrors this exact pinned release; verification is unchanged.
# shellcheck disable=SC2034
BB_SRC_MIRROR_URL="https://sources.buildroot.net/busybox/busybox-${BB_SRC_VER}.tar.bz2"
BB_SRC_SHA256=3311dff32e746499f4df0d5df04d7eb396382d7e108bb9250e7b519b837043a4
qemu_log() { printf '\033[36m== %s\033[0m\n' "$*"; }
# Download URL to DEST and verify it against the sha256 WANT. A DEST that
# already matches is kept. FAILS CLOSED: three bounded attempts, then exit 1;
# a mismatching download never lands at DEST.
# Usage: qemu_fetch_verified URL WANT DEST LABEL
# Usage: qemu_fetch_verified URL WANT DEST LABEL [MIRROR_URL]
qemu_fetch_verified() {
local url="$1" want="$2" dest="$3" label="$4" got
local mirror="${5:-}"
if [ -f "$dest" ]; then
got="$(sha256sum "$dest" | awk '{print $1}')"
if [ "$want" = "$got" ]; then
@@ -32,6 +44,9 @@ qemu_fetch_verified() {
local attempt tmp="${dest}.download.$$"
rm -f "$tmp"
for attempt in 1 2 3; do
if [ "$attempt" -gt 1 ] && [ -n "$mirror" ]; then
url="$mirror"
fi
qemu_log "downloading $url (attempt $attempt/3)"
if curl --retry 1 --retry-delay "$delay" --retry-connrefused \
--connect-timeout "$stall" --speed-limit 1024 --speed-time "$stall" \
@@ -50,6 +65,19 @@ qemu_fetch_verified() {
exit 1
}
# The source inputs of the panel BusyBox, as one sha256: the pinned source
# tarball and every committed file under qemu/busybox/ the build reads. The
# compiler is not part of it (build-busybox.sh keys its rebuild on that too),
# so a job without the cross compiler can check a binary another job built.
# build-busybox.sh writes it next to the binary as <binary>.inputs.
qemu_busybox_panel_inputs() {
local d="$QEMU_DIR/busybox"
{
echo "busybox $BB_SRC_VER $BB_SRC_SHA256"
(cd "$d" && sha256sum panel.config rig.fragment applets.txt patches/*.patch)
} | sha256sum | awk '{print $1}'
}
# Provide the rig's static armv7 busybox and set $BB to its path.
#
# RIG_BUSYBOX picks which one (flare-edge#2210):
@@ -58,20 +86,35 @@ qemu_fetch_verified() {
# verified against qemu/busybox.sha256
# panel the image's BusyBox version and applet config, built
# from source by qemu/build-busybox.sh (needs a cross
# compiler; checked by its applet list, see there)
# compiler; checked by its applet list, see there).
# With $BUSYBOX set, that prebuilt panel binary is used
# instead (a job without the cross compiler, given the
# binary an earlier build job made): it is accepted only
# when its $BUSYBOX.inputs, written by build-busybox.sh,
# equals qemu_busybox_panel_inputs of this tree, so a
# binary built from other config files is refused.
# FAILS CLOSED: a missing pin refuses to build, never silently skips
# verification, mirroring build/build-kernel.sh's tarball handling; an
# unknown RIG_BUSYBOX, or $BUSYBOX with the panel build, is refused.
# unknown RIG_BUSYBOX, or a prebuilt panel binary without matching inputs,
# is refused.
qemu_get_busybox() {
local out="${OUT:-$QEMU_DIR/out}"
mkdir -p "$out"
case "${RIG_BUSYBOX:-multiarch}" in
multiarch) ;;
panel)
[ -z "${BUSYBOX:-}" ] || {
echo "FATAL: BUSYBOX=$BUSYBOX names a prebuilt binary; RIG_BUSYBOX=panel builds its own (unset one of them)" >&2
exit 1
}
if [ -n "${BUSYBOX:-}" ]; then
local want got
want="$(qemu_busybox_panel_inputs)"
got="$(cat "$BUSYBOX.inputs" 2>/dev/null || true)"
if [ ! -f "$BUSYBOX" ] || [ "$got" != "$want" ]; then
echo "FATAL: BUSYBOX=$BUSYBOX is not a panel BusyBox built from this tree's qemu/busybox/ ($BUSYBOX.inputs '${got:-missing}', want '$want'): run qemu/build-busybox.sh" >&2
exit 1
fi
BB="$BUSYBOX"
qemu_log "panel busybox: prebuilt $BB (inputs $want)"
return
fi
OUT="$out" bash "$QEMU_DIR/build-busybox.sh"
BB="$out/busybox-armv7l-panel"
return
+2 -1
View File
@@ -15,7 +15,8 @@
# flare-edge build's rootfs.img/oem.img matched pair) into slot A instead of
# the busybox skeleton; slot B keeps the skeleton as a known-good fallback.
# Env:
# BUSYBOX path to a local busybox binary (skips the download; still verified)
# BUSYBOX path to a local busybox binary (skips the download; still verified;
# with RIG_BUSYBOX=panel a prebuilt panel binary, checked by its .inputs)
# RIG_BUSYBOX multiarch (default) or panel: the image's own BusyBox, built by
# qemu/build-busybox.sh (see qemu/busybox/README.md)
# OUT output dir (default: qemu/out); image at $OUT/disk.img
+2 -1
View File
@@ -4,7 +4,8 @@
# see qemu/lib.sh).
#
# Env:
# BUSYBOX path to a local busybox binary (skips the download; still verified)
# BUSYBOX path to a local busybox binary (skips the download; still verified;
# with RIG_BUSYBOX=panel a prebuilt panel binary, checked by its .inputs)
# RIG_BUSYBOX multiarch (default) or panel: the image's own BusyBox, built by
# qemu/build-busybox.sh (see qemu/busybox/README.md)
# OUT output dir (default: qemu/out); initramfs at $OUT/initramfs.cpio.gz
+110
View File
@@ -387,3 +387,113 @@ warden_init_chain() {
done
echo "$_wic_ran"
}
# The rig agent (flare-edge M9 soak-lite, d10 6.5): a shell inside the guest
# for a host-side rig that must read state and change it (tools/soak/rig-qemu.py:
# bus reads and writes, the clock, /proc for metrics). /sbin/init runs it on
# its own pci-serial port, only on a boot with warden.agent on the command
# line (run.sh --agent). It is part of the rig rootfs, which no panel image
# carries; the flow channels (ctl bridge, test hook) are untouched by it.
#
# One request per line on stdin, every answer framed so the host never needs
# a timeout to know a reply is complete:
#
# @ping -> <<PONG>>
# @chunk ID B64 -> <<OK ID BYTES>> appends B64 to ID's script text
# @run ID SECS [B64] -> <<BEGIN ID>>, the base64 of the script's stdout
# and stderr, <<END ID RC>>
# anything else -> <<ERR reason>>
#
# The script is the base64 text of the @chunk lines for ID, then the @run
# line's own B64, decoded and run by sh with stdin from /dev/null. The agent
# port is a tty in cooked mode, which cuts a line at 4095 bytes, hence the
# chunks. ID is [A-Za-z0-9_-] (1 to 32 characters), SECS 1 to 3600. A script
# still running after SECS seconds is killed with its whole process group and
# answers RC 124, as timeout(1) does; the panel BusyBox has no timeout applet.
# WARDEN_AGENT_DIR exists for the host test only.
warden_agent() {
_wa_dir="${WARDEN_AGENT_DIR:-/tmp/warden-agent}"
mkdir -p "$_wa_dir"
while IFS= read -r _wa_line; do
# A cooked tty may hand the line over with a trailing CR.
_wa_line="${_wa_line%"$(printf '\r')"}"
[ -n "$_wa_line" ] || continue
set -f
# shellcheck disable=SC2086 # split into words on purpose, globbing off
set -- $_wa_line
set +f
case "$1" in
@ping) echo "<<PONG>>" ;;
@chunk)
if [ "$#" -ne 3 ] || ! _wa_id_ok "$2" || ! _wa_b64_ok "$3"; then
echo "<<ERR bad chunk>>"
continue
fi
printf '%s' "$3" >> "$_wa_dir/$2.b64"
echo "<<OK $2 $(wc -c < "$_wa_dir/$2.b64" | tr -d ' ')>>"
;;
@run)
if [ "$#" -lt 3 ] || [ "$#" -gt 4 ] || ! _wa_id_ok "$2" ||
! _wa_secs_ok "$3" || { [ "$#" -eq 4 ] && ! _wa_b64_ok "$4"; }; then
echo "<<ERR bad run>>"
continue
fi
[ "$#" -eq 4 ] && printf '%s' "$4" >> "$_wa_dir/$2.b64"
_wa_run "$2" "$3"
;;
*) echo "<<ERR unknown request>>" ;;
esac
done
}
_wa_id_ok() {
case "$1" in ""|*[!A-Za-z0-9_-]*) return 1 ;; esac
[ "${#1}" -le 32 ]
}
_wa_b64_ok() {
case "$1" in ""|*[!A-Za-z0-9+/=]*) return 1 ;; esac
return 0
}
_wa_secs_ok() {
case "$1" in ""|*[!0-9]*) return 1 ;; esac
[ "${#1}" -le 4 ] && [ "$1" -ge 1 ] && [ "$1" -le 3600 ]
}
# _wa_run ID SECS: decode, run under the deadline, answer, forget ID.
_wa_run() {
_wr_b64="$_wa_dir/$1.b64"
_wr_sh="$_wa_dir/$1.sh"
_wr_out="$_wa_dir/$1.out"
if [ ! -s "$_wr_b64" ] || ! base64 -d < "$_wr_b64" > "$_wr_sh" 2>/dev/null ||
[ ! -s "$_wr_sh" ]; then
rm -f "$_wr_b64" "$_wr_sh"
echo "<<ERR bad script $1>>"
return 0
fi
rm -f "$_wr_b64"
# setsid: the script leads its own process group, so a timeout kills
# every process it started, not only its shell.
setsid sh "$_wr_sh" < /dev/null > "$_wr_out" 2>&1 &
_wr_pid=$!
_wr_n=0
_wr_limit=$(($2 * 10))
_wr_late=0
while kill -0 "$_wr_pid" 2>/dev/null; do
if [ "$_wr_n" -ge "$_wr_limit" ]; then
kill -KILL "-$_wr_pid" 2>/dev/null || kill -KILL "$_wr_pid" 2>/dev/null
_wr_late=1
break
fi
sleep 0.1
_wr_n=$((_wr_n + 1))
done
wait "$_wr_pid" 2>/dev/null
_wr_rc=$?
[ "$_wr_late" = 1 ] && _wr_rc=124
echo "<<BEGIN $1>>"
[ -s "$_wr_out" ] && base64 < "$_wr_out"
echo "<<END $1 $_wr_rc>>"
rm -f "$_wr_sh" "$_wr_out"
}
+22
View File
@@ -229,6 +229,28 @@ if grep -qw warden.ctl /proc/cmdline && [ -c /dev/ttyS0 ]; then
) &
fi
# Rig agent (run.sh --agent, warden.agent on the command line): a shell for a
# host-side rig that reads and changes guest state, such as the QEMU soak rig
# (flare-edge tools/soak/rig-qemu.py). Its pci-serial port comes after the
# ctl port (when there is one) and the always-present RS485 port, so it is
# ttyS2 with warden.ctl and ttyS1 without; the ctl/RS485 order above is
# unchanged. Echo is turned off so the host reads only the agent's frames.
# The protocol is warden_agent (/etc/warden-lib.sh). Rig rootfs only: no
# panel image carries it.
if grep -qw warden.agent /proc/cmdline; then
if grep -qw warden.ctl /proc/cmdline; then agent=/dev/ttyS2; else agent=/dev/ttyS1; fi
if [ -c "$agent" ]; then
echo "init: rig agent on $agent"
(
exec 4<> "$agent"
stty -echo <&4 2>/dev/null || echo "init: rig agent: stty -echo failed"
warden_agent <&4 >&4 2>/dev/null
) &
else
echo "init: rig agent: $agent missing (needs the virt.fragment kernel)"
fi
fi
if grep -qw warden.shell /proc/cmdline; then
echo "warden.shell: interactive shell (exit powers off)"
warden_console_shell
+14 -1
View File
@@ -17,6 +17,10 @@
# --ctl SOCK unix socket to warden-ui's debug channel (nav/page/hit),
# bridged by init from a pci-serial port; the rig-side
# twin of tools/warden-ctl over SSH on a real panel
# --agent SOCK unix socket to the rig agent (warden_agent in
# rootfs/etc/warden-lib.sh): a guest shell for host-side
# rigs such as flare-edge tools/soak/rig-qemu.py; a third
# pci-serial after ctl and rs485, so their order holds
# --watchdog add i6300esb watchdog, reset on expiry (fragment kernel)
# --qmp SOCK QMP unix socket (screendump, input-send-event, quit)
# --display MODE off (default, -nographic) | on (gtk window) | headless
@@ -38,7 +42,7 @@ QEMU_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OUT="${OUT:-$QEMU_DIR/out}"
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
RTC="" RS485="" CTL="" AGENT="" WATCHDOG=0 QMP="" DISPLAY_MODE="off" SHELL_FLAG=0 ALLOW_APPLY=0
SSH_PORT=2222 HTTP_PORT=8080 API_PORT=28443
EXTRA=()
EXTRA_APPEND=""
@@ -53,6 +57,7 @@ while [ $# -gt 0 ]; do
--rtc) RTC="${2:?}"; shift 2 ;;
--rs485) RS485="${2:?}"; shift 2 ;;
--ctl) CTL="${2:?}"; shift 2 ;;
--agent) AGENT="${2:?}"; shift 2 ;;
--watchdog) WATCHDOG=1; shift ;;
--qmp) QMP="${2:?}"; shift 2 ;;
--display) DISPLAY_MODE="${2:?}"; shift 2 ;;
@@ -143,6 +148,14 @@ if [ -n "$RS485" ]; then
else
ARGS+=( -chardev "null,id=rs485" -device "pci-serial,chardev=rs485" )
fi
# The rig agent comes LAST of the pci-serial ports, so ctl stays ttyS0 and
# rs485 stays where init looks for it; init finds the agent at ttyS1 (no
# ctl) or ttyS2 (with ctl), and only with warden.agent on the cmdline.
if [ -n "$AGENT" ]; then
APPEND="$APPEND warden.agent"
ARGS+=( -chardev "socket,id=agent,path=$AGENT,server=on,wait=off"
-device "pci-serial,chardev=agent" )
fi
[ -n "$QMP" ] && ARGS+=( -qmp "unix:$QMP,server=on,wait=off" )
case "$DISPLAY_MODE" in
+121
View File
@@ -0,0 +1,121 @@
#!/usr/bin/env bash
# Host test for the rig agent, warden_agent in qemu/rootfs/etc/warden-lib.sh
# (flare-edge M9 soak-lite). Feeds request lines on stdin, as the host rig
# does over the agent's serial port, and checks the framed answers: a script
# runs and answers its output in base64 with its exit code, chunks join into
# one script, a script past its deadline is killed with its children and
# answers 124, and malformed requests answer one <<ERR ...>> line and run
# nothing.
set -uo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
LIB="$HERE/../rootfs/etc/warden-lib.sh"
# Unquoted where it runs: WARDEN_TEST_SH may be "busybox sh", the rig's shell.
SH="${WARDEN_TEST_SH:-sh}"
WORK="$(mktemp -d)" || exit 1
trap 'rm -rf "$WORK"' 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
}
b64() { printf '%s' "$1" | base64 -w0; }
agent() { # agent <name> <lines...>: run the agent over the lines
local name="$1"
shift
# $SH unquoted (it may be "busybox sh"); the quoted script is meant literally.
# shellcheck disable=SC2086,SC2016
printf '%s\n' "$@" |
env WARDEN_AGENT_DIR="$WORK/agent-$name" \
$SH -c '. "$1"; warden_agent' sh "$LIB" > "$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; }
}
# The body between <<BEGIN ID>> and <<END ID ...>>, decoded.
body() { # body <file> <id>
awk -v b="<<BEGIN $2>>" -v e="<<END $2 " '$0 == b {on = 1; next} index($0, e) == 1 {on = 0} on' "$1" |
base64 -d
}
agent basic @ping "@run a1 10 $(b64 'echo hello; echo oops >&2; exit 3')"
check "ping and a run answer framed lines" \
grep -qx '<<PONG>>' "$WORK/basic.out"
check "the run ends with its exit code" grep -qx '<<END a1 3>>' "$WORK/basic.out"
check "stdout and stderr come back in base64" \
same <(body "$WORK/basic.out" a1) hello oops
# Chunks: the script text arrives in pieces, then @run with no B64 of its own
# and once more with a last piece on the run line.
# shellcheck disable=SC2016 # the guest's shell expands it, not this one
script='i=0; while [ $i -lt 3 ]; do echo line$i; i=$((i + 1)); done'
whole="$(b64 "$script")"
agent chunks "@chunk c1 ${whole:0:20}" "@chunk c1 ${whole:20}" "@run c1 10" \
"@chunk c2 ${whole:0:12}" "@run c2 10 ${whole:12}"
check "chunks acknowledge the bytes so far" \
grep -qx "<<OK c1 20>>" "$WORK/chunks.out"
check "chunked script runs whole" same <(body "$WORK/chunks.out" c1) line0 line1 line2
check "a last piece on the run line joins the chunks" \
same <(body "$WORK/chunks.out" c2) line0 line1 line2
check "a script's text is used once" \
test -z "$(ls -A "$WORK/agent-chunks" 2>/dev/null)"
# Deadline: the script and the child it started both die; RC 124.
start=$(date +%s)
agent late "@run t1 1 $(b64 "sleep 30 & echo \$! > $WORK/child.pid; sleep 30")" @ping
took=$(( $(date +%s) - start ))
check "a script past its deadline answers 124" grep -qx '<<END t1 124>>' "$WORK/late.out"
check "the deadline holds (took ${took}s)" test "$took" -le 5
child="$(cat "$WORK/child.pid" 2>/dev/null)"
# Gone or a zombie: in a CI job container PID 1 reaps nothing, so a killed
# orphan stays a zombie that kill -0 still finds.
gone() { [ ! -r "/proc/$1/stat" ] || [ "$(sed 's/.*) //' "/proc/$1/stat" | cut -d' ' -f1)" = Z ]; }
check "the script's child is killed too" bash -c "[ -n '$child' ] && $(declare -f gone); sleep 0.5; gone '$child'"
check "the agent answers after a timeout" grep -qx '<<PONG>>' "$WORK/late.out"
# Malformed requests: one error line each, nothing runs.
touch_b64="$(b64 "touch $WORK/ran")"
agent bad "@run bad/id 10 $touch_b64" "@run b1 0 $touch_b64" "@run b1 99999 $touch_b64" \
"@run b1 10 not*base64" "@chunk b2" "@run b3 10" "frobnicate" "@run b4 10 $(b64 'x') extra" \
"@run b5 10 ===="
check "malformed requests answer one error line each" \
same "$WORK/bad.out" '<<ERR bad run>>' '<<ERR bad run>>' '<<ERR bad run>>' '<<ERR bad run>>' \
'<<ERR bad chunk>>' '<<ERR bad script b3>>' '<<ERR unknown request>>' '<<ERR bad run>>' \
'<<ERR bad script b5>>'
check "no malformed request ran anything" test ! -e "$WORK/ran"
# A trailing CR (a cooked tty line) is not part of the last word.
agent cr "$(printf '@ping\r')" "$(printf '@run r1 10 %s\r' "$(b64 'echo ok')")"
check "a trailing CR is ignored" bash -c "grep -qx '<<PONG>>' '$WORK/cr.out' && grep -qx '<<END r1 0>>' '$WORK/cr.out'"
# A request with glob characters in a word does not expand them.
agent glob "@run * 10 $(b64 'echo no')"
check "a glob word is not expanded" same "$WORK/glob.out" '<<ERR bad run>>'
# sbin/init arms the agent only on warden.agent, on the port after ctl and
# RS485 (ttyS2 with warden.ctl, ttyS1 without), with echo off.
INIT="$HERE/../rootfs/sbin/init"
check "init arms the agent only with warden.agent" grep -q 'grep -qw warden.agent /proc/cmdline' "$INIT"
check "init picks ttyS2 with ctl and ttyS1 without" \
grep -q 'if grep -qw warden.ctl /proc/cmdline; then agent=/dev/ttyS2; else agent=/dev/ttyS1; fi' "$INIT"
check "init turns echo off on the agent port" grep -q 'stty -echo <&4' "$INIT"
if [ "$FAIL" = 0 ]; then
echo "agent tests: OK ($CHECKS checks)"
else
echo "agent tests: FAILED"
exit 1
fi
+47 -3
View File
@@ -108,10 +108,54 @@ if ! RIG_BUSYBOX=bogus run_get && grep -q 'RIG_BUSYBOX must be multiarch or pane
else
fail "an unknown RIG_BUSYBOX was accepted"
fi
if ! RIG_BUSYBOX=panel BUSYBOX=/nonexistent run_get && grep -q 'names a prebuilt binary' "$SCRATCH/get.err"; then
pass "RIG_BUSYBOX=panel with BUSYBOX set is refused"
# 7b. A prebuilt panel binary (a flow job without the cross compiler) is taken
# only with a .inputs equal to this tree's qemu_busybox_panel_inputs.
inputs="$(QEMU_DIR="$QEMU_DIR" qemu_busybox_panel_inputs)"
if [[ "$inputs" =~ ^[0-9a-f]{64}$ ]]; then
pass "qemu_busybox_panel_inputs is one sha256"
else
fail "RIG_BUSYBOX=panel accepted a prebuilt BUSYBOX"
fail "qemu_busybox_panel_inputs gave '$inputs'"
fi
mkdir -p "$SCRATCH/pre"
printf 'stand-in\n' > "$SCRATCH/pre/bb"
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err" &&
grep -q "inputs 'missing'" "$SCRATCH/get.err"; then
pass "a prebuilt panel BUSYBOX without .inputs is refused"
else
fail "a prebuilt panel BUSYBOX without .inputs was accepted"
fi
printf '%s\n' "$(printf '%s' "$inputs" | tr '0-9a-f' '1-9a-f0')" > "$SCRATCH/pre/bb.inputs"
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err"; then
pass "a prebuilt panel BUSYBOX built from other inputs is refused"
else
fail "a prebuilt panel BUSYBOX with other inputs was accepted"
fi
printf '%s\n' "$inputs" > "$SCRATCH/pre/bb.inputs"
got_bb="$(RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/bb" QEMU_DIR="$QEMU_DIR" OUT="$SCRATCH/out" \
bash -c '. "$QEMU_DIR/lib.sh"; set -euo pipefail; qemu_get_busybox >/dev/null; printf %s "$BB"' 2>"$SCRATCH/get.err")"
if [ "$got_bb" = "$SCRATCH/pre/bb" ] && [ ! -e "$SCRATCH/out/busybox-armv7l-panel" ]; then
pass "a prebuilt panel BUSYBOX with matching .inputs is used as is, nothing built"
else
fail "a prebuilt panel BUSYBOX with matching .inputs was not used (BB='$got_bb': $(cat "$SCRATCH/get.err"))"
fi
if ! RIG_BUSYBOX=panel BUSYBOX="$SCRATCH/pre/none" run_get && grep -q 'is not a panel BusyBox built from' "$SCRATCH/get.err"; then
pass "a prebuilt panel BUSYBOX that does not exist is refused"
else
fail "a missing prebuilt panel BUSYBOX was accepted"
fi
# Every committed input file is in the inputs hash: a config edit changes it.
mkdir -p "$SCRATCH/qcopy"
cp -a "$QEMU_DIR/busybox" "$SCRATCH/qcopy/"
printf '# CONFIG_TIMEOUT is not set\n' >> "$SCRATCH/qcopy/busybox/panel.config"
other="$(QEMU_DIR="$SCRATCH/qcopy" qemu_busybox_panel_inputs)"
first_patch="$(find "$SCRATCH/qcopy/busybox/patches" -maxdepth 1 -type f -name '*.patch' | sort | head -n 1)"
printf 'x\n' >> "$first_patch"
other2="$(QEMU_DIR="$SCRATCH/qcopy" qemu_busybox_panel_inputs)"
if [ "$other" != "$inputs" ] && [ "$other2" != "$other" ]; then
pass "a panel.config or patch edit changes qemu_busybox_panel_inputs"
else
fail "qemu_busybox_panel_inputs ignored a panel.config or patch edit"
fi
# 8. No cross compiler: the build fails closed, it never falls back.
+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
# The sourced downloader runs before the later production-call test stub.
# shellcheck disable=SC2218
set -euo pipefail
TEST_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
QEMU_DIR="$(cd "$TEST_DIR/.." && pwd)"
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/busybox-source-mirror.XXXXXX")"
trap 'rm -rf "$SCRATCH"' EXIT
mkdir -p "$SCRATCH/bin"
printf 'pinned source fixture' > "$SCRATCH/good"
WANT="$(sha256sum "$SCRATCH/good" | awk '{print $1}')"
export MIRROR_LOG="$SCRATCH/requests" MIRROR_GOOD="$SCRATCH/good"
export MIRROR_MODE=good
cat > "$SCRATCH/bin/curl" <<'CURL'
#!/usr/bin/env bash
set -euo pipefail
url= out=
while [ "$#" -gt 0 ]; do
case "$1" in
-o) shift; out="$1" ;;
https://*) url="$1" ;;
esac
shift
done
printf '%s\n' "$url" >> "$MIRROR_LOG"
[ -n "$out" ] || exit 2
case "$url" in
https://primary.invalid/source) exit 28 ;;
https://mirror.invalid/source)
if [ "$MIRROR_MODE" = good ]; then cp "$MIRROR_GOOD" "$out";
else printf 'corrupt mirror response' > "$out"; fi ;;
*) exit 2 ;;
esac
CURL
chmod 0755 "$SCRATCH/bin/curl"
export PATH="$SCRATCH/bin:$PATH"
# shellcheck source=qemu/lib.sh disable=SC1091
source "$QEMU_DIR/lib.sh"
qemu_fetch_verified https://primary.invalid/source "$WANT" \
"$SCRATCH/fetched" source https://mirror.invalid/source
cmp "$SCRATCH/good" "$SCRATCH/fetched"
printf '%s\n' https://primary.invalid/source https://mirror.invalid/source > "$SCRATCH/expected"
cmp "$MIRROR_LOG" "$SCRATCH/expected"
echo 'PASS primary timeout uses verified mirror'
: > "$MIRROR_LOG"
qemu_fetch_verified https://primary.invalid/source "$WANT" \
"$SCRATCH/fetched" source https://mirror.invalid/source
test ! -s "$MIRROR_LOG"
echo 'PASS verified cache avoids both sources'
export MIRROR_MODE=bad
: > "$MIRROR_LOG"
if (qemu_fetch_verified https://primary.invalid/source "$WANT" \
"$SCRATCH/refused" source https://mirror.invalid/source) > "$SCRATCH/refusal" 2>&1; then
echo 'FAIL corrupt mirror was accepted' >&2
exit 1
fi
test "$(wc -l < "$MIRROR_LOG")" -eq 3
test ! -e "$SCRATCH/refused"
test -z "$(find "$SCRATCH" -maxdepth 1 -name 'refused.download.*' -print -quit)"
grep -q 'after 3 verified attempts' "$SCRATCH/refusal"
echo 'PASS corrupt mirror refused within three attempts'
# Exercise the production source call with the downloader intercepted only
# after build-busybox.sh loads its constants. Refuse before extraction.
# shellcheck source=qemu/build-busybox.sh disable=SC1091
source "$QEMU_DIR/build-busybox.sh"
mkdir -p "$SCRATCH/toolchain"
printf '#!/bin/sh\nexit 0\n' > "$SCRATCH/toolchain/fake-gcc"
chmod 0755 "$SCRATCH/toolchain/fake-gcc"
qemu_fetch_verified() {
[ "$1" = "$BB_SRC_URL" ] && [ "$2" = "$BB_SRC_SHA256" ]
[ "$5" = "$BB_SRC_MIRROR_URL" ]
printf '%s\n' 'production mirror call verified' > "$SCRATCH/wired"
return 42
}
set +e
(set -e; OUT="$SCRATCH/build" CROSS_COMPILE="$SCRATCH/toolchain/fake-" JOBS=1 bb_main) \
> "$SCRATCH/wiring-log" 2>&1
status=$?
set -e
if [ "$status" -ne 42 ]; then
cat "$SCRATCH/wiring-log" >&2
echo 'FAIL production source call did not stop at the verified downloader' >&2
exit 1
fi
grep -qx 'production mirror call verified' "$SCRATCH/wired"
echo 'PASS production source fetch supplies pinned mirror'
+48
View File
@@ -969,6 +969,8 @@ class Ctx:
self.input_wait_s = 0.0
# Stall probes run so far (STALL_REPORTS_MAX bounds them).
self.stall_reports = 0
# The UI's test hook answered a ping (hook_wait_ready).
self.hook_ready = False
def need_ctl(self, lineno, cmd):
if self.ctl is None:
@@ -1200,6 +1202,49 @@ def hook_request(ctl, words, args):
return ctl.send(f"@hook {words}")
# The bridge's line for a hook request whose client got no reply (_wcb_hook
# in rootfs/etc/warden-lib.sh).
HOOK_NO_ANSWER = "bridge: hook request got no answer"
# How long the run's first hook request waits for the UI's hook to answer a
# ping, and the pause between two pings. Each ping is bounded by the hook
# client itself (wthctl: 5 s for the UI).
HOOK_READY_S = 90.0
HOOK_READY_POLL_S = 1.0
def hook_wait_ready(ctx):
"""Wait, once per run, until the UI's test hook answers a `ping` -> None,
or the fatal detail when it never did.
The hook takes requests from the device bus, which the UI drains under a
per-tick budget (libwardenbus WBUS_TICK_PACKETS / WBUS_TICK_BUDGET_US).
Right after boot it is still taking the broker's retained replay, and a
request queued behind it misses both the client's 5 s bound and its own
5 s message expiry: an override sent then was lost, or applied with its
reply lost (flare-edge #2602). ping changes nothing, so it is the one
request that is safe to repeat; the step's own request is sent once,
after a ping came back. Replies come back in request order, so a late
answer to an earlier ping is gone before that request goes out.
Anything other than "no answer" ends the wait: a missing client or a
reply that is not JSON is reported by the step's own request."""
if ctx.hook_ready:
return None
deadline = time.monotonic() + HOOK_READY_S
pings = 0
while True:
pings += 1
reply = hook_request(ctx.ctl, "ping", {})
if not reply.startswith(HOOK_NO_ANSWER):
break
if time.monotonic() >= deadline:
return (f"the UI test hook answered no ping in {HOOK_READY_S:.0f} s "
f"({pings} sent): {reply}")
time.sleep(HOOK_READY_POLL_S)
ctx.hook_ready = judge_hook_reply(reply)[0] == "ok"
return None
def judge_hook_reply(reply):
"""(status, detail) for a hook reply: ok:true passes, ok:false fails with
the hook's err, and anything else (a bridge line, no JSON) is fatal: the
@@ -1230,6 +1275,9 @@ def verb_override(ctx, lineno, cmd, args, line):
return "fatal", f"override document is not JSON: {doc_text!r}"
if doc is not None and not isinstance(doc, (dict, list)):
return "fatal", "override document must be an object, an array or null"
not_ready = hook_wait_ready(ctx)
if not_ready:
return "fatal", not_ready
return judge_hook_reply(hook_request(ctx.ctl, "override", {"topic": topic, "doc": doc}))
+30
View File
@@ -140,6 +140,36 @@ if run_case "$argv" --ctl "$SCRATCH/ctl.sock" --rs485 "$SCRATCH/rs.sock"; then
fi
fi
# --- case: --agent (the rig agent, flare-edge M9 soak-lite) -> its
# pci-serial comes LAST, after ctl and rs485, so neither moves, and
# warden.agent lands on the cmdline only with the flag -------------------
if ! grep -qw 'warden.agent' "$SCRATCH/argv-both.txt" && ! grep -qF 'id=agent' "$SCRATCH/argv-both.txt"; then
pass "no --agent: no agent chardev and no warden.agent"
else
fail "no --agent: an agent chardev or warden.agent appeared unrequested"
fi
for combo in "agent-ctl:--ctl $SCRATCH/ctl.sock" "agent-alone:"; do
name="${combo%%:*}" extra="${combo#*:}"
argv="$SCRATCH/argv-$name.txt"
# shellcheck disable=SC2086 # extra is a word list on purpose
if run_case "$argv" $extra --rs485 "$SCRATCH/rs.sock" --agent "$SCRATCH/agent.sock"; then
ag_ln="$(chardev_line "$argv" "socket,id=agent,path=$SCRATCH/agent.sock,")"
rs_ln="$(chardev_line "$argv" "socket,id=rs485,path=$SCRATCH/rs.sock,")"
ctl_ln="$(chardev_line "$argv" "socket,id=ctl,")"
if [ -n "$ag_ln" ] && [ -n "$rs_ln" ] && [ "$rs_ln" -lt "$ag_ln" ] &&
{ [ -z "$ctl_ln" ] || [ "$ctl_ln" -lt "$rs_ln" ]; }; then
pass "$name: agent chardev (line $ag_ln) comes after rs485 (line $rs_ln) and ctl (${ctl_ln:-none})"
else
fail "$name: expected ctl < rs485 < agent, got ctl=$ctl_ln rs485=$rs_ln agent=$ag_ln"
fi
if grep -qF 'pci-serial,chardev=agent' "$argv" && grep -qw 'warden.agent' "$argv"; then
pass "$name: agent pci-serial device and warden.agent present"
else
fail "$name: agent pci-serial device or warden.agent missing"
fi
fi
done
if [ "$FAIL" -eq 0 ]; then
echo "ALL RUN.SH ARGV TESTS PASSED"
exit 0
+58 -2
View File
@@ -892,6 +892,11 @@ class OverrideVerb(unittest.TestCase):
HookCtl.sent = []
HookCtl.answer = staticmethod(lambda words, args: '{"v":1,"ok":true,"data":{}}')
HookCtl.refuse_pieces = False
self.ready = (qmp.HOOK_READY_S, qmp.HOOK_READY_POLL_S)
qmp.HOOK_READY_S, qmp.HOOK_READY_POLL_S = 0.0, 0.0
def tearDown(self):
qmp.HOOK_READY_S, qmp.HOOK_READY_POLL_S = self.ready
def test_pin_and_unpin_reach_the_hook_as_one_request_each(self):
seen = []
@@ -906,6 +911,7 @@ class OverrideVerb(unittest.TestCase):
self.assertIsNone(rc, rows)
self.assertEqual([r["status"] for r in rows], ["ok", "ok"])
self.assertEqual(seen, [
("ping", {}),
("override", {"topic": "io/state/failsafe",
"doc": {"last_trip": {"why": "two words"}, "ack": False}}),
("override", {"topic": "io/state/failsafe", "doc": None}),
@@ -915,7 +921,8 @@ class OverrideVerb(unittest.TestCase):
seen = []
def answer(words, args):
seen.append(args)
if words != "ping":
seen.append(args)
return '{"v":1,"ok":true}'
HookCtl.answer = staticmethod(answer)
doc = {"rows": ["x" * 100] * 120}
@@ -924,7 +931,9 @@ class OverrideVerb(unittest.TestCase):
ctl_cls=HookCtl)
self.assertEqual(rows[0]["status"], "ok", rows)
self.assertEqual(seen, [{"topic": "cfg/state/big", "doc": doc}])
pieces = [c for c in HookCtl.sent if c.startswith("@hookdoc")]
# The pieces after the readiness ping (which sends {} in one piece).
after_ping = HookCtl.sent[HookCtl.sent.index("@hook ping") + 1:]
pieces = [c for c in after_ping if c.startswith("@hookdoc")]
self.assertGreater(len(pieces), 5)
self.assertTrue(pieces[0].startswith("@hookdoc {"))
self.assertTrue(all(c.startswith("@hookdoc+ ") for c in pieces[1:]))
@@ -947,6 +956,53 @@ class OverrideVerb(unittest.TestCase):
rc, by, rows = run_script('override io/state/x {"a":1}\n', ctl_cls=HookCtl)
self.assertEqual(rows[0]["status"], "fatal", reply)
def test_the_first_override_waits_for_the_hook_to_answer_a_ping(self):
# flare-edge #2602: right after boot the UI's hook answered nothing
# for a while; the override must be sent once, after a ping came back.
qmp.HOOK_READY_S = 60.0
seen = []
lost = [2]
def answer(words, args):
seen.append(words)
if words == "ping" and lost[0]:
lost[0] -= 1
return "bridge: hook request got no answer (client exit 2): wthctl: no reply (-5)"
return '{"v":1,"ok":true,"data":{}}'
HookCtl.answer = staticmethod(answer)
rc, by, rows = run_script(
'override io/state/failsafe {"a":1}\n'
"override io/state/failsafe null\n", ctl_cls=HookCtl)
self.assertIsNone(rc, rows)
self.assertEqual([r["status"] for r in rows], ["ok", "ok"])
self.assertEqual(seen, ["ping", "ping", "ping", "override", "override"])
def test_a_hook_that_never_answers_a_ping_is_fatal_and_gets_no_override(self):
HookCtl.answer = staticmethod(lambda words, args: (
"bridge: hook request got no answer (client exit 2): wthctl: no reply (-5)"))
rc, by, rows = run_script('override io/state/x {"a":1}\nwake\n', ctl_cls=HookCtl)
self.assertEqual([r["status"] for r in rows], ["fatal", "ok"])
self.assertIn("answered no ping", rows[0]["detail"])
self.assertIn("@hook ping", HookCtl.sent)
self.assertNotIn("@hook override", HookCtl.sent)
def test_a_ping_that_is_not_ok_leaves_the_verdict_to_the_override(self):
# A hook that answers but refuses ping (an older hook) is still a
# hook: the override goes out and its own reply is judged, and the
# next override pings again rather than trusting it.
seen = []
def answer(words, args):
seen.append(words)
if words == "ping":
return '{"v":1,"ok":false,"err":{"code":"E_UNKNOWN_VERB"}}'
return '{"v":1,"ok":true}'
HookCtl.answer = staticmethod(answer)
rc, by, rows = run_script(
'override io/state/x {"a":1}\noverride io/state/x null\n', ctl_cls=HookCtl)
self.assertEqual([r["status"] for r in rows], ["ok", "ok"])
self.assertEqual(seen, ["ping", "override", "ping", "override"])
def test_a_refused_piece_is_fatal_for_the_step_only(self):
HookCtl.refuse_pieces = True
rc, by, rows = run_script('override io/state/x {"a":1}\nwake\n', ctl_cls=HookCtl)