Repository navigation
tests: tests/run, a runner on per-test metadata, and test machines as fixtures - #65
Merged
Merged
Conversation
… images tests/testmachine.py builds a machine from a tests/mkbusybox.py image: the image's kernel and machine arguments with an initramfs holding the image's busybox and tests/programs/agent.c as /init, snapshotted at the agent's first poll and cached next to the image (or $TESTMACHINE_CACHE). A test copies the snapshot and reverts to it in about half a second, then puts files, runs commands and gets files through hypercalls and guest memory instead of the serial console. Machines exist for x86_64, aarch64 and arm (busybox-armel). testmachine.machine_dir() names a machine's cache directory without building it, so that a runner can tell whether the machine exists. tests/programs/sys.h is the freestanding programs' per-arch system layer (system calls, numbers, penguin's hypercall instruction, clone onto a stack, _start). build.sh builds <name>.c programs with the nixpkgs cross gcc, and takes the names to build as arguments.
Each test file declares a literal PANDA_TEST dict (area, tier, arches, fixture, plugins, variants, xfail, ...). tests/pandatest, a pytest plugin, reads it with ast, so collecting imports neither pandare2 nor an engine, and makes one item per test, arch and variant, with an id such as testmachine[x86_64,intel=1,smp=4]. tests/run selects items by area, name, tier and arch, lists them and explains why each is selected or skipped. Each item runs in its own process, pinned with taskset, with a work directory and TMPDIR of its own; busybox and cloud images are copied into it as run.sh does. Static and harness items run in parallel. Guest items run one at a time, each after a resource guard (free disk, MemAvailable, no build running) that skips the item with its reason when it fails. Results are JUnit XML and a JSON record per item (outcome, reason, duration, log, fixture identity) with the engine build's tree, revision and whether it had uncommitted changes. An xfail entry that passes is reported as XPASS and fails the run. Fixtures are named: busybox-<arch>, testmachine-<arch>[-smpN][-intel] and cloud-<distro>-<arch> resolve to cached paths, each with an identity; the locations can be pointed at existing images. A missing fixture skips its items unless --build-fixtures is given. The static tier, the construct and multi harnesses, smoke, the busybox taint tests and testmachine.py have metadata. The flake check flake-checks (tests/static/flake_checks.py) checks that every flake check running a test script is the nix_check its metadata names.
…s for arches Each variant dimension has a default value (overridable per test), and --variants default runs each variant at its default only. A guest item whose resource guard fails waits for it, up to $PANDATEST_GUARD_WAIT seconds, before it is skipped (--no-wait: skipped at once). Arches are named by their engine target in item ids, metadata and --arch, with mkbusybox's names as aliases. Item id globs take brackets literally. The dev shell's Python has pytest, for tests/run.
lacraig2
force-pushed
the
test-runner
branch
from
November 13, 2026 16:03
d6d1338 to
65474cd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A test runner driven by per-test metadata, plus the test machines it uses as fixtures. This is the base for selecting tests by what a change touches. This PR only adds the runner.
run.sh,guest.ymlandci.ymlare unchanged.Test machines
tests/testmachine.pyturns atests/mkbusybox.pyimage into a machine for tests that run guest programs:tests/programs/agent.c) as/init.tests/README.mdlists what another arch needs: an image, the system layer inprograms/sys.h, the agent build and the machine entry.Metadata and
tests/runEach test file declares a literal
PANDA_TEST = dict(...). Its fields:area,tier,arches,fixture,pluginsvariantsxfailalwaysargs/envneedstimeoutnix_checktests/pandatest, a pytest plugin, reads the metadata withast. Collecting tests therefore imports neither pandare2 nor an engine. It makes one item per test, arch and variant, with an id such astestmachine[x86_64,intel=1,smp=4].tests/run:$PANDATEST_GUARD_WAIT, then skips the item with the reason.--variants defaultruns each variant dimension at its default only.Fixtures are named:
busybox-<arch>testmachine-<arch>[-smpN][-intel]cloud-<distro>-<arch>Each name resolves to a cached path with an identity. A missing fixture skips its items unless
--build-fixturesis given.Metadata is added for:
testmachine.py.The new flake check
flake-checks(tests/static/flake_checks.py) checks that every flake check that runs a test script is thenix_checkits metadata names. The dev shell's Python gains pytest.Testing
Against
nix build .#python, with fixtures built by--build-fixturesfromtests/busybox.shimages.tests/run --arch x86_64,aarch64: 29 pass, 48 skip, each with its reason.construct,multismoketaint,taint_mmio,taint_errorstestmachinetests/runThe other checks:
tests/busybox.sh(12 arches)tests/smoke.py x86_64nix flake checkflake-checksexamples/consumerflake check