# 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_bootloader_installed(host, zfs_root): # A ZFS root boots via ZFSBootMenu (archangel installs the EFI binary under # /efi/EFI/ZBM), so there is no GRUB; a non-ZFS root uses GRUB. if zfs_root: assert host.file("/efi/EFI/ZBM/zfsbootmenu.efi").exists, \ "ZFS root must have the ZFSBootMenu EFI binary" else: assert host.file("/boot/grub/grub.cfg").exists, \ "non-ZFS root must have a GRUB config" @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_configured(host, zfs_root): # archsetup sets FONT=ter-132n in /etc/vconsole.conf on every run. assert host.file("/etc/vconsole.conf").contains("^FONT=ter-132n"), \ "archsetup should set FONT=ter-132n in /etc/vconsole.conf" # On non-ZFS it also rebuilds the initramfs (mkinitcpio -P) so the font is # baked in for early boot. On ZFS that rebuild is skipped (the busybox ZFS # hook is incompatible with the systemd-hook switch), so the font applies at # the vconsole layer once userspace starts, not inside the initramfs. if zfs_root: return # 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): 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"