1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-11 20:58:27 +03:00

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 14:01:08 +01:00
parent 82d00f0cc6
commit e022e73e3f
3 changed files with 12 additions and 2 deletions

View File

@ -60,48 +60,56 @@ jobs:
llvm: 0 llvm: 0
cflags: "-O2 -D_FORTIFY_SOURCE=3" cflags: "-O2 -D_FORTIFY_SOURCE=3"
relabel: no relabel: no
qemu: 1
- distro: debian - distro: debian
release: testing release: testing
sanitizers: "" sanitizers: ""
llvm: 0 llvm: 0
cflags: "-Og" cflags: "-Og"
relabel: no relabel: no
qemu: 0
- distro: ubuntu - distro: ubuntu
release: noble release: noble
sanitizers: "" sanitizers: ""
llvm: 0 llvm: 0
cflags: "-Og" cflags: "-Og"
relabel: no relabel: no
qemu: 0
- distro: fedora - distro: fedora
release: "41" release: "41"
sanitizers: "" sanitizers: ""
llvm: 0 llvm: 0
cflags: "-Og" cflags: "-Og"
relabel: yes relabel: yes
qemu: 0
- distro: fedora - distro: fedora
release: rawhide release: rawhide
sanitizers: address,undefined sanitizers: address,undefined
llvm: 1 llvm: 1
cflags: "-Og" cflags: "-Og"
relabel: yes relabel: yes
qemu: 0
- distro: opensuse - distro: opensuse
release: tumbleweed release: tumbleweed
sanitizers: "" sanitizers: ""
llvm: 0 llvm: 0
cflags: "-Og" cflags: "-Og"
relabel: no relabel: no
qemu: 0
- distro: centos - distro: centos
release: "9" release: "9"
sanitizers: "" sanitizers: ""
llvm: 0 llvm: 0
cflags: "-Og" cflags: "-Og"
relabel: yes relabel: yes
qemu: 0
- distro: centos - distro: centos
release: "10" release: "10"
sanitizers: "" sanitizers: ""
llvm: 0 llvm: 0
cflags: "-Og" cflags: "-Og"
relabel: yes relabel: yes
qemu: 0
steps: steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@ -210,7 +218,7 @@ jobs:
run: sudo meson compile -C build mkosi run: sudo meson compile -C build mkosi
- name: Run integration tests - name: Run integration tests
run: sudo --preserve-env meson test -C build --no-rebuild --suite integration-tests --print-errorlogs --no-stdsplit --num-processes "$(($(nproc) - 1))" run: sudo --preserve-env env TEST_PREFER_QEMU=${{ matrix.qemu }} meson test -C build --no-rebuild --suite integration-tests --print-errorlogs --no-stdsplit --num-processes "$(($(nproc) - 1))"
- name: Archive failed test journals - name: Archive failed test journals
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

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 `TEST_PREFER_NSPAWN=1`: Run all tests that do not require qemu under
systemd-nspawn. 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 `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) trying to run the *vanilla* qemu and have both qemu and qemu-kvm installed)

View File

@ -381,7 +381,7 @@ def main() -> None:
), ),
'--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}", '--credential', f"journal.storage={'persistent' if sys.stderr.isatty() else args.storage}",
*(['--runtime-build-sources=no'] if not sys.stderr.isatty() else []), *(['--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 ] # fmt: skip
result = subprocess.run(cmd) result = subprocess.run(cmd)