]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: Implement TEST_PREFER_QEMU and use it in one of the mkosi jobs
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 5 Dec 2024 13:01:08 +0000 (14:01 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Thu, 5 Dec 2024 15:43:11 +0000 (16:43 +0100)
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.

.github/workflows/mkosi.yml
test/README.testsuite
test/integration-test-wrapper.py

index 156b8bae89f1f480970f3aa4c85381f6ff510b9f..7d39e501a9bf0e74637c789ad254ffe66349dd2a 100644 (file)
@@ -60,48 +60,56 @@ jobs:
             llvm: 0
             cflags: "-O2 -D_FORTIFY_SOURCE=3"
             relabel: no
+            qemu: 1
           - distro: debian
             release: testing
             sanitizers: ""
             llvm: 0
             cflags: "-Og"
             relabel: no
+            qemu: 0
           - distro: ubuntu
             release: noble
             sanitizers: ""
             llvm: 0
             cflags: "-Og"
             relabel: no
+            qemu: 0
           - distro: fedora
             release: "41"
             sanitizers: ""
             llvm: 0
             cflags: "-Og"
             relabel: yes
+            qemu: 0
           - distro: fedora
             release: rawhide
             sanitizers: address,undefined
             llvm: 1
             cflags: "-Og"
             relabel: yes
+            qemu: 0
           - distro: opensuse
             release: tumbleweed
             sanitizers: ""
             llvm: 0
             cflags: "-Og"
             relabel: no
+            qemu: 0
           - distro: centos
             release: "9"
             sanitizers: ""
             llvm: 0
             cflags: "-Og"
             relabel: yes
+            qemu: 0
           - distro: centos
             release: "10"
             sanitizers: ""
             llvm: 0
             cflags: "-Og"
             relabel: yes
+            qemu: 0
 
     steps:
       - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
@@ -210,7 +218,7 @@ jobs:
         run: sudo meson compile -C build mkosi
 
       - 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
         uses: actions/upload-artifact@v4
index 3793bf44e5cabbac62fc2bc450ffff264d8a909d..b8b4c4e86400675994ef30df9e86761237812ba8 100644 (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)
 
index 09dcda92e1363dfa0fdae7a17f99db64a29e9fa7..bf0fe80d44c75b25040824fbb530897576701a9d 100755 (executable)
@@ -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)