Merge pull request 'qemu: PAYLOAD_DIR lets one run boot its own payload set' (#31) from rb/ln-hook-payload into rebuild
ci / test (push) Successful in 21s
ci / mcdc (push) Successful in 23s
ci / bench (push) Successful in 17s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / patches-apply (push) Successful in 21s
ci / qemu-tools (push) Successful in 1m32s
ci / quality (push) Successful in 1m25s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 4m58s
ci / test (push) Successful in 21s
ci / mcdc (push) Successful in 23s
ci / bench (push) Successful in 17s
ci / prune-artifacts (push) Skipped
ci / kernel-build (push) Skipped
ci / patches-apply (push) Successful in 21s
ci / qemu-tools (push) Successful in 1m32s
ci / quality (push) Successful in 1m25s
ci / badges (push) Skipped
ci / kernel-symbols (push) Successful in 4m58s
This commit was merged in pull request #31.
This commit is contained in:
@@ -175,6 +175,11 @@ jobs:
|
|||||||
# otherwise; this builds the same unprivileged mkfs.ext4 image and
|
# otherwise; this builds the same unprivileged mkfs.ext4 image and
|
||||||
# reads it back with debugfs, no VM needed.
|
# reads it back with debugfs, no VM needed.
|
||||||
run: bash qemu/tests/seed-dir.sh
|
run: bash qemu/tests/seed-dir.sh
|
||||||
|
- name: mkimage.sh PAYLOAD_DIR regression test (flare-edge#2054)
|
||||||
|
# A run's own payload set (the hook set) lands in both slots, the
|
||||||
|
# default still reads qemu/payload, and ui-drive.sh checks the same
|
||||||
|
# directory; images read back with debugfs, no VM.
|
||||||
|
run: bash qemu/tests/payload-dir.sh
|
||||||
- name: qemu_stage_rootfs permission regression test
|
- name: qemu_stage_rootfs permission regression test
|
||||||
# Git tracks only the executable bit, so a fresh checkout can land
|
# Git tracks only the executable bit, so a fresh checkout can land
|
||||||
# the source etc/shadow world-readable under a permissive umask;
|
# the source etc/shadow world-readable under a permissive umask;
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ All take the virt-fragment `<zImage>`; `FLARE_EDGE=<checkout>` where noted.
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `stage-rootfs-perms.sh` | - | offline, no VM: `qemu_stage_rootfs()` always lands `etc/shadow` at 0600, even staged from a source copy deliberately left 0644 |
|
| `stage-rootfs-perms.sh` | - | offline, no VM: `qemu_stage_rootfs()` always lands `etc/shadow` at 0600, even staged from a source copy deliberately left 0644 |
|
||||||
| `seed-dir.sh` | - | offline, no VM: `mkimage.sh`'s `SEED_DIR` hook lands every seeded file under userdata/warden with its original mode (a 0600 secret included), a seeded file beats a same-named `--state` value, a `SEED_DIR` that isn't a directory fails closed, and so does an individual entry that is a symlink, a subdirectory, or named outside `[A-Za-z0-9_.-]+` -- a hyphenated key such as `gas-plant.devices` still seeds cleanly |
|
| `seed-dir.sh` | - | offline, no VM: `mkimage.sh`'s `SEED_DIR` hook lands every seeded file under userdata/warden with its original mode (a 0600 secret included), a seeded file beats a same-named `--state` value, a `SEED_DIR` that isn't a directory fails closed, and so does an individual entry that is a symlink, a subdirectory, or named outside `[A-Za-z0-9_.-]+` -- a hyphenated key such as `gas-plant.devices` still seeds cleanly |
|
||||||
|
| `payload-dir.sh` | - | offline, no VM: `mkimage.sh`'s `PAYLOAD_DIR` hook puts the run's own payload set (symlinked entries included, as regular 0755 files; its README.md skipped) into `/usr/bin` of both slots and nothing from `qemu/payload`, the default still reads `qemu/payload`, a `PAYLOAD_DIR` that is not a directory fails closed, and `ui-drive.sh` looks for `warden-ui` in the same directory |
|
||||||
| `boot-smoke.sh` | - | sentinel-asserting boot; runs in CI inside kernel-build |
|
| `boot-smoke.sh` | - | sentinel-asserting boot; runs in CI inside kernel-build |
|
||||||
| `portal-scenario.sh` | `FLARE_EDGE` | real flared against the desk mock portal: authenticated check-in, desired-state pull, signed tier-1 `.wfw` download; verify/stage/APPLYING as a dry run (no `WARDEN_FW_ALLOW_APPLY`) |
|
| `portal-scenario.sh` | `FLARE_EDGE` | real flared against the desk mock portal: authenticated check-in, desired-state pull, signed tier-1 `.wfw` download; verify/stage/APPLYING as a dry run (no `WARDEN_FW_ALLOW_APPLY`) |
|
||||||
| `ota-apply.sh` | `FLARE_EDGE` | the FULL apply: the `.wfw`'s bootable rootfs payload is written to rootfs_b (`run.sh --allow-apply` gates it per boot), the AvbABData in `misc` flips, and slot `_b` boots the applied version |
|
| `ota-apply.sh` | `FLARE_EDGE` | the FULL apply: the `.wfw`'s bootable rootfs payload is written to rootfs_b (`run.sh --allow-apply` gates it per boot), the AvbABData in `misc` flips, and slot `_b` boots the applied version |
|
||||||
|
|||||||
+9
-1
@@ -17,6 +17,12 @@
|
|||||||
# Env:
|
# 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)
|
||||||
# OUT output dir (default: qemu/out); image at $OUT/disk.img
|
# OUT output dir (default: qemu/out); image at $OUT/disk.img
|
||||||
|
# PAYLOAD_DIR the directory whose binaries land in /usr/bin of both slots
|
||||||
|
# (default qemu/payload). Lets one run boot its own payload set
|
||||||
|
# (flare-edge's hook set for a flow that pins documents: the
|
||||||
|
# production payload plus the test-flavor UI and wthctl) while
|
||||||
|
# other runs read qemu/payload at the same time. Not a
|
||||||
|
# directory: fails closed.
|
||||||
# SEED_DIR a directory of pre-built userdata/warden files (one file per
|
# SEED_DIR a directory of pre-built userdata/warden files (one file per
|
||||||
# settings key, e.g. flare-edge tools/seed-fixtures.py's output)
|
# settings key, e.g. flare-edge tools/seed-fixtures.py's output)
|
||||||
# copied in VERBATIM, after --portal-url/--state. Lets a caller
|
# copied in VERBATIM, after --portal-url/--state. Lets a caller
|
||||||
@@ -72,7 +78,9 @@ trap 'rm -rf "$SCRATCH"' EXIT
|
|||||||
# both slots so A and B start byte-identical, like a factory flash.
|
# both slots so A and B start byte-identical, like a factory flash.
|
||||||
ROOT="$SCRATCH/root"
|
ROOT="$SCRATCH/root"
|
||||||
qemu_stage_rootfs "$ROOT"
|
qemu_stage_rootfs "$ROOT"
|
||||||
for p in "$QEMU_DIR"/payload/*; do
|
PAYLOAD_DIR="${PAYLOAD_DIR:-$QEMU_DIR/payload}"
|
||||||
|
[ -d "$PAYLOAD_DIR" ] || { echo "FATAL: PAYLOAD_DIR '$PAYLOAD_DIR' is not a directory" >&2; exit 1; }
|
||||||
|
for p in "$PAYLOAD_DIR"/*; do
|
||||||
[ -f "$p" ] || continue
|
[ -f "$p" ] || continue
|
||||||
case "$(basename "$p")" in README.md) continue ;; esac
|
case "$(basename "$p")" in README.md) continue ;; esac
|
||||||
install -m 0755 "$p" "$ROOT/usr/bin/$(basename "$p")"
|
install -m 0755 "$p" "$ROOT/usr/bin/$(basename "$p")"
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
Drop **static musl armv7** binaries in this directory (contents are
|
Drop **static musl armv7** binaries in this directory (contents are
|
||||||
gitignored; binaries are never committed); `qemu/mkimage.sh` copies everything
|
gitignored; binaries are never committed); `qemu/mkimage.sh` copies everything
|
||||||
in this directory (except this README) into `/usr/bin/` of both rootfs slots.
|
in this directory (except this README) into `/usr/bin/` of both rootfs slots.
|
||||||
|
`PAYLOAD_DIR=<dir>` points one run (`mkimage.sh`, `tests/ui-drive.sh`) at
|
||||||
|
another directory instead, so a caller can boot its own set, such as
|
||||||
|
flare-edge's hook set for a flow that pins documents, while other runs read
|
||||||
|
this one.
|
||||||
Static musl is the same target the device uses for its Rust daemons, so the
|
Static musl is the same target the device uses for its Rust daemons, so the
|
||||||
exact production binaries run unmodified in the VM.
|
exact production binaries run unmodified in the VM.
|
||||||
|
|
||||||
|
|||||||
Executable
+179
@@ -0,0 +1,179 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Regression test for mkimage.sh's PAYLOAD_DIR hook (see its Env note): a run
|
||||||
|
# may boot its own payload set instead of qemu/payload, so flare-edge can boot
|
||||||
|
# the hook set (production payload plus the test-flavor UI and wthctl) for a
|
||||||
|
# flow that pins documents while other flows of the same batch read
|
||||||
|
# qemu/payload at the same time (flare-edge #2054).
|
||||||
|
#
|
||||||
|
# Works on a copy of qemu/ (no payload, no out/) so the default payload
|
||||||
|
# directory is the copy's own and nothing in the checkout is touched. Builds
|
||||||
|
# real disk images the same way mkimage.sh always does (unprivileged
|
||||||
|
# mkfs.ext4 -d), then reads rootfs_a and rootfs_b back with debugfs -R
|
||||||
|
# (read-only, no mount or loop device) to check what actually landed.
|
||||||
|
#
|
||||||
|
# bash payload-dir.sh
|
||||||
|
set -uo pipefail
|
||||||
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # qemu/tests/
|
||||||
|
SRC_QEMU="$(cd "$HERE/.." && pwd)" # qemu/
|
||||||
|
FAIL=0
|
||||||
|
pass() { printf '[PASS] %s\n' "$1"; }
|
||||||
|
fail() { printf '[FAIL] %s\n' "$1"; FAIL=1; }
|
||||||
|
|
||||||
|
# mkfs.ext4 and debugfs live in sbin, which user shells on Debian do not put
|
||||||
|
# on PATH; mkimage.sh applies the same fix.
|
||||||
|
PATH="$PATH:/usr/sbin:/sbin"
|
||||||
|
command -v debugfs >/dev/null || {
|
||||||
|
echo "FATAL: debugfs (e2fsprogs) not found: needed to read the rootfs partitions back" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
SCRATCH="$(mktemp -d "${TMPDIR:-/tmp}/warden-qemu-payload-dir.XXXXXX")"
|
||||||
|
trap 'rm -rf "$SCRATCH"' EXIT
|
||||||
|
|
||||||
|
# The copy: everything mkimage.sh reads, without the build outputs or any
|
||||||
|
# payload a developer dropped into the checkout.
|
||||||
|
QEMU_DIR="$SCRATCH/qemu"
|
||||||
|
mkdir -p "$QEMU_DIR/payload"
|
||||||
|
for entry in "$SRC_QEMU"/*; do
|
||||||
|
case "$(basename "$entry")" in out|payload) continue ;; esac
|
||||||
|
cp -a "$entry" "$QEMU_DIR/"
|
||||||
|
done
|
||||||
|
|
||||||
|
# shellcheck source=../lib.sh disable=SC1091
|
||||||
|
. "$QEMU_DIR/lib.sh"
|
||||||
|
# shellcheck source=../blkdevparts.conf disable=SC1091
|
||||||
|
. "$QEMU_DIR/blkdevparts.conf"
|
||||||
|
|
||||||
|
declare -A PART_OFF PART_SIZE
|
||||||
|
capture_part() { PART_OFF[$1]="$2"; PART_SIZE[$1]="$3"; return 0; }
|
||||||
|
qemu_each_partition capture_part
|
||||||
|
for name in rootfs_a rootfs_b; do
|
||||||
|
[ -n "${PART_OFF[$name]:-}" ] || { echo "FATAL: no '$name' entry in blkdevparts.conf" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
|
# extract_part DISK NAME OUTFILE: one partition window, sparse.
|
||||||
|
extract_part() {
|
||||||
|
dd if="$1" of="$3" bs=4096 skip=$((PART_OFF[$2] / 4096)) \
|
||||||
|
count=$((PART_SIZE[$2] / 4096)) conv=sparse status=none
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reuse an already-verified busybox wherever a prior build produced one; a
|
||||||
|
# checkout that never ran mkimage.sh fetches and verifies it once here.
|
||||||
|
BUSYBOX_BIN="$SRC_QEMU/out/busybox-armv7l"
|
||||||
|
if [ ! -f "$BUSYBOX_BIN" ]; then
|
||||||
|
OUT="$SCRATCH/bb" qemu_get_busybox
|
||||||
|
BUSYBOX_BIN="$BB"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The default set and the run's own set name the same binary differently,
|
||||||
|
# so each image shows which directory it was built from.
|
||||||
|
printf 'default-ui\n' > "$QEMU_DIR/payload/warden-ui"
|
||||||
|
printf 'default only\n' > "$QEMU_DIR/payload/warden-default-only"
|
||||||
|
ALT="$SCRATCH/alt"
|
||||||
|
mkdir -p "$ALT"
|
||||||
|
printf 'alt-ui\n' > "$ALT/warden-ui"
|
||||||
|
printf 'readme\n' > "$ALT/README.md"
|
||||||
|
printf 'linked tool\n' > "$SCRATCH/wthctl.real"
|
||||||
|
ln -s "$SCRATCH/wthctl.real" "$ALT/wthctl"
|
||||||
|
|
||||||
|
# --- scenario 1: PAYLOAD_DIR replaces qemu/payload in both slots ---
|
||||||
|
OUT1="$SCRATCH/out1"
|
||||||
|
if OUT="$OUT1" BUSYBOX="$BUSYBOX_BIN" PAYLOAD_DIR="$ALT" \
|
||||||
|
bash "$QEMU_DIR/mkimage.sh" > "$SCRATCH/mkimage1.log" 2>&1; then
|
||||||
|
for slot in rootfs_a rootfs_b; do
|
||||||
|
IMG="$SCRATCH/$slot.1.img"
|
||||||
|
extract_part "$OUT1/disk.img" "$slot" "$IMG"
|
||||||
|
ui="$(debugfs -R "cat /usr/bin/warden-ui" "$IMG" 2>/dev/null)"
|
||||||
|
if [ "$ui" = "alt-ui" ]; then
|
||||||
|
pass "PAYLOAD_DIR: $slot carries the run's own warden-ui"
|
||||||
|
else
|
||||||
|
fail "PAYLOAD_DIR: $slot warden-ui = '$ui', want 'alt-ui'"
|
||||||
|
fi
|
||||||
|
tool="$(debugfs -R "cat /usr/bin/wthctl" "$IMG" 2>/dev/null)"
|
||||||
|
if [ "$tool" = "linked tool" ]; then
|
||||||
|
pass "PAYLOAD_DIR: $slot gets a symlinked entry's content"
|
||||||
|
else
|
||||||
|
fail "PAYLOAD_DIR: $slot wthctl = '$tool', want the symlink target's content"
|
||||||
|
fi
|
||||||
|
mode="$(debugfs -R "stat /usr/bin/wthctl" "$IMG" 2>/dev/null | grep -oE 'Mode: *[0-7]+' | grep -oE '[0-7]+$')"
|
||||||
|
if [ "$mode" = "0755" ]; then
|
||||||
|
pass "PAYLOAD_DIR: $slot installs a regular 0755 file for the symlink"
|
||||||
|
else
|
||||||
|
fail "PAYLOAD_DIR: $slot wthctl mode '$mode', want 0755"
|
||||||
|
fi
|
||||||
|
if debugfs -R "stat /usr/bin/warden-default-only" "$IMG" 2>&1 | grep -q 'File not found'; then
|
||||||
|
pass "PAYLOAD_DIR: $slot has nothing from qemu/payload"
|
||||||
|
else
|
||||||
|
fail "PAYLOAD_DIR: $slot carries qemu/payload's warden-default-only"
|
||||||
|
fi
|
||||||
|
if debugfs -R "stat /usr/bin/README.md" "$IMG" 2>&1 | grep -q 'File not found'; then
|
||||||
|
pass "PAYLOAD_DIR: $slot skips the set's README.md"
|
||||||
|
else
|
||||||
|
fail "PAYLOAD_DIR: $slot carries the set's README.md"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
fail "PAYLOAD_DIR: mkimage.sh exited nonzero with a valid payload dir (see $SCRATCH/mkimage1.log)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- scenario 2: no PAYLOAD_DIR still reads qemu/payload ---
|
||||||
|
OUT2="$SCRATCH/out2"
|
||||||
|
if OUT="$OUT2" BUSYBOX="$BUSYBOX_BIN" \
|
||||||
|
bash "$QEMU_DIR/mkimage.sh" > "$SCRATCH/mkimage2.log" 2>&1; then
|
||||||
|
IMG="$SCRATCH/rootfs_a.2.img"
|
||||||
|
extract_part "$OUT2/disk.img" rootfs_a "$IMG"
|
||||||
|
ui="$(debugfs -R "cat /usr/bin/warden-ui" "$IMG" 2>/dev/null)"
|
||||||
|
if [ "$ui" = "default-ui" ]; then
|
||||||
|
pass "no PAYLOAD_DIR: rootfs_a carries qemu/payload's warden-ui"
|
||||||
|
else
|
||||||
|
fail "no PAYLOAD_DIR: rootfs_a warden-ui = '$ui', want 'default-ui'"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
fail "no PAYLOAD_DIR: mkimage.sh exited nonzero (see $SCRATCH/mkimage2.log)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# --- scenario 3: a PAYLOAD_DIR that is not a directory fails closed ---
|
||||||
|
NOTADIR="$SCRATCH/notadir"
|
||||||
|
: > "$NOTADIR"
|
||||||
|
OUT3="$SCRATCH/out3"
|
||||||
|
err3="$(OUT="$OUT3" BUSYBOX="$BUSYBOX_BIN" PAYLOAD_DIR="$NOTADIR" \
|
||||||
|
bash "$QEMU_DIR/mkimage.sh" 2>&1 1>/dev/null)"
|
||||||
|
rc3=$?
|
||||||
|
if [ "$rc3" -ne 0 ] && printf '%s' "$err3" | grep -qF "FATAL: PAYLOAD_DIR '$NOTADIR' is not a directory"; then
|
||||||
|
pass "PAYLOAD_DIR: a non-directory path fails closed with the FATAL message"
|
||||||
|
else
|
||||||
|
fail "PAYLOAD_DIR: non-directory path gave rc=$rc3, stderr='$err3' (want nonzero + the FATAL message)"
|
||||||
|
fi
|
||||||
|
[ -e "$OUT3/disk.img" ] && fail "PAYLOAD_DIR: a disk image was written for a non-directory payload dir"
|
||||||
|
|
||||||
|
# --- scenario 4: ui-drive.sh looks for warden-ui in PAYLOAD_DIR ---
|
||||||
|
# An empty set fails its warden-ui check before anything is built; the set
|
||||||
|
# with a warden-ui gets past it and stops at the next check, because the
|
||||||
|
# PATH it runs with holds only dirname (no qemu-system-arm), so no VM boots.
|
||||||
|
EMPTY="$SCRATCH/empty"
|
||||||
|
mkdir -p "$EMPTY" "$SCRATCH/nobin"
|
||||||
|
ln -s "$(command -v dirname)" "$SCRATCH/nobin/dirname"
|
||||||
|
BASH_BIN="$(command -v bash)"
|
||||||
|
printf 'page Demo\n' > "$SCRATCH/drive.txt"
|
||||||
|
: > "$SCRATCH/zImage"
|
||||||
|
err4="$(PAYLOAD_DIR="$EMPTY" PATH="$SCRATCH/nobin" "$BASH_BIN" "$QEMU_DIR/tests/ui-drive.sh" \
|
||||||
|
"$SCRATCH/zImage" "$SCRATCH/drive.txt" "$SCRATCH/drive-out" 2>&1)"
|
||||||
|
if printf '%s' "$err4" | grep -qF "FATAL: no warden-ui in $EMPTY"; then
|
||||||
|
pass "ui-drive.sh: a PAYLOAD_DIR without warden-ui is refused, naming the directory"
|
||||||
|
else
|
||||||
|
fail "ui-drive.sh: PAYLOAD_DIR without warden-ui gave '$err4'"
|
||||||
|
fi
|
||||||
|
chmod +x "$ALT/warden-ui"
|
||||||
|
err5="$(PAYLOAD_DIR="$ALT" PATH="$SCRATCH/nobin" "$BASH_BIN" "$QEMU_DIR/tests/ui-drive.sh" \
|
||||||
|
"$SCRATCH/zImage" "$SCRATCH/drive.txt" "$SCRATCH/drive-out" 2>&1)"
|
||||||
|
if printf '%s' "$err5" | grep -qF "qemu-system-arm not on PATH" && ! printf '%s' "$err5" | grep -q "no warden-ui"; then
|
||||||
|
pass "ui-drive.sh: a PAYLOAD_DIR with warden-ui passes the payload check"
|
||||||
|
else
|
||||||
|
fail "ui-drive.sh: PAYLOAD_DIR with an executable warden-ui gave '$err5' (want the qemu-system-arm check next)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$FAIL" -ne 0 ]; then
|
||||||
|
echo "payload-dir: FAILED"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "payload-dir: all scenarios passed"
|
||||||
@@ -13,9 +13,11 @@ was never compared with the one the reference was captured under.
|
|||||||
|
|
||||||
python3 test_qmp_drive.py
|
python3 test_qmp_drive.py
|
||||||
"""
|
"""
|
||||||
|
import atexit
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@@ -29,6 +31,15 @@ HERE = os.path.dirname(os.path.abspath(__file__))
|
|||||||
sys.path.insert(0, HERE)
|
sys.path.insert(0, HERE)
|
||||||
import qmp # noqa: E402
|
import qmp # noqa: E402
|
||||||
|
|
||||||
|
# Every temp dir this module makes (a drive's out dir per run_script, the
|
||||||
|
# console and QMP socket dirs) lands under one root per run, removed at exit,
|
||||||
|
# so a run leaves $TMPDIR as it found it (bfe-core1106-sdk#30: about 40 dirs
|
||||||
|
# per run used to stay behind). The prefix is short: an AF_UNIX socket path
|
||||||
|
# under it must stay inside about 108 bytes.
|
||||||
|
_TMP_ROOT = tempfile.mkdtemp(prefix="qdt.")
|
||||||
|
tempfile.tempdir = _TMP_ROOT
|
||||||
|
atexit.register(shutil.rmtree, _TMP_ROOT, True)
|
||||||
|
|
||||||
SIZE = 64
|
SIZE = 64
|
||||||
|
|
||||||
|
|
||||||
@@ -1574,5 +1585,29 @@ class StallProbe(unittest.TestCase):
|
|||||||
self.assertTrue(qmp.is_stall("control channel: bridge: no reply from warden-ui within 30 s: hit"))
|
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"))
|
self.assertFalse(qmp.is_stall("obj moved: box=1,2,3x4"))
|
||||||
|
|
||||||
|
class TempDirs(unittest.TestCase):
|
||||||
|
# One test per kind of temp dir this module makes: a drive's out dir
|
||||||
|
# (run_script), a console dir and a QMP socket dir.
|
||||||
|
CHILD_TESTS = (
|
||||||
|
"DriveVerbs.test_shot_and_region_names_cannot_escape_outdir",
|
||||||
|
"ConsoleWatchTests.test_finds_a_marker_split_across_two_reads_and_caches_it",
|
||||||
|
"QmpSocketTimeout.test_main_bounds_a_wedged_qmp_peer_instead_of_hanging_forever",
|
||||||
|
)
|
||||||
|
|
||||||
|
@unittest.skipIf(os.environ.get("QMP_DRIVE_TEMP_CHILD"), "the child run itself")
|
||||||
|
def test_a_run_leaves_tmpdir_as_it_found_it(self):
|
||||||
|
fresh = tempfile.mkdtemp(prefix="fresh.", dir=os.path.dirname(_TMP_ROOT))
|
||||||
|
try:
|
||||||
|
env = dict(os.environ, TMPDIR=fresh, QMP_DRIVE_TEMP_CHILD="1")
|
||||||
|
child = subprocess.run(
|
||||||
|
[sys.executable, os.path.abspath(__file__), *self.CHILD_TESTS],
|
||||||
|
env=env, capture_output=True, text=True, timeout=120)
|
||||||
|
self.assertEqual(child.returncode, 0, child.stderr[-2000:])
|
||||||
|
self.assertIn(f"Ran {len(self.CHILD_TESTS)} tests", child.stderr)
|
||||||
|
self.assertEqual(os.listdir(fresh), [])
|
||||||
|
finally:
|
||||||
|
shutil.rmtree(fresh, ignore_errors=True)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main(verbosity=1)
|
unittest.main(verbosity=1)
|
||||||
|
|||||||
@@ -71,8 +71,9 @@ if [ -n "$SEED_FILE" ] && { [ -z "${FLARE_EDGE:-}" ] || [ ! -f "$FLARE_EDGE/tool
|
|||||||
echo "FATAL: --seed needs FLARE_EDGE to point at a flare-edge checkout (seed-fixtures.py not found under '${FLARE_EDGE:-}')" >&2
|
echo "FATAL: --seed needs FLARE_EDGE to point at a flare-edge checkout (seed-fixtures.py not found under '${FLARE_EDGE:-}')" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
[ -x "$QDIR/payload/warden-ui" ] || {
|
# PAYLOAD_DIR (mkimage.sh's Env note) picks another payload set for this run.
|
||||||
echo "FATAL: no qemu/payload/warden-ui: build it with flare-edge tools/build-ui-vm.sh" >&2
|
[ -x "${PAYLOAD_DIR:-$QDIR/payload}/warden-ui" ] || {
|
||||||
|
echo "FATAL: no warden-ui in ${PAYLOAD_DIR:-qemu/payload}: build it with flare-edge tools/build-ui-vm.sh" >&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
command -v qemu-system-arm >/dev/null || {
|
command -v qemu-system-arm >/dev/null || {
|
||||||
|
|||||||
Reference in New Issue
Block a user