eBPF-based security platform
testing: run the tests by tier
Daniel Borkmann9c17cdf6df99
diff --git a/.github/scripts/target-tests.sh b/.github/scripts/tests.shsimilarity index 91%rename from .github/scripts/target-tests.shrename to .github/scripts/tests.shindex 79b358f8..fd3887a4 100755--- a/.github/scripts/target-tests.sh+++ b/.github/scripts/tests.sh@@ -2,14 +2,14 @@# SPDX-License-Identifier: BSD-2-Clause# Copyright (c) 2026 Authors of shirudo#-# .github/scripts/target-tests.sh -- run the target suite in the test VM as-# make -C testing test-tgt does on a developer's host. setup makes the-# runner the VM host: KVM, the VM's packages, a compatible LVH kernel or-# the Shirudo test kernel cache, and the OpenSSL 3.5 toolchain from-# vm-toolchain.sh. staging builds the host bundle and runs the target suite-# from a dracut initrd.+# .github/scripts/tests.sh -- run every test as make tests does on a+# developer's host. setup makes the runner the VM host: KVM, the VM's+# packages, a compatible LVH kernel or the Shirudo test kernel cache, and+# the OpenSSL 3.5 toolchain from vm-toolchain.sh. run builds and runs the+# unit, ghchecks, functional and end2end tests, each family of target tests+# in a VM of its own.#-# .github/scripts/target-tests.sh setup|staging+# .github/scripts/tests.sh setup|run## Runs as a user with passwordless sudo, from the checkout.@@ -251,9 +251,9 @@ setup() {}case "${1:-}" in-setup|staging) ;;+setup|run) ;;*)- echo "usage: $0 setup|staging" >&2+ echo "usage: $0 setup|run" >&2exit 2;;esac@@ -274,7 +274,12 @@ fi# emergency mode for instance, would otherwise hold the job for an hour.export TEST_VM_TIMEOUT=900+# The kernel restored from the cache is older than this checkout of the+# script that built it.+if [ -s "$kernel/bzImage.sha256sum" ]; then+ touch "$kernel/bzImage.sha256sum"+fi+sudo prlimit --pid "$$" --memlock=unlimited:unlimited-make -C testing test-vm-bundle-sudo -E env PATH="$PATH" make -C testing test-tgt TEST_VM_INITRD=1+sudo -E env PATH="$PATH" make testsdiff --git a/.github/workflows/deb.yml b/.github/workflows/deb.ymlindex 07a6e2bd..50dd58f0 100644--- a/.github/workflows/deb.yml+++ b/.github/workflows/deb.yml@@ -192,58 +192,6 @@ jobs:path: build/lvh-target-depskey: ${{ steps.lvh-target-deps.outputs.cache-primary-key }}- - name: Name the target kernel cache week- id: target-kernel-week- run: echo "week=$(date -u +%G-W%V)" >> "$GITHUB_OUTPUT"-- - name: Restore the cached Shirudo bpf-next kernel- id: target-kernel- uses: actions/cache/restore@v4- with:- path: artifacts/bpf-next-kernel-debs- key: test-vm-kernel-${{ steps.target-kernel-week.outputs.week }}-${{ hashFiles('testing/vm/build-kernel.sh', 'testing/vm/arch.sh', 'testing/Makefile', 'kernel/*.patch') }}-- - name: Restore the target VM image- id: target-vm-image- uses: actions/cache/restore@v4- with:- path: build/test-vm/cache- key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh') }}-- - name: Restore the target build dependencies- id: target-deps- uses: actions/cache/restore@v4- with:- path: build/target-deps- key: target-deps-${{ hashFiles('Makefile.target-deps') }}-- - name: Prepare runner with the cached Shirudo bpf-next kernel- run: .github/scripts/target-tests.sh setup-- - name: Run target tests in staging configuration- run: .github/scripts/target-tests.sh staging-- - name: Save the target build dependencies- if: always() && steps.target-deps.outputs.cache-hit != 'true' && hashFiles('build/target-deps/lib/libcrypto.a') != '' && hashFiles('build/target-deps/curl/lib/libcurl.a') != ''- uses: actions/cache/save@v4- with:- path: build/target-deps- key: ${{ steps.target-deps.outputs.cache-primary-key }}-- - name: Save the target kernel- if: always() && steps.target-kernel.outputs.cache-hit != 'true' && hashFiles('artifacts/bpf-next-kernel-debs/bzImage.sha256sum') != ''- uses: actions/cache/save@v4- with:- path: artifacts/bpf-next-kernel-debs- key: ${{ steps.target-kernel.outputs.cache-primary-key }}-- - name: Save the target VM image- if: always() && steps.target-vm-image.outputs.cache-hit != 'true' && hashFiles('build/test-vm/cache/runtime/*.qcow2') != ''- uses: actions/cache/save@v4- with:- path: build/test-vm/cache- key: ${{ steps.target-vm-image.outputs.cache-primary-key }}-- name: Upload deb packageuses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2with:diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.ymlindex ec2867d7..edff55c7 100644--- a/.github/workflows/lint.yml+++ b/.github/workflows/lint.yml@@ -47,7 +47,7 @@ jobs:# The kernel's checkpatch.pl, in strict mode, over the C sources and# the message of every commit the event covers; the script fetches- # the pinned copy it runs, and its tests then run against that copy.+ # the pinned copy it runs.- name: Run checkpatch over every commitenv:EVENT_NAME: ${{ github.event_name }}@@ -56,6 +56,3 @@ jobs:BEFORE_SHA: ${{ github.event.before }}SHA: ${{ github.sha }}run: .github/scripts/ci-commit-range.sh .github/scripts/check-style.sh-- - name: Test the checker against the fetched copy- run: sh testing/ghchecks/t0003-check-style.shdiff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.ymlindex 06c2e20d..97974c61 100644--- a/.github/workflows/sanitizers.yml+++ b/.github/workflows/sanitizers.yml@@ -12,7 +12,7 @@ permissions:contents: readjobs:- test-op:+ tests:name: ASan+UBSan (${{ matrix.compiler }})runs-on: ubuntu-lateststrategy:@@ -90,7 +90,7 @@ jobs:make -j4 SANITIZE=address,undefinedmake SANITIZE=address,undefined shirudo-buildmake -C testing SANITIZE=address,undefined test-helpers- make -C testing SANITIZE=address,undefined test-op+ make tests VM=0 SANITIZE=address,undefinedlibfuzzer:name: libFuzzerdiff --git a/.github/workflows/target-tests.yml b/.github/workflows/tests.ymlsimilarity index 79%rename from .github/workflows/target-tests.ymlrename to .github/workflows/tests.ymlindex dd72a4e0..f6fc3378 100644--- a/.github/workflows/target-tests.yml+++ b/.github/workflows/tests.yml@@ -1,25 +1,29 @@-name: Target tests+name: Testson:+ push:+ branches:+ - main+ pull_request:workflow_dispatch:permissions:contents: read-# A newer manual run supersedes the run in progress.+# A newer run for the same branch or pull request supersedes this one.concurrency:group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}cancel-in-progress: truejobs:- test-tgt:- name: Target suite in the dm-verity VM+ tests:+ name: make testsruns-on: ubuntu-latesttimeout-minutes: 150steps:- name: Check out repository- uses: actions/checkout@v4+ uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1# bpf-next moves daily; a week-old kernel still tests the tree, and# building one takes most of the run.@@ -49,10 +53,10 @@ jobs:key: test-vm-images-${{ hashFiles('testing/vm/runtime-packages', 'testing/vm/prepare-runtime.sh', 'testing/vm/build-bundle.sh', 'testing/vm/arch.sh') }}- name: Prepare the runner as the VM host- run: .github/scripts/target-tests.sh setup+ run: .github/scripts/tests.sh setup- - name: Run the target suite in the dm-verity VM- run: .github/scripts/target-tests.sh production+ - name: Run make tests+ run: .github/scripts/tests.sh run# Each part is saved once it is complete, even when a later step# fails, so that the next run does not build it again.@@ -76,3 +80,13 @@ jobs:with:path: build/test-vm/cachekey: ${{ steps.images.outputs.cache-primary-key }}++ - name: Upload the guest logs+ if: failure()+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2+ with:+ name: guest-logs+ path: |+ build/test-vm/vms/*/result+ build/test-vm/vms/*/console.log+ if-no-files-found: ignorediff --git a/.gitignore b/.gitignoreindex 1919900f..3a8e7413 100644--- a/.gitignore+++ b/.gitignore@@ -44,7 +44,7 @@# Compiled test helpers (sources are tracked)/testing/helper/*-/testing/e2e/exec-paths+/testing/end2end/exec-paths!/testing/helper/*.c!/testing/helper/*.h!/testing/helper/otel-mock.pydiff --git a/AGENTS.md b/AGENTS.mdindex 7d0c7f02..173817b1 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -336,18 +336,19 @@ one usually still compiles and passes tests.objects, vendored libbpf, test helpers and fuzz targets included;fix the warning rather than silence it. `WERROR=0` is for a compilernewer than the tree, while its new warnings get fixed.-- `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 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+- `make tests` (or `make -C testing`) runs every test, and is what CI runs;+ `make -C testing unit`, `ghchecks`, `functional` or `end2end` runs one+ tier, `unit/<suite>` or `functional/<family>` part of one. The target+ tests (`t?1??`) run as root in QEMU/swtpm VMs, one fresh VM per family;+ `VM=0` leaves them out, and `make tests VM=0+ SANITIZE=address,undefined` runs the rest under ASan and UBSan (CI does+ too). `make -C testing help` lists the suites and families.+- The target tests always boot the dm-verity runtime and signedconfig from a dracut initrd. CI runs that same required suite through- `.github/scripts/target-tests.sh`; the old root-only installer suite is gone.+ `.github/scripts/tests.sh`; the old root-only installer suite is gone.- `util/<m>.c` is unit tested by `testing/unit/<m>.c`: a change to a utilfunction adds or updates its cases there. A shell test is named- `t<F><K><NN>`, family, host (0) or target (1), and order, and lives in+ `t<F><K><NN>`, family, operator (0) or target (1), and order, and lives inits family's directory; `Documentation/testing.rst` has the families.- `make -C testing fuzz [FUZZ_SECONDS=60]` runs the libFuzzer targets in`testing/fuzz/` for the parsers of input from outside the host, underdiff --git a/Documentation/config-images.rst b/Documentation/config-images.rstindex 914182c9..80506b49 100644--- a/Documentation/config-images.rst+++ b/Documentation/config-images.rst@@ -453,7 +453,7 @@ kernel build applies the local copy under ``kernel/``.Shirudo also requires the signed-BPF kernel interfaces listed in`requirements <requirements.rst>`__.-The host tests exercise standard superblocks, exact root encoding,+The operator tests exercise standard superblocks, exact root encoding,``veritysetup`` formatting and offline verification, signature failures,durable pending selections, interrupted activation and fresh-boot history.The libtpms cases use actual PCR commands in addition to injected callbacks.@@ -476,11 +476,12 @@ initiate a reboot. A skipped required fixture fails the run.The standard harness builds and signs fixtures on the operator and deploysonly public artifacts. Run the suite with::- sudo make -C testing test-tgt+ sudo make -C testing functionalEach 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.+no family sees state another left behind; ``make -C testing+functional/image`` runs the image family alone, and ``make -j`` runs several+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 ofdiff --git a/Documentation/contributing.rst b/Documentation/contributing.rstindex fe0dbe00..638274c7 100644--- a/Documentation/contributing.rst+++ b/Documentation/contributing.rst@@ -200,11 +200,11 @@ Before sending==============* Build both profiles and the helper (``make``, ``make shirudo-build``)- and run ``make -C testing test-op``; run ``make -C testing test-tgt`` when the change- touches target-side behaviour. CI runs the target suite in both- configurations as the ``Target tests`` check. Run the host-side suite once more- with ``make -C testing SANITIZE=address,undefined test-op`` when the change- touches memory handling or binary formats; CI runs the same sweep.+ and run ``make tests``, which CI runs too; ``make -C testing+ functional/<family>`` runs the families the change touches while you+ work on it. Run ``make tests VM=0 SANITIZE=address,undefined`` when the+ change touches memory handling or binary formats; CI runs the same+ sweep.* Run ``make -C Documentation html-docs`` when the change touches ``Documentation/``;every document must render clean under docutils' strict mode.* Run ``.github/scripts/check-spdx.sh`` when the change adds a file:diff --git a/Documentation/getting-started.rst b/Documentation/getting-started.rstindex 01d20e12..d4bfd894 100644--- a/Documentation/getting-started.rst+++ b/Documentation/getting-started.rst@@ -29,9 +29,10 @@ From the checkout::make # the operator-profile shirudo binarymake shirudo-build # the operator-only build and publish helpermake target # the target binary, shirudo-target- make -C testing test-op # host-side TAP suite; no root, LSM or TPM- make -C testing SANITIZE=address,undefined test-op- # the same suite under ASan and UBSan+ make tests # every test, the target ones in VMs (root)+ make tests VM=0 # without the VMs: no root, LSM or TPM+ make tests VM=0 SANITIZE=address,undefined+ # the same under ASan and UBSan``make`` probes the toolchain and libraries and refuses an OpenSSLolder than 3.5. ``make target`` first runs ``make target-deps``, whichdiff --git a/Documentation/initrd.rst b/Documentation/initrd.rstindex 2e6071a4..2dc2ce34 100644--- a/Documentation/initrd.rst+++ b/Documentation/initrd.rst@@ -132,6 +132,6 @@ reboots automatically. The operator chooses when to reboot; trusted startupre-verifies the selected image, records a fresh BOOT event and finishes init.It does not retry the previous boot's PCR extension.-The standard disposable VM run is ``sudo make -C testing test-tgt``. It+The standard disposable VM run is ``sudo make -C testing functional``. Itexercises this initrd handoff, signed config and upatch updates, task andwritable-state protection, TPM checks and interrupted activation.diff --git a/Documentation/requirements.rst b/Documentation/requirements.rstindex 38a478d6..ce6f360d 100644--- a/Documentation/requirements.rst+++ b/Documentation/requirements.rst@@ -267,7 +267,7 @@ booting the target kernel rather than on the operator host. ``make -C testingkernel KERNEL_TAG=<tag> KERNEL_CONFIG=<the fleet's .config>`` buildssuch a kernel with its BTF, ``make -C testing vm KERNEL=<version>`` boots arelease of v7.4 or newer with a software TPM and a prepared shirudo, and-``make -C testing test-tgt`` runs the target suite in it; any VM of the operator's+``make tests`` runs the tests in it; any VM of the operator'sown serves the same purpose. A mitigation that loads and passes itsreproducer on a kernel unlike the fleet's proves nothing about thefleet.@@ -454,12 +454,12 @@ suites when validating a deployment.* ``make -C Documentation html-docs`` renders the documents withdocutils' ``rst2html`` (``python3-docutils``).-* The host-side suite, ``make -C testing test-op``, runs its Python+* The operator tests, ``make tests VM=0``, run their Pythonhelpers on the standard library alone. With the ``cryptography``module installed, ``testing/functional/tpm/t4001-tpm-wire.sh`` alsocross-checks the TPM credential blob it builds against an independentimplementation; without it that one check is skipped.-* ``make -C testing test-tgt-register`` additionally needs libtpms+* ``make -C testing functional/tpm`` additionally needs libtpmsdevelopment headers on the build host (``libtpms-dev`` on Debian andUbuntu). The prepared guest installs libtpms and the command TCTIruntime. The guest uses the TPM-held NV writer and the kernel TPMdiff --git a/Documentation/testing.rst b/Documentation/testing.rstindex fce16e02..19442b05 100644--- a/Documentation/testing.rst+++ b/Documentation/testing.rst@@ -23,7 +23,7 @@ sending a change.unit/ unit tests, util/<m>.c by unit/<m>.cghchecks/ the scripts under .github/scriptsfunctional/<family>/ one command or mechanism at a time- e2e/ whole delivery paths on a test VM+ end2end/ whole delivery paths on a test VMfuzz/ libFuzzer targets and seed corporafixtures/ BPF programs, decoders and configs thetests build from@@ -31,7 +31,7 @@ sending a change.vm/ the test VM: kernel, bundle, guesttest-lib.sh the TAP harness of the shell testsintegration-lib.sh shared setup of the target tests- run-tests.sh the unit and host tests+ run-tests.sh the unit and operator testsrun-target-tests.sh one family's target tests, in its VMEach ``functional/`` family may carry a ``test.plan.md`` that maps the cases@@ -44,9 +44,9 @@ A shell test is named ``t<F><K><NN>-<what>.sh``, the way git numbers itstest families:* ``F`` is the family, and with it the directory;-* ``K`` is ``0`` for a host test, which needs no root, kernel or TPM of its- own, and ``1`` for a target test, which runs as root in the test VM- against an initialised target;+* ``K`` is ``0`` for an operator test, which runs on the build host and+ needs no root, kernel or TPM of its own, and ``1`` for a target test,+ which runs as root in the test VM against an initialised target;* ``NN`` orders the tests of a family, and is the order they run in.=== ============================ ==========================================@@ -66,7 +66,7 @@ F Directory What it coverskeyrings, bpffs and the TPM path7 ``functional/bpm/`` packages, repositories, the upatch tree8 ``functional/otel/`` map export, status, TLS policy-9 ``e2e/`` the kernel-obs package, delivery paths+9 ``end2end/`` the kernel-obs package, delivery paths=== ============================ ==========================================A new test takes the next free number of its family and kind; a number is@@ -76,32 +76,38 @@ test does not take a name of this form.3) Running the tests---------------------``make -C testing test-unit``- Builds and runs the unit tests.--``make -C testing test-op``- Builds shirudo, the helpers and the unit tests, then runs the unit- tests and every host test in number order. ``SANITIZE=address,undefined``- builds all of it under ASan and UBSan, as CI does.--``make -C testing test-tgt``- Runs the target tests, one VM per family, booted from one bundle- through the production path: the dm-verity runtime and the signed- config from a dracut initrd. ``register`` runs the TPM register tests- before ``init``, without the production initrd. ``T="<family> ..."``- selects families, ``make -C testing test-tgt-<family>`` runs one, and- ``make -j`` boots several side by side. A VM that passed keeps its- logs and drops its disks; one that failed is kept under- ``build/test-vm/vms/`` for inspection. Needs root.+``make tests`` or ``make -C testing``+ Runs every test, tier by tier: ``unit``, ``ghchecks``, ``functional``+ and ``end2end``. CI runs the same.++``make -C testing <tier>``+ Runs one tier. ``unit/<suite>`` runs one unit suite and+ ``functional/<family>`` one family; ``make -C testing help`` lists+ them. The unit tests and the ``ghchecks/`` tests run on the build+ host.++A functional or end-to-end tier runs its operator tests first, in number+order, then its target tests: each family boots a VM of its own from one+bundle, through the production path, the dm-verity runtime and the signed+config from a dracut initrd. The tpm family also boots a VM before+``init``, without the production initrd, for the TPM register tests. The+VMs need root, and ``make -j`` boots several side by side. A VM that+passed keeps its logs and drops its disks; one that failed is kept under+``build/test-vm/vms/`` for inspection.++``VM=0`` leaves out the tests that boot a VM, for a host without KVM or+root; ``make tests VM=0 SANITIZE=address,undefined`` builds and runs the+rest under ASan and UBSan, as CI does.``make -C testing fuzz [FUZZ_SECONDS=60]``Runs every libFuzzer target on its seed corpus under ASan and UBSan.``make -C testing vm``Boots an interactive VM with a prepared shirudo, for running a test by- hand; ``make -C testing help`` lists the rest.+ hand.-The ``ghchecks/`` tests run with the host tests and need no build.+In CI, the tests workflow runs ``make tests`` and the sanitizer workflow+``make tests VM=0`` under ASan and UBSan with gcc and clang.4) Unit tests-------------@@ -151,8 +157,8 @@ finds loaded only what its family loaded; ``require_loaded <name>`` loads asigned fixture of the bundle that a test needs. A target test that skipsas a whole fails its family, since every one of them is required.-The end-to-end tests in ``e2e/`` run a shipped package against real kernel-activity and follow it out through the export path.+The end-to-end tests in ``end2end/`` run a shipped package against real+kernel activity and follow it out through the export path.6) The test VM--------------diff --git a/Documentation/tpm.rst b/Documentation/tpm.rstindex 7a411eb1..cfa79581 100644--- a/Documentation/tpm.rst+++ b/Documentation/tpm.rst@@ -684,7 +684,7 @@ context and the deferred mitigations the plan.8) Testing-----------``make -C testing test-tgt-register`` runs+``make -C testing functional/tpm`` runs``testing/functional/tpm/t4003-register.sh`` in a dedicated pre-init KVMguest. It creates the TPM-held writerand freezes its nonsecret input and public modulus in a BPF identity@@ -693,8 +693,9 @@ while the guest kernel and writersurvive. This preserves lifecycle, attestation and credential-activationcoverage, 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 in a VM of its own beside the test families.+attaches, not evidence of guard enforcement. The operator tests skip it;+``make -C testing functional/tpm`` runs it in a VM of its own before the+tpm family's.The same guest runs ``testing/functional/tpm/t4004-config-attest.sh``with a fresh native writer to cover config-PCR evidence alongside thesigned NV register.@@ -714,14 +715,14 @@ implementation, without a TPM.Post-init integration tests run only against a real kernel in the KVMguest with swtpm attached through ``/dev/tpmrm0``-(``make -C testing test-tgt``). There is no software signing fixture:+(``make -C testing functional``). There is no software signing fixture:the guest uses the production TPM-held writer and installed``shirudo`` binary. ``testing/functional/tpm/t4102-tpm-chain.sh``exercises measured loads and unloads, initialization reuse, prediction, attestation,credential activation and rejection of forged writer evidence.Prediction uses the offline command fixture rather than overriding theproduction runtime's certificate selection.-``make -C testing test-tgt`` also exercises the production initrd and+``make -C testing functional`` also exercises the production initrd andswitch-root path in ``testing/functional/tpm/t4101-initrd.sh``.``testing/helper/test-nv-cphash`` creates a separate TPM-resident writerdiff --git a/Makefile b/Makefileindex efe54aee..a67f333a 100644--- a/Makefile+++ b/Makefile@@ -50,7 +50,7 @@ export prefix exec_prefix bindir libexecdir sharedir libdir mandir completionsdisystemdunitdir dracutmodulesdir SHIRUDO_TARGET_PKG_CONFIG_PATH \SHIRUDO_TARGET_STATIC_LIBDIR-.PHONY: all help target target-deps target-deps-clean shirudo-target target-config shirudo-build bpf-deps install install-target install-operator clean distclean config+.PHONY: all help target target-deps target-deps-clean shirudo-target target-config shirudo-build bpf-deps install install-target install-operator clean distclean config testsall: config+$(Q)$(MAKE) -f Makefile.shirudo PROFILE=operator CONFIG_MK=config.mk all@@ -89,13 +89,16 @@ help:' Build: make, make target, make target-deps, make bpf-deps, make install' \' Install roles: make install-target, make install-operator' \' Package: make -C packaging help' \- ' Tests and VMs: make -C testing help' \+ ' Tests: make tests (all of them), make -C testing help' \' Documentation: make -C Documentation html-docs' \' Watch lists: make -C upatches/kernel-obs lists'shirudo-build:+$(Q)$(MAKE) -C tools/shirudo-build+tests:+ +$(Q)$(MAKE) -C testing+# config.mk is regenerated by Makefile.config from the host's pkg-config# state. Caches results until `make distclean`.bpf-deps:diff --git a/Makefile.shirudo b/Makefile.shirudoindex 339a537b..1f60637b 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -295,7 +295,7 @@ DEPS := $(DEP_OBJS:.o=.d)# ----- top-level goals ---------------------------------------------.PHONY: all install install-common install-target install-operator clean distclean check test \+.PHONY: all install install-common install-target install-operator clean distclean \test-helpers verity-test-helpers unit-tests \bpf libbpf@@ -622,7 +622,7 @@ TEST_HELPERS := $(VERITY_TEST_HELPERS) \testing/helper/test-signed-load \testing/helper/test-upatch-link-lockdown \testing/helper/test-exec-churn \- testing/e2e/exec-paths+ testing/end2end/exec-pathsTEST_HELPERS += testing/helper/test-nv-writerTEST_HELPERS += testing/helper/test-keyring-sealTEST_HELPERS += testing/helper/test-tpm-preopened@@ -792,7 +792,7 @@ testing/helper/test-exec-churn: testing/helper/test-exec-churn.c util/io.o util/@printf ' CC $@\n'$(Q)$(CC) $(CFLAGS) -o $@ $^-testing/e2e/exec-paths: testing/e2e/exec_paths.c+testing/end2end/exec-paths: testing/end2end/exec_paths.c@printf ' CC $@\n'$(Q)$(CC) $(CFLAGS) -pthread -o $@ $^@@ -990,10 +990,6 @@ $(FUZZ_TARGETS): testing/fuzz/fuzz.hfuzz-targets: $(FUZZ_TARGETS)-check test: shirudo $(TEST_HELPERS) $(UNIT_TESTS)- @printf ' TEST\n'- $(Q)cd testing && ./run-tests.sh-# ----- clean ------------------------------------------------------clean:diff --git a/testing/Makefile b/testing/Makefileindex ae9920b8..27d98ec3 100644--- a/testing/Makefile+++ b/testing/Makefile@@ -1,7 +1,9 @@# SPDX-License-Identifier: BSD-2-Clause# Copyright (c) 2026 Authors of shirudo#-# Host, VM, and kernel test targets. Run with make -C testing <target>.+# Test, VM and kernel targets. make -C testing runs every test, make -C+# testing <tier>[/<name>] one tier or part of it; make -C testing help+# lists the rest.ROOT := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))/..)MAKEFLAGS += -rR --no-print-directory@@ -13,14 +15,20 @@ elseendifexport Q V+# make tests at the top exports the install paths, and dracut takes the+# prefix it finds in the environment for the initrd a test VM boots.+unexport prefix exec_prefix bindir libexecdir sharedir libdir mandir \+ completionsdir systemdunitdir dracutmodulesdir+root-path = $(if $(filter /%,$(1)),$(1),$(ROOT)/$(1))# $(call test-vm-arch,NAME): the value testing/vm/arch.sh gives NAME.test-vm-arch = $(shell TEST_VM_ARCH='$(TEST_VM_ARCH)'; \. $(ROOT)/testing/vm/arch.sh && printf '%s' "$$$(1)")-.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-vm test-vm-clean+.DEFAULT_GOAL := all+.PHONY: all help clean unit ghchecks functional end2end build-operator build-unit \+ test-helpers \+ fuzz bundle test-vm-bundle kernel bpf-next vm vm-console vm-ssh vm-stop vm-cleanKERNEL_PATCHES ?= $(if $(wildcard $(ROOT)/kernel/*.patch),$(ROOT)/kernel/,)override KERNEL_PATCHES := $(if $(strip $(KERNEL_PATCHES)),$(call root-path,$(KERNEL_PATCHES)),)@@ -122,7 +130,7 @@ TEST_VM_BUNDLE_SOURCES := $(sort $(wildcard \$(ROOT)/tools/gen-image/shirudo-gen-* $(ROOT)/tools/gen-image/*.sh \$(ROOT)/tools/gen-image/*.in \$(ROOT)/testing/vm/files/* \- $(ROOT)/testing/e2e/*.c $(ROOT)/completion/* $(ROOT)/systemd/*.in \+ $(ROOT)/testing/end2end/*.c $(ROOT)/completion/* $(ROOT)/systemd/*.in \$(ROOT)/systemd/*.timer $(ROOT)/testing/fixtures/*.c $(ROOT)/testing/fixtures/*.lua \$(ROOT)/testing/fixtures/*.conf $(ROOT)/testing/fixtures/*.sh \$(ROOT)/testing/fixtures/*.h \@@ -150,6 +158,7 @@ $(ROOT)/config.mk: $(ROOT)/Makefile.configtest-vm-bundle: $(VM_KERNEL_DEP) $(TEST_VM_BUNDLE_STAMP)$(TEST_VM_BUNDLE_STAMP): $(TEST_VM_BUNDLE_INPUTS)+ $(Q)mkdir -p $(dir $(BUILD_LOCK))$(Q)TEST_VM_MODE="$(TEST_VM_MODE)" TEST_VM_INITRD="$(TEST_VM_INITRD)" \TEST_VM_HOST_BUNDLE="$(abspath $(TEST_VM_BUNDLE_DIR))" \TEST_VM_WORK_DIR="$(abspath $(TEST_VM_WORK_DIR))" \@@ -161,7 +170,7 @@ $(TEST_VM_BUNDLE_STAMP): $(TEST_VM_BUNDLE_INPUTS)TEST_VM_BUNDLE_STAMP="$(abspath $(TEST_VM_BUNDLE_STAMP))" \TEST_VM_BUNDLE_INPUTS="$(abspath $(TEST_VM_BUNDLE_INPUTS))" \BPF_VMLINUX_BTF="$(abspath $(VM_KERNEL_ARTIFACT_DIR)/vmlinux.btf)" \- $(ROOT)/testing/vm/build-bundle.sh+ flock $(BUILD_LOCK) $(ROOT)/testing/vm/build-bundle.shkernel: $(KERNEL_BUILD_STAMP)@@ -242,18 +251,55 @@ VM_MODE=test TEST_VM_SUITE="$(1)" VM_VERBOSE="$(TEST_VM_VERBOSE)" VM_NAME="$(2)"$(ROOT)/testing/vm/run.shendef-# 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: $(addprefix test-tgt-,$(T))--test-tgt-%: $(VM_KERNEL_DEP) test-vm-bundle+# The tiers: the unit tests, the tests of the scripts CI runs, the families+# of functional tests in number order, and the end-to-end tests. A test with+# a target number (t?1??) runs in a VM its family boots from the bundle, so+# no test finds what another family left behind; tpm boots a second VM+# before init, without the initrd, for the TPM register tests. VM=0 leaves+# out every test that boots a VM.+VM ?= 1+UNIT_SUITES := $(sort $(basename $(notdir $(filter-out %/unit.c, \+ $(wildcard $(ROOT)/testing/unit/*.c)))))+family-list = $(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)+FAMILIES := $(call family-list,[0-9])+VM_SUITES := $(call family-list,1) end2end+vm-tests = $(if $(filter 0,$(VM)),:,$(MAKE) $(addprefix vm-test-,$(1)))+.PHONY: $(addprefix unit/,$(UNIT_SUITES)) $(addprefix functional/,$(FAMILIES)) \+ $(addprefix vm-test-,register $(VM_SUITES))++all:+ +$(Q)$(MAKE) unit+ +$(Q)$(MAKE) ghchecks+ +$(Q)$(MAKE) functional+ +$(Q)$(MAKE) end2end++unit: build-unit+ $(Q)$(ROOT)/testing/run-tests.sh unit++$(addprefix unit/,$(UNIT_SUITES)): unit/%: build-unit+ $(Q)$(ROOT)/testing/run-tests.sh unit/$*++# The tests of the scripts under .github/scripts, which need no build.+ghchecks:+ $(Q)$(ROOT)/testing/run-tests.sh ghchecks++functional: build-operator+ $(Q)$(ROOT)/testing/run-tests.sh functional+ +$(Q)$(call vm-tests,$(filter-out end2end,$(VM_SUITES)))++$(addprefix functional/,$(FAMILIES)): functional/%: build-operator+ $(Q)$(ROOT)/testing/run-tests.sh functional/$*+ +$(Q)$(call vm-tests,$(filter $*,$(VM_SUITES)))++end2end: build-operator+ $(Q)$(ROOT)/testing/run-tests.sh end2end+ +$(Q)$(call vm-tests,end2end)++vm-test-tpm: vm-test-register++$(addprefix vm-test-,register $(VM_SUITES)): vm-test-%: $(VM_KERNEL_DEP) test-vm-bundle$(Q)$(call run-target-vm,$*,$(if $(VM_NAME),$(VM_NAME)-$*),$(if $(filter register,$*),0,1))vm-stop:@@ -264,25 +310,23 @@ vm-clean:$(Q)VM_NAME="$(VM_NAME)" \TEST_VM_WORK_DIR="$(TEST_VM_WORK_DIR)" $(ROOT)/testing/vm/run.sh --clean-test-vm-clean: vm-clean+# The operator build and the bundle build compile in the same tree, one at+# a time.+BUILD_LOCK := $(ROOT)/build/.testing-build.lock++build-operator: build-unit+ +$(Q)flock $(BUILD_LOCK) $(MAKE) -C $(ROOT) shirudo-build+ +$(Q)flock $(BUILD_LOCK) $(MAKE) -C $(ROOT) -f Makefile.shirudo test-helpers-test-op:- +$(Q)$(MAKE) -C $(ROOT) all- +$(Q)$(MAKE) -C $(ROOT) shirudo-build- +$(Q)$(MAKE) -C $(ROOT) -f testing/Makefile test-helpers- +$(Q)$(MAKE) -C $(ROOT) -f Makefile.shirudo check+build-unit:+ $(Q)mkdir -p $(dir $(BUILD_LOCK))+ +$(Q)flock $(BUILD_LOCK) $(MAKE) -C $(ROOT) all+ +$(Q)flock $(BUILD_LOCK) $(MAKE) -C $(ROOT) -f Makefile.shirudo unit-teststest-helpers:+$(Q)$(MAKE) -C $(ROOT) config+$(Q)$(MAKE) -C $(ROOT) -f Makefile.shirudo test-helpers-test-unit:- +$(Q)$(MAKE) -C $(ROOT) config- +$(Q)$(MAKE) -C $(ROOT) -f Makefile.shirudo unit-tests- $(Q)rc=0; for t in $(ROOT)/build/unit/*; do \- [ -f "$$t" ] && [ -x "$$t" ] || continue; "$$t" || rc=1; \- done; exit $$rc-# The parsers of input from outside the host under libFuzzer, each target# for FUZZ_SECONDS on its seed corpus; needs clang with its fuzzer runtime.FUZZ_SECONDS ?= 60@@ -294,27 +338,21 @@ fuzz:bundle: test-vm-bundle-test-vm: test-tgt--test:- +$(Q)$(MAKE) -C $(ROOT) -f testing/Makefile bundle- +$(Q)$(MAKE) -C $(ROOT) -f testing/Makefile test-op- +$(Q)$(MAKE) -C $(ROOT) -f testing/Makefile test-tgt-help:@printf '%s\n' \- 'Testing targets:' \- ' make -C testing test' \- ' make -C testing test-op' \- ' make -C testing test-unit' \- ' make -C testing test-helpers' \+ 'Testing targets (make tests at the top runs the first):' \+ ' make -C testing every test' \+ ' make -C testing unit[/<suite>] suites: $(UNIT_SUITES)' \+ ' make -C testing ghchecks the scripts CI runs' \+ ' make -C testing functional[/<family>] families: $(FAMILIES)' \+ ' make -C testing end2end' \+ ' VM=0 leaves out the tests that boot a VM, which need root;' \+ ' make -j boots several at once.' \' make -C testing fuzz [FUZZ_SECONDS=60]' \- ' 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' \- ' make -C testing bpf-next or test-vm-bundle' \+ ' make -C testing bpf-next, bundle or test-helpers' \' make -C testing clean'clean:diff --git a/testing/e2e/dns_obs_matrix.py b/testing/end2end/dns_obs_matrix.pysimilarity index 100%rename from testing/e2e/dns_obs_matrix.pyrename to testing/end2end/dns_obs_matrix.pydiff --git a/testing/e2e/exec_paths.c b/testing/end2end/exec_paths.csimilarity index 100%rename from testing/e2e/exec_paths.crename to testing/end2end/exec_paths.cdiff --git a/testing/e2e/kernel_obs_events.py b/testing/end2end/kernel_obs_events.pysimilarity index 97%rename from testing/e2e/kernel_obs_events.pyrename to testing/end2end/kernel_obs_events.pyindex b2084e0d..d00602e8 100755--- a/testing/e2e/kernel_obs_events.py+++ b/testing/end2end/kernel_obs_events.py@@ -27,26 +27,26 @@ def exec_event():shutil.copyfile("/bin/true", executable)os.chmod(executable, 0o755)subprocess.run([executable], check=True)- subprocess.run(["./e2e/exec-paths", directory], check=True)+ subprocess.run(["./end2end/exec-paths", directory], check=True)for method in ("execveat-empty", "fexecve"):fd_executable = os.path.join(directory, f"true-{method}")shutil.copyfile("/bin/true", fd_executable)os.chmod(fd_executable, 0o755)- subprocess.run(["./e2e/exec-paths", f"--{method}",+ subprocess.run(["./end2end/exec-paths", f"--{method}",fd_executable], check=True)dirfd_executable = os.path.join(directory, "true-execveat-dirfd")shutil.copyfile("/bin/true", dirfd_executable)os.chmod(dirfd_executable, 0o755)- subprocess.run(["./e2e/exec-paths",+ subprocess.run(["./end2end/exec-paths","--execveat-dirfd", directory,os.path.basename(dirfd_executable)], check=True)dropped_uid_executable = os.path.join(directory, "true-drop-euid")shutil.copyfile("/bin/true", dropped_uid_executable)os.chmod(dropped_uid_executable, 0o755)os.chmod(directory, 0o755)- subprocess.run(["./e2e/exec-paths",+ subprocess.run(["./end2end/exec-paths","--drop-euid", dropped_uid_executable], check=True)- subprocess.run(["./e2e/exec-paths", "--replace", executable],+ subprocess.run(["./end2end/exec-paths", "--replace", executable],check=True)diff --git a/testing/e2e/priv_events.py b/testing/end2end/priv_events.pysimilarity index 100%rename from testing/e2e/priv_events.pyrename to testing/end2end/priv_events.pydiff --git a/testing/e2e/t9001-dns-observability-matrix.sh b/testing/end2end/t9001-dns-observability-matrix.shsimilarity index 86%rename from testing/e2e/t9001-dns-observability-matrix.shrename to testing/end2end/t9001-dns-observability-matrix.shindex 061e00f1..2d6b820f 100755--- a/testing/e2e/t9001-dns-observability-matrix.sh+++ b/testing/end2end/t9001-dns-observability-matrix.sh@@ -8,7 +8,7 @@ cd "$(dirname "$0")/.."command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"test_expect_success 'DNS packet-case builders and batch encoding are valid' '- python3 e2e/dns_obs_matrix.py --self-test+ python3 end2end/dns_obs_matrix.py --self-test'test_donediff --git a/testing/e2e/t9101-kernel-obs.sh b/testing/end2end/t9101-kernel-obs.shsimilarity index 97%rename from testing/e2e/t9101-kernel-obs.shrename to testing/end2end/t9101-kernel-obs.shindex 3090c537..6d4ace44 100755--- a/testing/e2e/t9101-kernel-obs.sh+++ b/testing/end2end/t9101-kernel-obs.sh@@ -93,7 +93,7 @@ assert any("caller" in r for r in tables["exec"]), tables["exec"]assert any(r["caller_inferred"] and "caller" in rfor r in tables["exec"]), tables["exec"]helper_records = [r for r in tables["exec"]- if r["path"].endswith("/e2e/exec-paths")]+ if r["path"].endswith("/end2end/exec-paths")]helper = next(r for r in helper_recordsif (r.get("caller", {}).get("dev"),r.get("caller", {}).get("ino")) !=@@ -243,16 +243,16 @@ test_expect_success 'kernel-obs upatch loads with eight serializers' ''test_expect_success 'exec, net, listen, DNS, privilege and file events produce records' '- python3 e2e/kernel_obs_events.py all &&- python3 e2e/kernel_obs_events.py dns-long &&- python3 e2e/kernel_obs_events.py dns-many &&+ python3 end2end/kernel_obs_events.py all &&+ python3 end2end/kernel_obs_events.py dns-long &&+ python3 end2end/kernel_obs_events.py dns-many &&export_maps "$WORK/events.ndjson" &&python3 "$WORK/check.py" "$WORK/events.ndjson" &&python3 "$WORK/check_events.py" "$WORK/events.ndjson"'test_expect_success 'watched destinations are recorded with the metric' '- python3 e2e/kernel_obs_events.py watch &&+ python3 end2end/kernel_obs_events.py watch &&export_maps "$WORK/watch.ndjson" &&python3 "$WORK/check_watch.py" "$WORK/watch.ndjson"'@@ -263,7 +263,7 @@ test_expect_success 'an export drains the tables' ''test_expect_success 'only the touched tables carry records' '- python3 e2e/kernel_obs_events.py exec &&+ python3 end2end/kernel_obs_events.py exec &&export_maps "$WORK/exec-only.ndjson" &&python3 "$WORK/check_exec_only.py" "$WORK/exec-only.ndjson"'diff --git a/testing/e2e/t9102-kernel-obs-net.sh b/testing/end2end/t9102-kernel-obs-net.shsimilarity index 96%rename from testing/e2e/t9102-kernel-obs-net.shrename to testing/end2end/t9102-kernel-obs-net.shindex 6eb9b4ad..b02e3568 100755--- a/testing/e2e/t9102-kernel-obs-net.sh+++ b/testing/end2end/t9102-kernel-obs-net.sh@@ -103,9 +103,9 @@ test_expect_success 'socket map loads with the network serializers' ''test_expect_success 'TCP, UDP and additional socket families are recorded' '- python3 e2e/kernel_obs_events.py tcp &&- python3 e2e/kernel_obs_events.py udp &&- python3 e2e/kernel_obs_events.py sockets \+ python3 end2end/kernel_obs_events.py tcp &&+ python3 end2end/kernel_obs_events.py udp &&+ python3 end2end/kernel_obs_events.py sockets \>"$WORK/expected.json" &&export_net_maps &&python3 "$WORK/check.py" "$WORK/expected.json" "$WORK/events.ndjson"diff --git a/testing/e2e/t9103-kernel-obs-priv.sh b/testing/end2end/t9103-kernel-obs-priv.shsimilarity index 93%rename from testing/e2e/t9103-kernel-obs-priv.shrename to testing/end2end/t9103-kernel-obs-priv.shindex 0634c1cf..bf2414cf 100755--- a/testing/e2e/t9103-kernel-obs-priv.sh+++ b/testing/end2end/t9103-kernel-obs-priv.sh@@ -51,7 +51,7 @@ trap cleanup EXIT HUP INT TERM[ -s "$BPF_FILTER_UNLOAD" ] || test_skip_all "missing BPF filter unload fixture"mkfifo "$WORK/events.in" "$WORK/events.out"SHIRUDO_TEST_WORK_DIR="$WORK/events" \- python3 e2e/priv_events.py serve \+ python3 end2end/priv_events.py serve \"$WORK/events.in" "$WORK/events.out" "$WORK/expected.json" &EVENT_PID=$!exec 3>"$WORK/events.in"@@ -105,7 +105,7 @@ test_expect_success 'kernel-obs upatch loads with the priv serializer' 'test_expect_success 'non-executable mappings do not produce exec protection records' 'run_event negative &&export_priv "$WORK/negative.ndjson" &&- python3 e2e/priv_events.py check-negative \+ python3 end2end/priv_events.py check-negative \"$WORK/negative.ndjson" "$WORK/expected.json" &&export_priv "$WORK/negative-drained.ndjson"'@@ -113,7 +113,7 @@ test_expect_success 'non-executable mappings do not produce exec protection recotest_expect_success 'mprotect does not duplicate an existing executable mapping' 'run_event existing-exec &&export_priv "$WORK/existing-exec.ndjson" &&- python3 e2e/priv_events.py check-existing-exec \+ python3 end2end/priv_events.py check-existing-exec \"$WORK/existing-exec.ndjson" "$WORK/expected.json" &&export_priv "$WORK/existing-exec-drained.ndjson"'@@ -128,9 +128,9 @@ test_expect_success 'privilege events produce attributed priv records' 'export_priv "$WORK/priv.ndjson" &&"$SHIRUDO_BIN" upatch map "$NAME" exec \--json="$WORK/exec.ndjson" >/dev/null &&- python3 e2e/priv_events.py \+ python3 end2end/priv_events.py \check-exec-unknown "$WORK/exec.ndjson" &&- python3 e2e/priv_events.py check \+ python3 end2end/priv_events.py check \"$WORK/expected.json" "$WORK/priv.ndjson"'@@ -139,10 +139,10 @@ test_expect_success 'credential anomalies are recorded once per task' '"$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck \>/dev/null &&load_observability "$ANOMALY_LOAD" &&- python3 e2e/priv_events.py anomaly \+ python3 end2end/priv_events.py anomaly \"$WORK/anomaly-expected.json" &&export_priv "$WORK/anomaly.ndjson" &&- python3 e2e/priv_events.py \+ python3 end2end/priv_events.py \check-anomaly "$WORK/anomaly-expected.json" "$WORK/anomaly.ndjson"'diff --git a/testing/e2e/t9104-kernel-obs-dns-matrix.sh b/testing/end2end/t9104-kernel-obs-dns-matrix.shsimilarity index 95%rename from testing/e2e/t9104-kernel-obs-dns-matrix.shrename to testing/end2end/t9104-kernel-obs-dns-matrix.shindex 8984fc09..9bbc3654 100755--- a/testing/e2e/t9104-kernel-obs-dns-matrix.sh+++ b/testing/end2end/t9104-kernel-obs-dns-matrix.sh@@ -54,8 +54,8 @@ PYTHONtest_expect_success 'DNS observations use real loopback UDP traffic' '"$SHIRUDO_BIN" upatch load "$LOAD" --no-precheck >/dev/null 2>&1 &&- python3 e2e/kernel_obs_events.py dns-long &&- python3 e2e/kernel_obs_events.py dns-many &&+ python3 end2end/kernel_obs_events.py dns-long &&+ python3 end2end/kernel_obs_events.py dns-many &&"$SHIRUDO_BIN" upatch map "$NAME" dns --json="$WORK/dns.ndjson" >/dev/null &&python3 "$WORK/check.py" "$WORK/dns.ndjson" &&"$SHIRUDO_BIN" upatch map "$NAME" dns --json="$WORK/dns-empty.ndjson" >/dev/null &&diff --git a/testing/functional/build/t1007-test-vm-cli.sh b/testing/functional/build/t1007-test-vm-cli.shindex bc3a931a..f1947096 100755--- a/testing/functional/build/t1007-test-vm-cli.sh+++ b/testing/functional/build/t1007-test-vm-cli.sh@@ -679,7 +679,6 @@ test_expect_success 'VM stop and cleanup use the VM runner paths' 'grep -q "testing/vm/run.sh --stop" ../testing/Makefile &&grep -q "^vm-clean:" ../testing/Makefile &&grep -q "testing/vm/run.sh --clean" ../testing/Makefile &&- grep -q "^test-vm-clean: vm-clean" ../testing/Makefile &&grep -q "VM_NAME=\"\$(VM_NAME)\"" ../testing/Makefile &&grep -q "stop_pid_file" vm/run.sh &&grep -q "removed VM state and logs" vm/run.sh@@ -710,7 +709,7 @@ test_expect_success 'unnamed vm-stop stops all VMs and preserves state' 'test -e "$root/logs/two/sentinel"'-test_expect_success 'named test-vm-clean removes only the selected VM' '+test_expect_success 'named vm-clean removes only the selected VM' 'root="$WORK/named-clean" &&mkdir -p "$root/vms/one" "$root/vms/two" "$root/logs/one" \"$root/logs/two" "$root/cache" &&@@ -895,28 +894,28 @@ test_expect_success 'test-vm validates BPM OCI repository handoff as a pair' '"$WORK/missing-bpm-oci-repository.out"'-test_expect_success 'make -C testing test runs the complete pipeline in order' '- grep -q "^test-op:" ../testing/Makefile &&- ! grep -Eq "^(check:|.*\bcheck\b.*\.PHONY)" ../testing/Makefile &&- grep -q "^bundle: test-vm-bundle" ../testing/Makefile &&- grep -A5 "^test:$" ../testing/Makefile | grep -q "\$(MAKE) -C \$(ROOT) -f testing/Makefile bundle" &&- grep -A5 "^test:$" ../testing/Makefile | grep -q "\$(MAKE) -C \$(ROOT) -f testing/Makefile test-op" &&- grep -A5 "^test:$" ../testing/Makefile | grep -q "\$(MAKE) -C \$(ROOT) -f testing/Makefile test-tgt" &&- ! grep -A5 "^test:$" ../testing/Makefile | grep -q "\$(MAKE) bpf-next"+test_expect_success 'make -C testing runs every tier in order' '+ grep -A4 "^all:$" ../testing/Makefile | sed -n "2,5s/.*\$(MAKE) //p" \+ >"$WORK/tiers" &&+ [ "$(tr "\n" " " <"$WORK/tiers")" = "unit ghchecks functional end2end " ] &&+ grep -q "^bundle: test-vm-bundle" ../testing/Makefile'-test_expect_success 'host and target runners split the tests by number' '- { sed -n "/^host_tests()/,/^}/p" run-tests.sh; echo host_tests; } |- 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" &&+test_expect_success 'the runners split the tests by number' '+ { echo "dirs=\"ghchecks functional/* end2end\""+ sed -n "/^operator_tests()/,/^}/p" run-tests.sh; echo operator_tests; } |+ sh >"$WORK/operator-tests" &&+ grep -q "^functional/upatch/t3001-" "$WORK/operator-tests" &&+ ! grep -q "/t[0-9]1[0-9][0-9]-" "$WORK/operator-tests" &&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+ [ "$families" = "build signing upatch tpm image tamperproof bpm otel" ] &&+ for d in functional/*/; do+ f=${d#functional/}+ case " $families " in *" ${f%/} "*) ;; *) return 1 ;; esac+ done &&+ ! sh run-tests.sh nosuch >"$WORK/nosuch.out" 2>&1 &&+ grep -q "no tests nosuch" "$WORK/nosuch.out"'test_expect_success 'test-vm rejects unknown policy modes before boot' '@@ -936,7 +935,7 @@ test_expect_success 'image VM requires initrd enrollment and complete guards' '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 "TEST_VM_SUITE must be register, e2e or a directory" \+ grep -q "TEST_VM_SUITE must be register, end2end 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 &&diff --git a/testing/functional/otel/test.plan.md b/testing/functional/otel/test.plan.mdindex ca908108..e2e56b79 100644--- a/testing/functional/otel/test.plan.md+++ b/testing/functional/otel/test.plan.md@@ -21,7 +21,7 @@ This plan records coverage for OpenTelemetry export across host-side serializati| Target service and timer | Installed map-export service delivers decoder-backed maps; slow collector fixture checks the timer does not overlap an active export. || Serialized metrics | Two serializer pages, repeated peek, drain, subsequent empty interval, reload reset, and service export of decoder-backed cumulative metrics. || Services and packaging | Static service/timer ordering, conditions, environment file, command, cadence, install paths, operator exclusion, and Debian/RPM scriptlets. |-| TLS policy | `testing/functional/otel/t8005-tls-policy.sh` covers shared TLS policy; OTEL host tests independently check certificate verification and insecure mode where TLS prerequisites are available. |+| TLS policy | `testing/functional/otel/t8005-tls-policy.sh` covers shared TLS policy; OTEL operator tests independently check certificate verification and insecure mode where TLS prerequisites are available. |## Remaining gaps@@ -38,4 +38,4 @@ These are coverage opportunities, not findings that the implementation is incorr## Test commands-Host coverage is the `t80NN` tests `testing/run-tests.sh` runs. Target integration scripts `t8101`, `t8102`, and `t8103` require an initialized test VM and fixtures in `SHIRUDO_TEST_FIXTURES_DIR`. The shared TLS test is `testing/functional/otel/t8005-tls-policy.sh`. Run with the repository's documented `make -C testing test-op` and target harness when runtime validation is requested.+Operator coverage is the `t80NN` tests; `make -C testing functional/otel` runs them and the target ones. Target integration scripts `t8101`, `t8102`, and `t8103` require an initialized test VM and fixtures in `SHIRUDO_TEST_FIXTURES_DIR`. The shared TLS test is `testing/functional/otel/t8005-tls-policy.sh`. Run with the repository's documented `make -C testing test-op` and target harness when runtime validation is requested.diff --git a/testing/functional/tpm/register-lib.sh b/testing/functional/tpm/register-lib.shindex dedfaeb6..5d08974d 100644--- a/testing/functional/tpm/register-lib.sh+++ b/testing/functional/tpm/register-lib.sh@@ -3,7 +3,7 @@# Copyright (c) 2026 Authors of shirudo[ "${SHIRUDO_TEST_REGISTER_VM:-0}" = 1 ] ||- test_skip_all "run with make -C testing test-tgt-register (real kernel signer required)"+ test_skip_all "run with make -C testing functional/tpm (real kernel signer required)"[ "$(id -u)" = 0 ] && [ -x "$R" ] || {echo "register VM requires root and the built register helper" >&2exit 1diff --git a/testing/functional/upatch/test.plan.md b/testing/functional/upatch/test.plan.mdindex 2eaf25ab..b2eb4890 100644--- a/testing/functional/upatch/test.plan.md+++ b/testing/functional/upatch/test.plan.md@@ -40,6 +40,6 @@ this review.coverage.- `functional/upatch/t3102-upatch-arena-serializer.sh` loads the arena-tree fixture and checksthe real target serializer over its full three-page result and error path.-- `make -C testing test-op` and `make -C testing test-tgt` passed on+- `make -C testing unit functional` passed on2026-10-19, including the parser, decoder, metadata, tamper and targetarena-serializer assertions listed above.diff --git a/testing/run-target-tests.sh b/testing/run-target-tests.shindex e5372d83..ec90518f 100755--- a/testing/run-target-tests.sh+++ b/testing/run-target-tests.sh@@ -10,7 +10,7 @@ set -eucd "$(dirname "$0")"family=${1:?usage: run-target-tests.sh <family>}case "$family" in-e2e) dir=e2e ;;+end2end) dir=end2end ;;*) dir=functional/$family ;;esac[ -d "$dir" ] || {diff --git a/testing/run-tests.sh b/testing/run-tests.shindex dfdfce83..4939e1b6 100755--- a/testing/run-tests.sh+++ b/testing/run-tests.sh@@ -2,29 +2,57 @@# SPDX-License-Identifier: BSD-2-Clause# Copyright (c) 2026 Authors of shirudo#-# testing/run-tests.sh -- the unit tests, then every host test (t?0??) of-# ghchecks/, functional/ and e2e/ in number order. CI-friendly; the exit-# status counts the suites that failed.+# testing/run-tests.sh [unit[/<suite>]|ghchecks|functional[/<family>]|end2end]...+# -- the tests of each tier named, all of them without an argument, that+# run on the build host: the unit tests and the operator tests (t?0??) in+# number order. The target tests run in the test VM through+# run-target-tests.sh. CI-friendly; the exit status counts the suites that+# failed.set -eucd "$(dirname "$0")"-host_tests()+[ $# -gt 0 ] || set -- unit ghchecks functional end2end+units=+dirs=+for what; do+ case "$what" in+ unit) units="$units ../build/unit/*" ;;+ unit/*) units="$units ../build/unit/${what#unit/}" ;;+ functional) dirs="$dirs functional/*" ;;+ *) dirs="$dirs $what" ;;+ esac+ [ "$what" = unit ] || [ -e "$what" ] || [ -e "../build/$what" ] || {+ printf 'no tests %s\n' "$what" >&2+ exit 2+ }+done++unit_tests()+{+ for t in $units; do+ [ -f "$t" ] && [ -x "$t" ] && printf '%s\n' "$t"+ done+}++operator_tests(){- for t in ghchecks/t*.sh functional/*/t*.sh e2e/t*.sh; do- case "${t##*/}" in- t[0-9]0[0-9][0-9]-*.sh) printf '%s %s\n' "${t##*/}" "$t" ;;- esac+ for d in $dirs; do+ for t in "$d"/t*.sh; do+ case "${t##*/}" in+ t[0-9]0[0-9][0-9]-*.sh) printf '%s %s\n' "${t##*/}" "$t" ;;+ esac+ donedone | sort | cut -d' ' -f2}fail=0: "${SHIRUDO_TEST_SUITE_FAILURES_FILE:=}"-for t in ../build/unit/* $(host_tests); do+for t in $(unit_tests) $(operator_tests); docase "$t" in*.sh) set -- sh "$t" ;;- *) [ -f "$t" ] && [ -x "$t" ] || continue; set -- "$t" ;;+ *) set -- "$t" ;;esacif "$@"; then:diff --git a/testing/vm/build-bundle.sh b/testing/vm/build-bundle.shindex 6fcb5192..22d6b7c1 100755--- a/testing/vm/build-bundle.sh+++ b/testing/vm/build-bundle.sh@@ -317,7 +317,7 @@ make -C "$REPO_ROOT" -j"$(nproc)" -f Makefile.shirudo \install -d "$TMP_DIR/test-helpers/testing/helper" \"$TMP_DIR/test-helpers/testing/fixtures" \- "$TMP_DIR/test-helpers/testing/e2e"+ "$TMP_DIR/test-helpers/testing/end2end"while IFS= read -r helper; doinstall -m 0755 "$REPO_ROOT/$helper" "$TMP_DIR/test-helpers/$helper"done <<'EOF'@@ -343,7 +343,7 @@ testing/helper/test-upatch-serializer-pagestesting/helper/test-signed-loadtesting/helper/test-upatch-link-lockdowntesting/helper/test-exec-churn-testing/e2e/exec-paths+testing/end2end/exec-pathstesting/helper/otel-mock.pytesting/helper/test-oci-registry.pyEOFdiff --git a/testing/vm/run.sh b/testing/vm/run.shindex d18fc1c1..7355fae3 100755--- a/testing/vm/run.sh+++ b/testing/vm/run.sh@@ -15,6 +15,11 @@set -euo pipefail+# The guest boots with the host's own QEMU, swtpm and dracut; a library path+# a shirudo build needed for its OpenSSL would load the wrong libraries into+# them.+unset LD_LIBRARY_PATH+SECONDS=0if [[ -t 1 && -z "${NO_COLOR:-}" ]]; then@@ -174,11 +179,11 @@ validate_mode()[[ "$VM_MODE" == test && "$VM_INITRD" == 0 && "$SKIP_SEAL" == 0 ]] ||die "register suite requires test mode without a production initrd";;- e2e) ;;+ end2end) ;;*)[[ "$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"+ die "TEST_VM_SUITE must be register, end2end or a directory of testing/functional: $VM_SUITE";;esaccase "$SKIP_SEAL" in@@ -419,7 +424,7 @@ 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" == e2e ]]; then+ if [[ "$VM_SUITE" == end2end ]]; 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" == bpm ]]; thendiff --git a/upatches/kernel-obs/dns.todo b/upatches/kernel-obs/dns.todoindex 3227cda0..a470ae68 100644--- a/upatches/kernel-obs/dns.todo+++ b/upatches/kernel-obs/dns.todo@@ -4,7 +4,7 @@ The UDP DNS parser correlates requests with a canonical key made fromthe network-namespace cookie, address family, client/resolver addressesand ports, and transaction ID, and attributes the answer to the queryingsocket's owner. The items below are the remaining parser and-correlation gaps. `testing/e2e/dns_obs_matrix.py` now validates+correlation gaps. `testing/end2end/dns_obs_matrix.py` now validatescase construction and batch encoding only. Its former target runner used`BPF_PROG_TEST_RUN`, which is restricted to Shirudo. The target suite useslive loopback UDP exchanges for representative query and response