diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-25 19:52:46 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-25 19:52:46 -0400 |
| commit | eb379c38383f3f46e7c19ca5d1f4980182ff7ce2 (patch) | |
| tree | 658fd65db999aaad42d9905c9995a6e6c6ab58a6 /scripts | |
| parent | 05ec096cb2dcab3e1bde6081d1ddb9028b501afd (diff) | |
| download | archsetup-eb379c38383f3f46e7c19ca5d1f4980182ff7ce2.tar.gz archsetup-eb379c38383f3f46e7c19ca5d1f4980182ff7ce2.zip | |
test(archsetup): branch boot/backup checks on the ZFS boot path
The Testinfra boot and backup checks asserted btrfs behavior unconditionally, so they failed on a ZFS root once the ZFS VM path started running them. ZFS boots via ZFSBootMenu, not GRUB. archsetup skips the systemd-hook switch and the mkinitcpio rebuild on ZFS, and on a ZFS+virtio VM it never edits mkinitcpio.conf at all. Branch each check on the existing zfs_root/has_nvme fixtures: assert the ZFSBootMenu EFI binary on ZFS (GRUB on btrfs), gate the mkinitcpio.conf backup on archsetup actually editing the file, and check the console font in /etc/vconsole.conf on ZFS (the initramfs on non-ZFS).
Surfaced by the first full ZFS VM run, which completed archsetup cleanly (exit 0). These were the only 3 failures.
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/testing/tests/test_backups.py | 22 | ||||
| -rw-r--r-- | scripts/testing/tests/test_boot.py | 22 |
2 files changed, 37 insertions, 7 deletions
diff --git a/scripts/testing/tests/test_backups.py b/scripts/testing/tests/test_backups.py index 314cacc..07da5ec 100644 --- a/scripts/testing/tests/test_backups.py +++ b/scripts/testing/tests/test_backups.py @@ -6,9 +6,11 @@ helper's logic; this confirms it actually fires end-to-end — archsetup leaves <file>.archsetup.bak next to each pre-existing file it edits in place. These targets are edited unconditionally on every run (pacman.conf/makepkg.conf -always sed'd, sudoers always appended, mkinitcpio.conf HOOKS on non-ZFS), so -their backups must exist. Conditionally-edited files (locale.gen, geoclue, -fstab) aren't asserted here since their edits depend on the base image. +always sed'd, sudoers always appended), so their backups must exist. +mkinitcpio.conf is edited only conditionally (the systemd-hook switch on +non-ZFS, or the nvme module on NVMe systems), so it gets its own fixture-gated +check below. Conditionally-edited files (locale.gen, geoclue, fstab) aren't +asserted here since their edits depend on the base image. """ import pytest @@ -18,7 +20,6 @@ ALWAYS_BACKED_UP = [ "/etc/pacman.conf", "/etc/makepkg.conf", "/etc/sudoers", - "/etc/mkinitcpio.conf", ] @@ -28,3 +29,16 @@ def test_backup_created_for_edited_file(host, path): bak = host.file(path + ".archsetup.bak") assert bak.exists, "%s.archsetup.bak missing — backup_system_file did not fire" % path assert bak.is_file + + +@pytest.mark.attribution("archsetup") +def test_backup_created_for_mkinitcpio(host, zfs_root, has_nvme): + # archsetup edits /etc/mkinitcpio.conf only when it has something to change: + # the systemd-hook switch (non-ZFS only) or adding the nvme module (NVMe + # systems). A ZFS root with no NVMe touches neither, so there's no backup. + if zfs_root and not has_nvme: + pytest.skip("ZFS root + no NVMe: archsetup doesn't edit mkinitcpio.conf") + bak = host.file("/etc/mkinitcpio.conf.archsetup.bak") + assert bak.exists, \ + "/etc/mkinitcpio.conf.archsetup.bak missing — backup_system_file did not fire" + assert bak.is_file diff --git a/scripts/testing/tests/test_boot.py b/scripts/testing/tests/test_boot.py index fdbe7cb..78b4404 100644 --- a/scripts/testing/tests/test_boot.py +++ b/scripts/testing/tests/test_boot.py @@ -10,8 +10,15 @@ import pytest @pytest.mark.attribution("archsetup") -def test_grub_config_exists(host): - assert host.file("/boot/grub/grub.cfg").exists +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") @@ -27,7 +34,16 @@ def test_mkinitcpio_hooks(host, zfs_root): @pytest.mark.attribution("archsetup") -def test_console_font_in_initramfs(host): +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( |
