Skip to content

eBPF-based security platform

testing: boot a fresh VM for each family of target tests

Daniel Borkmann5626e5e10ceb
diff --git a/AGENTS.md b/AGENTS.md
index dde2ce7b..9285f881 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -338,8 +338,9 @@ one usually still compiles and passes tests.
- `make -C testing test-op` runs the unit tests and the host-side suite (the
`t?0??` tests under `testing/`), no root needed;
`make -C testing SANITIZE=address,undefined test-op` runs it under ASan and
- UBSan (CI does too); `make -C testing test-tgt` runs the target suite in the
- QEMU/swtpm VM (`make -C testing help` lists the VM target groups).
+ UBSan (CI does too); `make -C testing test-tgt` runs the target tests in
+ QEMU/swtpm VMs, one fresh VM per test family (`T=<family>` selects some,
+ `make -C testing help` lists them).
- `sudo make -C testing test-tgt` always boots the dm-verity runtime and signed
config from a dracut initrd. CI runs that same required suite through
`.github/scripts/target-tests.sh`; the old root-only installer suite is gone.
diff --git a/Documentation/config-images.rst b/Documentation/config-images.rst
index fe5c789f..914182c9 100644
--- a/Documentation/config-images.rst
+++ b/Documentation/config-images.rst
@@ -478,6 +478,10 @@ only public artifacts. Run the suite with::
sudo make -C testing test-tgt
+Each family of target tests boots a VM of its own from the same bundle, so
+no family sees state another left behind; ``T=image`` runs the image family
+alone, and ``make -j`` runs several families side by side.
+
The harness requires dracut, initrd boot and all seal hooks. It rejects
``TEST_VM_INITRD=0`` and ``TEST_VM_SKIP_SEAL=1``. The only accepted value of
the old ``TEST_VM_MODE`` setting is ``verity``; no selection is needed.
@@ -494,12 +498,13 @@ process observers, hidden bpffs, signed config updates and measured revocation.
After the final interrupted update it checks that changes and attestation
refuse while the node continues running.
-Required image fixtures and helpers are failures when absent. A whole suite
-that skips in image mode fails the runner. Test ordering matters:
-boot-signer assertions run before config changes. Revocation removes a
-signer for the remainder of the boot; the interruption case runs last
-because it leaves the activation pending. Use a fresh test
-VM and state for another complete run.
+Required image fixtures and helpers are failures when absent. A target
+test that skips as a whole fails its family. Within a family the tests run
+in number order, and for the image family the order matters: the
+boot-signer assertions run before the config changes, revocation removes a
+signer for the remainder of the boot, and the interruption case runs last
+because it leaves the activation pending. Use a fresh test VM and state
+for another run.
For an already provisioned disposable image-mode VM, install the complete
public fixture set and cache every config bundle under
@@ -509,7 +514,7 @@ public fixture set and cache every config bundle under
export SHIRUDO_TEST_FIXTURES_DIR=/path/to/public-upatch-fixtures
export SHIRUDO_TEST_KEY_FIXTURES=/path/to/public-image-fixtures
export SHIRUDO_TEST_RESULTS=/root/test-results/verity
- sh testing/run-target-tests.sh
+ sh testing/run-target-tests.sh image
``testing/vm/image-fixtures.sh --keys-dir <operator-keys>
--output <new-directory>`` builds the signed config and revocation fixtures;
diff --git a/Documentation/tpm.rst b/Documentation/tpm.rst
index 08a6ff30..7a411eb1 100644
--- a/Documentation/tpm.rst
+++ b/Documentation/tpm.rst
@@ -694,7 +694,7 @@ survive. This preserves lifecycle, attestation and credential-activation
coverage, including index recreation, the closed first-write window,
reset recovery and late binding. It is a protocol test before the LSM
attaches, not evidence of guard enforcement. The host suite skips it;
-``test-tgt`` runs it before the normal target suite.
+``test-tgt`` runs it in a VM of its own beside the test families.
The same guest runs ``testing/functional/tpm/t4004-config-attest.sh``
with a fresh native writer to cover config-PCR evidence alongside the
signed NV register.
diff --git a/testing/Makefile b/testing/Makefile
index b686d5df..ae9920b8 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -20,8 +20,7 @@ test-vm-arch = $(shell TEST_VM_ARCH='$(TEST_VM_ARCH)'; \
.DEFAULT_GOAL := help
.PHONY: help clean test-helpers test-unit test-op fuzz test bundle test-vm-bundle kernel \
- bpf-next vm vm-console vm-ssh vm-stop vm-clean test-tgt test-tgt-obs \
- test-tgt-register test-vm test-vm-clean
+ bpf-next vm vm-console vm-ssh vm-stop vm-clean test-tgt test-vm test-vm-clean
KERNEL_PATCHES ?= $(if $(wildcard $(ROOT)/kernel/*.patch),$(ROOT)/kernel/,)
override KERNEL_PATCHES := $(if $(strip $(KERNEL_PATCHES)),$(call root-path,$(KERNEL_PATCHES)),)
@@ -243,28 +242,19 @@ VM_MODE=test TEST_VM_SUITE="$(1)" VM_VERBOSE="$(TEST_VM_VERBOSE)" VM_NAME="$(2)"
$(ROOT)/testing/vm/run.sh
endef
-test-tgt-register: $(VM_KERNEL_DEP) test-vm-bundle
- $(Q)$(call run-target-vm,register,$(if $(VM_NAME),$(VM_NAME),shirudo)-register,0)
+# Each family of target tests boots a VM of its own from the bundle, so no
+# test finds what another family left behind; register runs the TPM
+# register tests before init, without the production initrd. T= selects
+# families, and make -j runs their VMs side by side.
+TEST_TGT_FAMILIES := register $(shell cd $(ROOT)/testing/functional && \
+ ls */t[0-9]1[0-9][0-9]-*.sh | \
+ awk -F/ '{ print substr($$2, 2, 1), $$1 }' | sort -u | cut -d' ' -f2) e2e
+T ?= $(TEST_TGT_FAMILIES)
-test-tgt: $(VM_KERNEL_DEP) test-vm-bundle test-tgt-register
- $(Q)$(call run-target-vm,$(TEST_VM_SUITE),$(VM_NAME),$(TEST_VM_INITRD))
+test-tgt: $(addprefix test-tgt-,$(T))
-test-tgt-obs: $(VM_KERNEL_DEP) test-vm-bundle
- $(Q)VM_MODE=test TEST_VM_SUITE=obs VM_VERBOSE="$(TEST_VM_VERBOSE)" VM_NAME="$(VM_NAME)" VM_TENANT="$(VM_TENANT)" \
- TEST_VM_KERNEL="$(abspath $(VM_KERNEL_IMAGE))" \
- TEST_VM_KERNEL_ARTIFACT_DIR="$(abspath $(VM_KERNEL_ARTIFACT_DIR))" \
- TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" \
- TEST_VM_RUNTIME_CACHE_DIR="$(TEST_VM_RUNTIME_CACHE_DIR)" \
- TEST_VM_MAP_EXPORT_ENDPOINT="$(TEST_VM_MAP_EXPORT_ENDPOINT)" \
- TEST_VM_MAP_EXPORT_TENANT_ID="$(TEST_VM_MAP_EXPORT_TENANT_ID)" \
- TEST_VM_MAP_EXPORT_INSECURE="$(TEST_VM_MAP_EXPORT_INSECURE)" \
- TEST_VM_MAP_EXPORT_CA="$(TEST_VM_MAP_EXPORT_CA)" \
- TEST_VM_OCI_CA="$(TEST_VM_OCI_CA)" \
- TEST_VM_BPM_OCI_REPOSITORY="$(TEST_VM_BPM_OCI_REPOSITORY)" \
- TEST_VM_BPM_OCI_INDEX_CERT="$(TEST_VM_BPM_OCI_INDEX_CERT)" \
- TEST_VM_MODE="$(TEST_VM_MODE)" TEST_VM_INITRD="$(TEST_VM_INITRD)" \
- TEST_VM_HOST_BUNDLE="$(abspath $(TEST_VM_BUNDLE_DIR))" \
- $(ROOT)/testing/vm/run.sh
+test-tgt-%: $(VM_KERNEL_DEP) test-vm-bundle
+ $(Q)$(call run-target-vm,$*,$(if $(VM_NAME),$(VM_NAME)-$*),$(if $(filter register,$*),0,1))
vm-stop:
$(Q)VM_NAME="$(VM_NAME)" \
@@ -319,9 +309,8 @@ help:
' make -C testing test-unit' \
' make -C testing test-helpers' \
' make -C testing fuzz [FUZZ_SECONDS=60]' \
- ' make -C testing test-tgt (dm-verity, dracut initrd, root required)' \
- ' make -C testing test-tgt-register' \
- ' make -C testing test-tgt-obs' \
+ ' make -C testing test-tgt [T="<family> ..."] (one VM per family, root required)' \
+ ' make -C testing test-tgt-<family>, families: $(TEST_TGT_FAMILIES)' \
' make -C testing vm, vm-console, vm-ssh, vm-stop, or vm-clean' \
' make -C testing vm KERNEL=7.4' \
' make -C testing kernel KERNEL_TAG=v7.4' \
diff --git a/testing/functional/build/t1007-test-vm-cli.sh b/testing/functional/build/t1007-test-vm-cli.sh
index 05a2dd7d..bc3a931a 100755
--- a/testing/functional/build/t1007-test-vm-cli.sh
+++ b/testing/functional/build/t1007-test-vm-cli.sh
@@ -7,6 +7,9 @@ cd "$(dirname "$0")/../.."
RUNNER=vm/run.sh
WORK=$(mktemp -d)
+# A test run boots one family; the checks below stop before it boots.
+TEST_VM_SUITE=upatch
+export TEST_VM_SUITE
trap 'rm -rf "$WORK"' EXIT
test_expect_success 'test-vm rejects a missing local kernel before boot' '
@@ -462,7 +465,7 @@ test_expect_success 'make -C testing vm and test-vm share named mode support' '
grep -q "VM_MODE=interactive" ../testing/Makefile &&
grep -q "VM_MODE=test" ../testing/Makefile &&
grep -Fq "VMS_DIR=\"\${VM_ROOT}/vms\"" vm/run.sh &&
- grep -Fq "mktemp -d \"\${VMS_DIR}/\${VM_MODE}-XXXXXX\"" \
+ grep -Fq "mktemp -d \"\${VMS_DIR}/\${VM_MODE}\${VM_SUITE:+-\$VM_SUITE}-XXXXXX\"" \
vm/run.sh &&
grep -q "VM_TENANT" vm/run.sh &&
grep -q "while :; do sleep 3600; done" vm/run.sh
@@ -907,9 +910,12 @@ test_expect_success 'host and target runners split the tests by number' '
sh >"$WORK/host-tests" &&
grep -q "^functional/upatch/t3001-" "$WORK/host-tests" &&
! grep -q "/t[0-9]1[0-9][0-9]-" "$WORK/host-tests" &&
- for t in functional/*/t[0-9]1[0-9][0-9]-*.sh e2e/t[0-9]1[0-9][0-9]-*.sh; do
- cat run-target-tests.sh run-target-obs-tests.sh \
- run-target-tree-tests.sh | grep -qF "$t" || return 1
+ families=$(make -s -C .. -f testing/Makefile help |
+ sed -n "s/.*families: //p") &&
+ [ "$families" = "register signing upatch tpm image tamperproof bpm otel e2e" ] &&
+ for t in functional/*/t[0-9]1[0-9][0-9]-*.sh; do
+ f=${t#functional/}
+ case " $families " in *" ${f%%/*} "*) ;; *) return 1 ;; esac
done
'
@@ -927,17 +933,23 @@ test_expect_success 'image VM requires initrd enrollment and complete guards' '
grep -q "TEST_VM_SKIP_SEAL=0" "$WORK/image-seal.out"
'
-test_expect_success 'image VM refuses an incompatible partial suite' '
- ! TEST_VM_MODE=verity TEST_VM_INITRD=1 TEST_VM_SUITE=tree "$RUNNER" \
+test_expect_success 'test VM takes register or a test family' '
+ ! TEST_VM_MODE=verity TEST_VM_INITRD=1 TEST_VM_SUITE=all "$RUNNER" \
>"$WORK/image-suite.out" 2>&1 &&
- grep -q "dm-verity requires the complete test suite" "$WORK/image-suite.out"
+ grep -q "TEST_VM_SUITE must be register, e2e or a directory" \
+ "$WORK/image-suite.out" &&
+ ! TEST_VM_MODE=verity TEST_VM_INITRD=1 TEST_VM_SUITE= "$RUNNER" \
+ >"$WORK/image-suite.out" 2>&1 &&
+ grep -q "test mode requires TEST_VM_SUITE" "$WORK/image-suite.out"
'
test_expect_success 'image target runner refuses missing fixture configuration' '
! SHIRUDO_TEST_MODE=verity SHIRUDO_BIN=/bin/true \
SHIRUDO_TEST_FIXTURES_DIR= SHIRUDO_TEST_KEY_FIXTURES= \
- sh ./run-target-tests.sh >"$WORK/target-fixtures.out" 2>&1 &&
- grep -q "signed upatch fixtures are required" "$WORK/target-fixtures.out"
+ sh ./run-target-tests.sh upatch >"$WORK/target-fixtures.out" 2>&1 &&
+ grep -q "signed upatch fixtures are required" "$WORK/target-fixtures.out" &&
+ ! sh ./run-target-tests.sh nosuch >"$WORK/target-family.out" 2>&1 &&
+ grep -q "no test family nosuch" "$WORK/target-family.out"
'
test_done
diff --git a/testing/functional/tamperproof/t6117-signed-metadata.sh b/testing/functional/tamperproof/t6117-signed-metadata.sh
index 8437ba80..e94318ee 100755
--- a/testing/functional/tamperproof/t6117-signed-metadata.sh
+++ b/testing/functional/tamperproof/t6117-signed-metadata.sh
@@ -24,7 +24,7 @@ B=/run/shirudo/bpffs/upatches
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
[ -s "$KP" ] && [ -s "$KP_UNLOAD" ] || test_skip_all "missing scope kprobe fixture"
-[ -e "$BASIC_PIN" ] || test_skip_all "basic fixture is not loaded"
+require_loaded shirudo-test-basic || test_skip_all "cannot load the basic fixture"
[ ! -e "$B/shirudo-test-scope-kprobe" ] || test_skip_all "scope kprobe fixture is loaded"
# Rewrite the header name, or a string inside one signed section named
diff --git a/testing/functional/upatch/t3104-payload-mismatch.sh b/testing/functional/upatch/t3104-payload-mismatch.sh
index 9a23b428..dbab37af 100644
--- a/testing/functional/upatch/t3104-payload-mismatch.sh
+++ b/testing/functional/upatch/t3104-payload-mismatch.sh
@@ -16,7 +16,7 @@ FIXTURES=${SHIRUDO_TEST_FIXTURES_DIR:?target fixture directory is not set}
UP=shirudo-test-basic
UNLOAD="$FIXTURES/shirudo-test-basic-mismatch.unload.upatch"
PIN="/run/shirudo/bpffs/upatches/$UP/link"
-[ -e "$PIN" ] || test_skip_all "basic fixture is not loaded"
+require_loaded "$UP" || test_skip_all "cannot load the basic fixture"
[ -s "$UNLOAD" ] || test_skip_all "missing prebuilt mismatch unload fixture"
test_expect_success 'wrong expected payload -> payload_mismatch, pin intact' '
diff --git a/testing/integration-lib.sh b/testing/integration-lib.sh
index 306664b9..473ad092 100644
--- a/testing/integration-lib.sh
+++ b/testing/integration-lib.sh
@@ -7,22 +7,17 @@
# These exercise the LIVE kernel (BPF LSM, kernel keyring, bpffs) and
# the installed binary, so they run as root against a target where `shirudo
# init` has already attached the LSM. shirudo is single-tenant with
-# hardcoded paths, so there is no isolation: intended for a dedicated
-# throwaway host (the CI vTPM runner) or a developer who has read what
-# the test does. The t11xx tests here are all NON-destructive -- they
-# assert refusal/denial paths and leave kernel/keyring state untouched.
+# hardcoded paths, so there is no isolation: intended for the test VM each
+# family of target tests (t?1??) boots, or a developer who has read what
+# the test does.
#
-# Sourced after a leading `cd "$(dirname "$0")"` in each test.
+# Sourced from testing/, where each test changes to first.
-INTEGRATION_TESTING_DIR=.
-[ -f "$INTEGRATION_TESTING_DIR/test-lib.sh" ] ||
- INTEGRATION_TESTING_DIR=..
-. "$INTEGRATION_TESTING_DIR/test-lib.sh"
+. ./test-lib.sh
-# Binary under test (the one that init'd the host) and the operator-side
-# builder. Overridable for out-of-tree layouts.
+# Binary under test, the one that init'd the host; overridable for
+# out-of-tree layouts.
: "${SHIRUDO_BIN:=/usr/local/bin/shirudo}"
-: "${SHIRUDO_BUILD_BIN:=$INTEGRATION_TESTING_DIR/../tools/shirudo-build/shirudo-build}"
# Skip the whole script unless every precondition holds.
target_guard() {
@@ -34,14 +29,13 @@ target_guard() {
test_skip_all "LSM not attached; run \`shirudo init\` first"
}
-# Echo the name of an arbitrary currently-loaded upatch, or "" if none.
-first_loaded_upatch() {
- for d in /run/shirudo/bpffs/upatches/*/; do
- [ -e "$d/link" ] || continue
- basename "$d"
- return 0
- done
- return 0
+# Load the signed fixture $1 unless it is loaded already: a family's tests
+# boot a VM of their own and find loaded only what they load themselves.
+require_loaded() {
+ [ -e "/run/shirudo/bpffs/upatches/$1/link" ] ||
+ "$SHIRUDO_BIN" upatch load \
+ "${SHIRUDO_TEST_FIXTURES_DIR:?}/$1.upatch" >/dev/null 2>&1
+ [ -e "/run/shirudo/bpffs/upatches/$1/link" ]
}
# Extract a top-level JSON field from a --report=- document on stdin.
diff --git a/testing/run-target-obs-tests.sh b/testing/run-target-obs-tests.sh
deleted file mode 100755
index f48db857..00000000
--- a/testing/run-target-obs-tests.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: BSD-2-Clause
-# Copyright (c) 2026 Authors of shirudo
-
-set -eu
-
-cd "$(dirname "$0")"
-
-fail=0
-: "${SHIRUDO_TEST_SUITE_FAILURES_FILE:=}"
-for test_script in \
- e2e/t9101-kernel-obs.sh \
- e2e/t9102-kernel-obs-net.sh \
- e2e/t9103-kernel-obs-priv.sh \
- e2e/t9104-kernel-obs-dns-matrix.sh
-do
- if sh "$test_script"; then
- :
- else
- fail=$((fail + 1))
- if [ -n "$SHIRUDO_TEST_SUITE_FAILURES_FILE" ]; then
- printf '%s\n' "$test_script" \
- >>"$SHIRUDO_TEST_SUITE_FAILURES_FILE" 2>/dev/null || :
- fi
- fi
-done
-
-exit "$fail"
diff --git a/testing/run-target-tests.sh b/testing/run-target-tests.sh
index 47ba94cb..e5372d83 100755
--- a/testing/run-target-tests.sh
+++ b/testing/run-target-tests.sh
@@ -1,9 +1,22 @@
#!/bin/sh
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
+#
+# testing/run-target-tests.sh <family> -- the target tests (t?1??) of one
+# family in number order, in the test VM that family booted for itself.
+# A test that skips as a whole fails the family: every one is required.
set -eu
cd "$(dirname "$0")"
+family=${1:?usage: run-target-tests.sh <family>}
+case "$family" in
+e2e) dir=e2e ;;
+*) dir=functional/$family ;;
+esac
+[ -d "$dir" ] || {
+ printf 'no test family %s\n' "$family" >&2
+ exit 1
+}
: "${SHIRUDO_BIN:?runtime command is required}"
: "${SHIRUDO_TEST_FIXTURES_DIR:?signed upatch fixtures are required}"
: "${SHIRUDO_TEST_KEY_FIXTURES:?signed image fixtures are required}"
@@ -12,7 +25,7 @@ cd "$(dirname "$0")"
[ "$(id -u)" = 0 ] && [ -x "$SHIRUDO_BIN" ] &&
[ -e /run/shirudo/bpffs/task_authority ] &&
mountpoint -q /run/shirudo/runtime && mountpoint -q /run/shirudo/config || {
- printf 'image suite requires an initialized dm-verity target\n' >&2
+ printf 'target tests require an initialized dm-verity target\n' >&2
exit 1
}
for name in config-boot-keys config-live-new-key config-a config-b config-bad config-revoke \
@@ -34,71 +47,16 @@ export SHIRUDO_TEST_INTERRUPTION_RESULTS="$SHIRUDO_TEST_RESULTS/interruption"
export SHIRUDO_TEST_CLI_RESULTS="$SHIRUDO_TEST_RESULTS/cli"
export SHIRUDO_TEST_REVOKE_RESULTS="$SHIRUDO_TEST_RESULTS/revocation"
fail=0
-# Boot assertions precede updates; the interruption leaves state pending.
-for t in \
- functional/image/t5101-verity-boot-signers.sh \
- functional/tamperproof/t6101-mode-objects.sh \
- functional/upatch/t3101-target-fixtures.sh \
- functional/tpm/t4101-initrd.sh \
- functional/signing/t2101-keys.sh \
- functional/signing/t2102-keys-add.sh \
- functional/signing/t2103-keys-revoke.sh \
- functional/tamperproof/t6102-siggate.sh \
- functional/upatch/t3102-upatch-arena-serializer.sh \
- functional/upatch/t3103-version-gate.sh \
- functional/upatch/t3104-payload-mismatch.sh \
- functional/upatch/t3105-load-unload.sh \
- functional/tpm/t4102-tpm-chain.sh \
- functional/upatch/t3106-upatch-get.sh \
- functional/upatch/t3107-uprobe-multi.sh \
- functional/bpm/t7101-bpm-tree.sh \
- functional/bpm/t7102-bpm-tree-sequential.sh \
- functional/bpm/t7103-bpm-tree-delete.sh \
- functional/otel/t8101-map-export-all.sh \
- functional/otel/t8102-otel-backend.sh \
- functional/otel/t8103-otel-serialized-metric.sh \
- functional/tpm/t4103-nv-writer.sh \
- functional/tamperproof/t6103-lsm-deny.sh \
- functional/tamperproof/t6104-prog-load-keyring-gate.sh \
- functional/tamperproof/t6105-mount-lockdown.sh \
- functional/tamperproof/t6106-pin-rename.sh \
- functional/tamperproof/t6107-bpf-cmd-deny.sh \
- functional/tamperproof/t6108-tamper-counters.sh \
- functional/tamperproof/t6109-map-lockdown.sh \
- functional/tamperproof/t6110-pr-set-mm-identity.sh \
- functional/tamperproof/t6111-seal-scratch.sh \
- functional/tamperproof/t6112-key-permission.sh \
- functional/tamperproof/t6113-verity-authority.sh \
- functional/tamperproof/t6114-output-paths.sh \
- functional/tamperproof/t6115-archive-restore.sh \
- functional/tamperproof/t6116-attach-scope.sh \
- functional/tamperproof/t6117-signed-metadata.sh \
- functional/tamperproof/t6118-foreign-entries.sh \
- functional/tamperproof/t6119-perf-attach.sh \
- functional/tamperproof/t6120-umount-above.sh \
- functional/tamperproof/t6121-bpffs-entries.sh \
- functional/tamperproof/t6122-persist-undo.sh \
- functional/tamperproof/t6123-foreign-state-root.sh \
- functional/tamperproof/t6124-overlay-copy-up.sh \
- functional/tamperproof/t6125-tpm-identity.sh \
- functional/tamperproof/t6126-kexec.sh \
- functional/tamperproof/t6127-proc-substitution.sh \
- functional/tamperproof/t6128-register-lock.sh \
- functional/tamperproof/t6129-keyring-seal.sh \
- functional/tamperproof/t6130-verity-devices.sh \
- functional/tamperproof/t6131-verity-process.sh \
- functional/tamperproof/t6132-verity-hidden.sh \
- functional/image/t5102-verity-config.sh \
- functional/image/t5103-verity-cli.sh \
- functional/image/t5104-verity-revocation.sh \
- functional/image/t5105-verity-interruption.sh
-do
+found=0
+for t in "$dir"/t[0-9]1[0-9][0-9]-*.sh; do
+ [ -e "$t" ] || continue
+ found=1
log="$SHIRUDO_TEST_RESULTS/$(basename "$t").log"
rc=0
sh "$t" >"$log" 2>&1 || rc=$?
cat "$log"
if grep -q '^1\.\.0 # SKIP' "$log"; then
- printf 'required image suite was skipped: %s\n' "$t" >&2
+ printf 'required target test was skipped: %s\n' "$t" >&2
rc=1
fi
if [ "$rc" -ne 0 ]; then
@@ -108,4 +66,8 @@ do
fi
fi
done
+[ "$found" -eq 1 ] || {
+ printf 'family %s has no target tests\n' "$family" >&2
+ exit 1
+}
[ "$fail" -eq 0 ]
diff --git a/testing/run-target-tree-tests.sh b/testing/run-target-tree-tests.sh
deleted file mode 100755
index 1e412675..00000000
--- a/testing/run-target-tree-tests.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-# SPDX-License-Identifier: BSD-2-Clause
-# Copyright (c) 2026 Authors of shirudo
-#
-# Run the target-side BPM tree integration tests.
-
-set -eu
-
-cd "$(dirname "$0")"
-
-fail=0
-: "${SHIRUDO_TEST_SUITE_FAILURES_FILE:=}"
- for t in \
- functional/bpm/t7101-bpm-tree.sh \
- functional/bpm/t7102-bpm-tree-sequential.sh \
- functional/bpm/t7103-bpm-tree-delete.sh
-do
- if sh "$t"; then
- :
- else
- fail=$((fail + 1))
- if [ -n "$SHIRUDO_TEST_SUITE_FAILURES_FILE" ]; then
- printf '%s\n' "$t" >>"$SHIRUDO_TEST_SUITE_FAILURES_FILE" 2>/dev/null || :
- fi
- fi
-done
-
-exit "$fail"
diff --git a/testing/vm/guest.sh b/testing/vm/guest.sh
index ade06945..e79383ac 100755
--- a/testing/vm/guest.sh
+++ b/testing/vm/guest.sh
@@ -342,7 +342,7 @@ if [[ "$VM_INITRD" == 1 ]]; then
journalctl -b -u shirudo-initrd.service --no-pager | tail -40 || true
fi
-if [[ "${TEST_VM_SUITE:-all}" == register ]]; then
+if [[ "${TEST_VM_SUITE:-}" == register ]]; then
[[ "$VM_INITRD" == 0 ]] || {
log "register protocol tests must precede production initialization"
exit 1
@@ -448,32 +448,17 @@ if [[ "$VM_MODE" == interactive ]]; then
exit 0
fi
-log "running target test suite: ${TEST_VM_SUITE:-all}"
+log "running target tests: $TEST_VM_SUITE"
: >/mnt/shirudo-out/failed-tests
: >/mnt/shirudo-out/failed-suites
(
cd testing
- export SHIRUDO_BIN
- export SHIRUDO_TEST_KEY_FIXTURES="$BUNDLE/verity"
- export SHIRUDO_TEST_RESULTS=/mnt/shirudo-out/verity
- if [[ "${TEST_VM_SUITE:-all}" == obs ]]; then
- SHIRUDO_BIN="$SHIRUDO_BIN" \
- SHIRUDO_TEST_FIXTURES_DIR="$BUNDLE/fixtures" \
- SHIRUDO_TEST_FAILURES_FILE=/mnt/shirudo-out/failed-tests \
- SHIRUDO_TEST_SUITE_FAILURES_FILE=/mnt/shirudo-out/failed-suites \
- ./run-target-obs-tests.sh
- elif [[ "${TEST_VM_SUITE:-all}" == tree ]]; then
- SHIRUDO_BIN="$SHIRUDO_BIN" \
- SHIRUDO_TEST_FIXTURES_DIR="$BUNDLE/fixtures" \
- SHIRUDO_TEST_FAILURES_FILE=/mnt/shirudo-out/failed-tests \
- SHIRUDO_TEST_SUITE_FAILURES_FILE=/mnt/shirudo-out/failed-suites \
- ./run-target-tree-tests.sh
- else
- SHIRUDO_BIN="$SHIRUDO_BIN" \
- SHIRUDO_TEST_FIXTURES_DIR="$BUNDLE/fixtures" \
- SHIRUDO_TEST_FAILURES_FILE=/mnt/shirudo-out/failed-tests \
- SHIRUDO_TEST_SUITE_FAILURES_FILE=/mnt/shirudo-out/failed-suites \
- ./run-target-tests.sh
- fi
+ SHIRUDO_BIN="$SHIRUDO_BIN" \
+ SHIRUDO_TEST_KEY_FIXTURES="$BUNDLE/verity" \
+ SHIRUDO_TEST_RESULTS=/mnt/shirudo-out/verity \
+ SHIRUDO_TEST_FIXTURES_DIR="$BUNDLE/fixtures" \
+ SHIRUDO_TEST_FAILURES_FILE=/mnt/shirudo-out/failed-tests \
+ SHIRUDO_TEST_SUITE_FAILURES_FILE=/mnt/shirudo-out/failed-suites \
+ ./run-target-tests.sh "$TEST_VM_SUITE"
)
log "integration suite passed"
diff --git a/testing/vm/run.sh b/testing/vm/run.sh
index d4648036..d18fc1c1 100755
--- a/testing/vm/run.sh
+++ b/testing/vm/run.sh
@@ -3,8 +3,9 @@
# Copyright (c) 2026 Authors of shirudo
#
# Boot an Ubuntu guest with a selected Linux kernel and an swtpm vTPM.
-# In test mode it runs the live Shirudo integration suite; in interactive
-# mode it prepares the guest and leaves QEMU and swtpm running.
+# In test mode it runs the target tests of the family TEST_VM_SUITE names,
+# or the TPM register tests for "register"; in interactive mode it prepares
+# the guest and leaves QEMU and swtpm running.
#
# VM_MODE=test|interactive selects the mode. VM_NAME optionally selects a
# stable state directory; if omitted, a unique name is allocated atomically.
@@ -62,7 +63,7 @@ MEMORY="${TEST_VM_MEMORY:-4G}"
DISK_SIZE="${TEST_VM_DISK_SIZE:-30G}"
VM_TIMEOUT="${TEST_VM_TIMEOUT:-3600}"
VM_MODE="${VM_MODE:-test}"
-VM_SUITE="${TEST_VM_SUITE:-all}"
+VM_SUITE="${TEST_VM_SUITE:-}"
TEST_MODE="${TEST_VM_MODE:-verity}"
SKIP_SEAL="${TEST_VM_SKIP_SEAL:-0}"
VM_INITRD="${TEST_VM_INITRD:-1}"
@@ -159,23 +160,26 @@ validate_mode()
if [[ "$VM_SUITE" != register ]]; then
[[ "$VM_INITRD" == 1 && "$SKIP_SEAL" == 0 ]] ||
die "dm-verity requires TEST_VM_INITRD=1 and TEST_VM_SKIP_SEAL=0"
- [[ "$VM_SUITE" == all || "$VM_SUITE" == obs ]] ||
- die "dm-verity requires the complete test suite or obs"
fi
case "$VM_MODE" in
interactive|test) ;;
*) die "VM_MODE must be 'interactive' or 'test'" ;;
esac
case "$VM_SUITE" in
- all|obs) ;;
- tree)
- [[ "$VM_MODE" == test ]] || die "tree suite requires VM_MODE=test"
+ '')
+ [[ "$VM_MODE" == interactive ]] ||
+ die "test mode requires TEST_VM_SUITE: register or a test family"
;;
register)
[[ "$VM_MODE" == test && "$VM_INITRD" == 0 && "$SKIP_SEAL" == 0 ]] ||
die "register suite requires test mode without a production initrd"
;;
- *) die "TEST_VM_SUITE must be 'all', 'obs', 'tree', or 'register'" ;;
+ e2e) ;;
+ *)
+ [[ "$VM_SUITE" =~ ^[a-z0-9-]+$ &&
+ -d "$REPO_ROOT/testing/functional/$VM_SUITE" ]] ||
+ die "TEST_VM_SUITE must be register, e2e or a directory of testing/functional: $VM_SUITE"
+ ;;
esac
case "$SKIP_SEAL" in
0|1) ;;
@@ -415,10 +419,10 @@ validate_host_bundle()
die "host VM bundle has no target-test certificate: $TEST_VM_HOST_BUNDLE"
[[ -s "$TEST_VM_HOST_BUNDLE/fixtures/shirudo-test-basic.upatch" ]] ||
die "host VM bundle has no target-test fixtures: $TEST_VM_HOST_BUNDLE"
- if [[ "$VM_SUITE" == obs ]]; then
+ if [[ "$VM_SUITE" == e2e ]]; then
[[ -s "$TEST_VM_HOST_BUNDLE/fixtures/kernel-obs.upatch" ]] ||
die "host VM bundle has no kernel-obs fixture: $TEST_VM_HOST_BUNDLE"
- elif [[ "$VM_SUITE" == tree ]]; then
+ elif [[ "$VM_SUITE" == bpm ]]; then
[[ -s "$TEST_VM_HOST_BUNDLE/fixtures/tree-oci/shirudo/upatch-tree/manifests/stable" &&
-s "$TEST_VM_HOST_BUNDLE/fixtures/shirudo-test-tree-match.upatch" &&
-s "$TEST_VM_HOST_BUNDLE/fixtures/shirudo-test-tree-skip.upatch" ]] ||
@@ -941,7 +945,14 @@ cleanup()
fi
if [[ "$VM_MODE" == test && -n "$RUN_DIR" && -d "$RUN_DIR" ]]; then
print_test_summary
- log "warning: the guest overlay contains an ephemeral signing key"
+ if [[ "$FINAL_STATUS" -eq 0 ]]; then
+ # A passed run keeps its logs, not the disks it booted.
+ rm -f -- "$RUN_DIR/rootfs.qcow2" "$RUN_DIR/initrd.img" \
+ "$RUN_DIR/seed.img"
+ rm -rf -- "$RUN_DIR/initrd-seed"
+ else
+ log "warning: the guest overlay contains an ephemeral signing key"
+ fi
elif [[ -n "$RUN_DIR" && -d "$RUN_DIR" ]]; then
log "preserved VM state: $RUN_DIR"
log "warning: the guest overlay contains an ephemeral signing key"
@@ -1200,7 +1211,7 @@ allocate_run_dir()
mkdir "$RUN_DIR" || die "could not create VM state directory $RUN_DIR"
VM_NAME="$VM_NAME_REQUEST"
else
- RUN_DIR="$(mktemp -d "${VMS_DIR}/${VM_MODE}-XXXXXX")" ||
+ RUN_DIR="$(mktemp -d "${VMS_DIR}/${VM_MODE}${VM_SUITE:+-$VM_SUITE}-XXXXXX")" ||
die "could not allocate a unique VM state directory"
VM_NAME="$(basename "$RUN_DIR")"
fi