From 08844e730f9acd0874f596bb9906f1f264824eba Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 25 Jun 2026 02:27:38 -0400 Subject: test(archsetup): fix fixture scope and initramfs path in the sweep VM run #2 exposed two test bugs (archsetup itself passed clean, 53/0/0): - ScopeMismatch errors on 26 tests: the host-dependent fixtures were session-scoped, but Testinfra's host fixture is module-scoped, and a session fixture cannot request a module one. Drop those fixtures to module scope. - test_console_font_in_initramfs hardcoded /boot/initramfs-linux.img; this fleet runs linux-lts, so the image is initramfs-linux-lts.img. Pick the main (non-fallback) initramfs by glob instead. --- scripts/testing/tests/conftest.py | 12 ++++++------ scripts/testing/tests/test_boot.py | 12 ++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'scripts/testing') diff --git a/scripts/testing/tests/conftest.py b/scripts/testing/tests/conftest.py index c805de9..680c967 100644 --- a/scripts/testing/tests/conftest.py +++ b/scripts/testing/tests/conftest.py @@ -77,35 +77,35 @@ def home(target_user): return "/home/%s" % target_user -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def zfs_root(host): """True when the VM's root filesystem is ZFS (gates ZFS-specific checks).""" return host.run("findmnt -n -o FSTYPE /").stdout.strip() == "zfs" -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def has_nvme(host): """True when the VM exposes an NVMe device.""" return host.run("ls /dev/nvme0n1 2>/dev/null").rc == 0 -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def hyprland_installed(host): return host.package("hyprland").is_installed -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def dwm_installed(host): return host.file("/usr/local/bin/dwm").exists -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def compositor_running(host): """A graphical session is live (gates socket/portal checks that need one).""" return host.run("pgrep -x Hyprland").rc == 0 -@pytest.fixture(scope="session") +@pytest.fixture(scope="module") def on_slirp(host): """QEMU user-mode networking (10.0.2.x) — no multicast, so mDNS can't work.""" return "10.0.2." in host.run("ip -4 addr show").stdout diff --git a/scripts/testing/tests/test_boot.py b/scripts/testing/tests/test_boot.py index c8895ae..fdbe7cb 100644 --- a/scripts/testing/tests/test_boot.py +++ b/scripts/testing/tests/test_boot.py @@ -28,10 +28,14 @@ def test_mkinitcpio_hooks(host, zfs_root): @pytest.mark.attribution("archsetup") def test_console_font_in_initramfs(host): - out = host.run( - "lsinitcpio /boot/initramfs-linux.img 2>/dev/null | grep -cE 'consolefont.psf|ter-'" - ) - assert int((out.stdout.strip() or "0")) > 0, "console font not found in initramfs" + # Pick the main initramfs (this fleet runs linux-lts, so the name is + # initramfs-linux-lts.img, not initramfs-linux.img); skip the fallback image. + img = host.run( + "ls /boot/initramfs-*.img 2>/dev/null | grep -v fallback | head -1" + ).stdout.strip() + assert img, "no initramfs image found under /boot" + out = host.run("lsinitcpio %s 2>/dev/null | grep -cE 'consolefont.psf|ter-'" % img) + assert int((out.stdout.strip() or "0")) > 0, "console font not found in %s" % img def test_nvme_module_when_nvme_present(host, has_nvme): -- cgit v1.2.3