Skip to content

eBPF-based security platform

testing: run the tests by tier

Daniel Borkmann9c17cdf6df99
diff --git a/.github/scripts/target-tests.sh b/.github/scripts/tests.sh
similarity index 91%
rename from .github/scripts/target-tests.sh
rename to .github/scripts/tests.sh
index 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" >&2
exit 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 tests
diff --git a/.github/workflows/deb.yml b/.github/workflows/deb.yml
index 07a6e2bd..50dd58f0 100644
--- a/.github/workflows/deb.yml
+++ b/.github/workflows/deb.yml
@@ -192,58 +192,6 @@ jobs:
path: build/lvh-target-deps
key: ${{ 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 package
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 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 commit
env:
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.sh
diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml
index 06c2e20d..97974c61 100644
--- a/.github/workflows/sanitizers.yml
+++ b/.github/workflows/sanitizers.yml
@@ -12,7 +12,7 @@ permissions:
contents: read
jobs:
- test-op:
+ tests:
name: ASan+UBSan (${{ matrix.compiler }})
runs-on: ubuntu-latest
strategy:
@@ -90,7 +90,7 @@ jobs:
make -j4 SANITIZE=address,undefined
make SANITIZE=address,undefined shirudo-build
make -C testing SANITIZE=address,undefined test-helpers
- make -C testing SANITIZE=address,undefined test-op
+ make tests VM=0 SANITIZE=address,undefined
libfuzzer:
name: libFuzzer
diff --git a/.github/workflows/target-tests.yml b/.github/workflows/tests.yml
similarity index 79%
rename from .github/workflows/target-tests.yml
rename to .github/workflows/tests.yml
index dd72a4e0..f6fc3378 100644
--- a/.github/workflows/target-tests.yml
+++ b/.github/workflows/tests.yml
@@ -1,25 +1,29 @@
-name: Target tests
+name: Tests
on:
+ 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: true
jobs:
- test-tgt:
- name: Target suite in the dm-verity VM
+ tests:
+ name: make tests
runs-on: ubuntu-latest
timeout-minutes: 150
steps:
- 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/cache
key: ${{ 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: ignore
diff --git a/.gitignore b/.gitignore
index 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.py
diff --git a/AGENTS.md b/AGENTS.md
index 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 compiler
newer 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 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.
+ `.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 util
function 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 in
its 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, under
diff --git a/Documentation/config-images.rst b/Documentation/config-images.rst
index 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 deploys
only public artifacts. Run the suite with::
- sudo make -C testing test-tgt
+ sudo make -C testing functional
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.
+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 of
diff --git a/Documentation/contributing.rst b/Documentation/contributing.rst
index 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.rst
index 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 binary
make shirudo-build # the operator-only build and publish helper
make 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 OpenSSL
older than 3.5. ``make target`` first runs ``make target-deps``, which
diff --git a/Documentation/initrd.rst b/Documentation/initrd.rst
index 2e6071a4..2dc2ce34 100644
--- a/Documentation/initrd.rst
+++ b/Documentation/initrd.rst
@@ -132,6 +132,6 @@ reboots automatically. The operator chooses when to reboot; trusted startup
re-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``. It
exercises this initrd handoff, signed config and upatch updates, task and
writable-state protection, TPM checks and interrupted activation.
diff --git a/Documentation/requirements.rst b/Documentation/requirements.rst
index 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 testing
kernel KERNEL_TAG=<tag> KERNEL_CONFIG=<the fleet's .config>`` builds
such a kernel with its BTF, ``make -C testing vm KERNEL=<version>`` boots a
release 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's
own serves the same purpose. A mitigation that loads and passes its
reproducer on a kernel unlike the fleet's proves nothing about the
fleet.
@@ -454,12 +454,12 @@ suites when validating a deployment.
* ``make -C Documentation html-docs`` renders the documents with
docutils' ``rst2html`` (``python3-docutils``).
-* The host-side suite, ``make -C testing test-op``, runs its Python
+* The operator tests, ``make tests VM=0``, run their Python
helpers on the standard library alone. With the ``cryptography``
module installed, ``testing/functional/tpm/t4001-tpm-wire.sh`` also
cross-checks the TPM credential blob it builds against an independent
implementation; without it that one check is skipped.
-* ``make -C testing test-tgt-register`` additionally needs libtpms
+* ``make -C testing functional/tpm`` additionally needs libtpms
development headers on the build host (``libtpms-dev`` on Debian and
Ubuntu). The prepared guest installs libtpms and the command TCTI
runtime. The guest uses the TPM-held NV writer and the kernel TPM
diff --git a/Documentation/testing.rst b/Documentation/testing.rst
index 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>.c
ghchecks/ the scripts under .github/scripts
functional/<family>/ one command or mechanism at a time
- e2e/ whole delivery paths on a test VM
+ end2end/ whole delivery paths on a test VM
fuzz/ libFuzzer targets and seed corpora
fixtures/ BPF programs, decoders and configs the
tests build from
@@ -31,7 +31,7 @@ sending a change.
vm/ the test VM: kernel, bundle, guest
test-lib.sh the TAP harness of the shell tests
integration-lib.sh shared setup of the target tests
- run-tests.sh the unit and host tests
+ run-tests.sh the unit and operator tests
run-target-tests.sh one family's target tests, in its VM
Each ``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 its
test 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 covers
keyrings, bpffs and the TPM path
7 ``functional/bpm/`` packages, repositories, the upatch tree
8 ``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 a
signed fixture of the bundle that a test needs. A target test that skips
as 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.rst
index 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 KVM
guest. It creates the TPM-held writer
and freezes its nonsecret input and public modulus in a BPF identity
@@ -693,8 +693,9 @@ while the guest kernel and writer
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 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 the
signed NV register.
@@ -714,14 +715,14 @@ implementation, without a TPM.
Post-init integration tests run only against a real kernel in the KVM
guest 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 the
production runtime's certificate selection.
-``make -C testing test-tgt`` also exercises the production initrd and
+``make -C testing functional`` also exercises the production initrd and
switch-root path in ``testing/functional/tpm/t4101-initrd.sh``.
``testing/helper/test-nv-cphash`` creates a separate TPM-resident writer
diff --git a/Makefile b/Makefile
index efe54aee..a67f333a 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ export prefix exec_prefix bindir libexecdir sharedir libdir mandir completionsdi
systemdunitdir 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 tests
all: 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.shirudo
index 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-paths
TEST_HELPERS += testing/helper/test-nv-writer
TEST_HELPERS += testing/helper/test-keyring-seal
TEST_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.h
fuzz-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/Makefile
index 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 @@ else
endif
export 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-clean
KERNEL_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.config
test-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.sh
kernel: $(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.sh
endef
-# 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-tests
test-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.py
similarity index 100%
rename from testing/e2e/dns_obs_matrix.py
rename to testing/end2end/dns_obs_matrix.py
diff --git a/testing/e2e/exec_paths.c b/testing/end2end/exec_paths.c
similarity index 100%
rename from testing/e2e/exec_paths.c
rename to testing/end2end/exec_paths.c
diff --git a/testing/e2e/kernel_obs_events.py b/testing/end2end/kernel_obs_events.py
similarity index 97%
rename from testing/e2e/kernel_obs_events.py
rename to testing/end2end/kernel_obs_events.py
index 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.py
similarity index 100%
rename from testing/e2e/priv_events.py
rename to testing/end2end/priv_events.py
diff --git a/testing/e2e/t9001-dns-observability-matrix.sh b/testing/end2end/t9001-dns-observability-matrix.sh
similarity index 86%
rename from testing/e2e/t9001-dns-observability-matrix.sh
rename to testing/end2end/t9001-dns-observability-matrix.sh
index 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_done
diff --git a/testing/e2e/t9101-kernel-obs.sh b/testing/end2end/t9101-kernel-obs.sh
similarity index 97%
rename from testing/e2e/t9101-kernel-obs.sh
rename to testing/end2end/t9101-kernel-obs.sh
index 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 r
for 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_records
if (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.sh
similarity index 96%
rename from testing/e2e/t9102-kernel-obs-net.sh
rename to testing/end2end/t9102-kernel-obs-net.sh
index 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.sh
similarity index 93%
rename from testing/e2e/t9103-kernel-obs-priv.sh
rename to testing/end2end/t9103-kernel-obs-priv.sh
index 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 reco
test_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.sh
similarity index 95%
rename from testing/e2e/t9104-kernel-obs-dns-matrix.sh
rename to testing/end2end/t9104-kernel-obs-dns-matrix.sh
index 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 @@ PYTHON
test_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.sh
index 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.md
index 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.sh
index 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" >&2
exit 1
diff --git a/testing/functional/upatch/test.plan.md b/testing/functional/upatch/test.plan.md
index 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 checks
the 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 on
2026-10-19, including the parser, decoder, metadata, tamper and target
arena-serializer assertions listed above.
diff --git a/testing/run-target-tests.sh b/testing/run-target-tests.sh
index e5372d83..ec90518f 100755
--- a/testing/run-target-tests.sh
+++ b/testing/run-target-tests.sh
@@ -10,7 +10,7 @@ set -eu
cd "$(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.sh
index 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 -eu
cd "$(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
+ done
done | 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); do
case "$t" in
*.sh) set -- sh "$t" ;;
- *) [ -f "$t" ] && [ -x "$t" ] || continue; set -- "$t" ;;
+ *) set -- "$t" ;;
esac
if "$@"; then
:
diff --git a/testing/vm/build-bundle.sh b/testing/vm/build-bundle.sh
index 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; do
install -m 0755 "$REPO_ROOT/$helper" "$TMP_DIR/test-helpers/$helper"
done <<'EOF'
@@ -343,7 +343,7 @@ testing/helper/test-upatch-serializer-pages
testing/helper/test-signed-load
testing/helper/test-upatch-link-lockdown
testing/helper/test-exec-churn
-testing/e2e/exec-paths
+testing/end2end/exec-paths
testing/helper/otel-mock.py
testing/helper/test-oci-registry.py
EOF
diff --git a/testing/vm/run.sh b/testing/vm/run.sh
index 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=0
if [[ -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"
;;
esac
case "$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 ]]; then
diff --git a/upatches/kernel-obs/dns.todo b/upatches/kernel-obs/dns.todo
index 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 from
the network-namespace cookie, address family, client/resolver addresses
and ports, and transaction ID, and attributes the answer to the querying
socket'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 validates
case construction and batch encoding only. Its former target runner used
`BPF_PROG_TEST_RUN`, which is restricted to Shirudo. The target suite uses
live loopback UDP exchanges for representative query and response