aboutsummaryrefslogtreecommitdiff
path: root/scripts/testing/tests/test_boot.py
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-25 01:12:35 -0400
committerCraig Jennings <c@cjennings.net>2026-06-25 01:12:35 -0400
commit3cac3b3dfcd432395201a309920c2491ee9caf01 (patch)
tree45c3ea7f8b73f7375c484912ecadc8a65c4d88a5 /scripts/testing/tests/test_boot.py
parent99a26d7de23bbfc757957c08e47606c3690df4cb (diff)
downloadarchsetup-3cac3b3dfcd432395201a309920c2491ee9caf01.tar.gz
archsetup-3cac3b3dfcd432395201a309920c2491ee9caf01.zip
test(archsetup): port full shell validation sweep to Testinfra (P2)
Port all ~26 post-install checks from validation.sh to pytest/Testinfra, reaching parity before the cutover. Adds test_users, test_packages, test_services, test_desktop, test_boot, test_keyring, and test_archsetup (88 tests after parametrizing groups, services, timers, tools, and configs), plus shared conftest fixtures for ZFS/NVMe/compositor/networking gating. The shell sweep's three outcomes map cleanly: hard failures become assertions, advisory warnings and unmet preconditions (headless compositor, slirp networking, optional services, non-ZFS/non-NVMe hosts) become skips. One correctness fix vs the shell sweep: check awww, not swww — archsetup installs awww (swww's successor) and `pacman -Q swww` no longer matches. Verified on the host: py_compile clean, pytest --collect-only green (88 tests). The sweep against a real VM is verified by the make test run that follows.
Diffstat (limited to 'scripts/testing/tests/test_boot.py')
-rw-r--r--scripts/testing/tests/test_boot.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/scripts/testing/tests/test_boot.py b/scripts/testing/tests/test_boot.py
new file mode 100644
index 0000000..c8895ae
--- /dev/null
+++ b/scripts/testing/tests/test_boot.py
@@ -0,0 +1,47 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+"""Post-install checks: boot, initramfs, and filesystem config.
+
+Parity port of validate_zfs_config, validate_boot_config,
+validate_mkinitcpio_hooks, validate_initramfs_consolefont, validate_nvme_module.
+Filesystem/hardware-specific checks are gated on fixtures.
+"""
+
+import pytest
+
+
+@pytest.mark.attribution("archsetup")
+def test_grub_config_exists(host):
+ assert host.file("/boot/grub/grub.cfg").exists
+
+
+@pytest.mark.attribution("archsetup")
+def test_mkinitcpio_hooks(host, zfs_root):
+ hooks = host.run("grep '^HOOKS=' /etc/mkinitcpio.conf").stdout
+ if zfs_root:
+ # ZFS must use the udev hook; the systemd hook breaks a ZFS boot.
+ assert " udev" in hooks or "(udev" in hooks, "ZFS root must use the udev hook"
+ assert "systemd" not in hooks, "ZFS root must not use the systemd hook"
+ else:
+ # Non-ZFS: either hook is acceptable.
+ assert ("systemd" in hooks) or ("udev" in hooks)
+
+
+@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"
+
+
+def test_nvme_module_when_nvme_present(host, has_nvme):
+ if not has_nvme:
+ pytest.skip("no NVMe device present")
+ modules = host.run("grep '^MODULES=' /etc/mkinitcpio.conf").stdout
+ assert "nvme" in modules, "NVMe system should list nvme in mkinitcpio MODULES"
+
+
+def test_zfs_has_sanoid(host):
+ if not host.exists("zfs"):
+ pytest.skip("ZFS not installed (non-ZFS system)")
+ assert host.exists("sanoid"), "ZFS system should have sanoid installed"