test: Implement TEST_PREFER_QEMU and use it in one of the mkosi jobs

We want to make sure the integration tests that don't require qemu
can run successfully both in an nspawn container and in a qemu VM.
So let's add one more knob TEST_PREFER_QEMU=1 to run jobs that normally
require nspawn in qemu instead.

Running these tests in qemu is also possible by not running as root but
that's very implicit so we add an explicit knob instead to make it explicit
that we want to run these in qemu instead of nspawn.
This commit is contained in:
Daan De Meyer
2024-12-05 16:43:11 +01:00
parent 82d00f0cc6
commit e022e73e3f
3 changed files with 12 additions and 2 deletions
+2
View File
@@ -199,6 +199,8 @@ $ sudo NO_BUILD=1 test/run-integration-tests
`TEST_PREFER_NSPAWN=1`: Run all tests that do not require qemu under
systemd-nspawn.
`TEST_PREFER_QEMU=1`: Run all tests under qemu.
`TEST_NO_KVM=1`: Disable qemu KVM auto-detection (may be necessary when you're
trying to run the *vanilla* qemu and have both qemu and qemu-kvm installed)
+1 -1
View File
@@ -381,7 +381,7 @@ def main() -> None:
),
'--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}",
*(['--runtime-build-sources=no'] if not sys.stderr.isatty() else []),
'qemu' if args.vm or os.getuid() != 0 else 'boot',
'qemu' if args.vm or os.getuid() != 0 or os.getenv('TEST_PREFER_QEMU', '0') == '1' else 'boot',
] # fmt: skip
result = subprocess.run(cmd)