@@ -176,7 +176,7 @@ EXPECTED_FUNCTIONS=(
176176 get_current_subvol get_current_subvol_raw get_root_device
177177 ensure_btrfs_mounted validate_subvolume check_btrfs_space
178178 check_esp_space list_generations build_uki garbage_collect
179- delete_generation
179+ delete_generation warn_orphan_homes
180180)
181181
182182for fn in " ${EXPECTED_FUNCTIONS[@]} " ; do
@@ -1045,6 +1045,65 @@ assert_not_contains "traversal no failure" "Failed" "$_out"
10451045run_cmd populate_home_skeleton " $_PHS_TARGET " " "
10461046assert_eq " empty copy_files does not crash" " 0" " $_rc "
10471047
1048+
1049+ # ── warn_orphan_homes ──────────────────────────────
1050+
1051+ section " warn_orphan_homes"
1052+
1053+ ESP=" ${TESTDIR} /esp_woh"
1054+ BTRFS_MOUNT=" ${TESTDIR} /btrfs_woh"
1055+ mkdir -p " ${ESP} /EFI/Linux" " $BTRFS_MOUNT "
1056+ make_mock mountpoint ' exit 0'
1057+
1058+ # ── Tagged gen is last with that tag → warns ──
1059+ mkdir -p " ${BTRFS_MOUNT} /home-vim"
1060+ touch " ${ESP} /EFI/Linux/arch-20260320-034104-vim.efi"
1061+ # No other UKI with tag "vim"
1062+
1063+ run_cmd warn_orphan_homes " 20260320-034104-vim"
1064+ assert_contains " warns about orphan home-vim" " home-vim" " $_out "
1065+ assert_contains " shows removal hint" " btrfs subvolume delete" " $_out "
1066+
1067+ # ── Another gen with same tag exists → no warning ──
1068+ touch " ${ESP} /EFI/Linux/arch-20260321-010000-vim.efi"
1069+
1070+ run_cmd warn_orphan_homes " 20260320-034104-vim"
1071+ assert_not_contains " no warning when other vim gen exists" " home-vim" " $_out "
1072+
1073+ rm -f " ${ESP} /EFI/Linux/arch-20260321-010000-vim.efi"
1074+
1075+ # ── Both gens with same tag deleted at once → warns ──
1076+ touch " ${ESP} /EFI/Linux/arch-20260321-010000-vim.efi"
1077+
1078+ run_cmd warn_orphan_homes " 20260320-034104-vim" " 20260321-010000-vim"
1079+ assert_contains " warns when all vim gens deleted" " home-vim" " $_out "
1080+
1081+ rm -f " ${ESP} /EFI/Linux/arch-20260321-010000-vim.efi"
1082+
1083+ # ── Untagged gen → no warning ──
1084+ run_cmd warn_orphan_homes " 20260320-034104"
1085+ assert_eq " untagged gen → no output" " " " $_out "
1086+
1087+ # ── No home subvolume for tag → no warning ──
1088+ rm -rf " ${BTRFS_MOUNT} /home-vim"
1089+ touch " ${ESP} /EFI/Linux/arch-20260320-034104-vim.efi"
1090+
1091+ run_cmd warn_orphan_homes " 20260320-034104-vim"
1092+ assert_eq " no home subvol → no output" " " " $_out "
1093+
1094+ # ── Tag substring mismatch: home-vim not warned by super-vim ──
1095+ mkdir -p " ${BTRFS_MOUNT} /home-vim"
1096+ touch " ${ESP} /EFI/Linux/arch-20260322-010000-super-vim.efi"
1097+
1098+ run_cmd warn_orphan_homes " 20260322-010000-super-vim"
1099+ assert_not_contains " super-vim does not affect home-vim" " home-vim" " $_out "
1100+
1101+ rm -f " ${ESP} /EFI/Linux/arch-20260322-010000-super-vim.efi"
1102+
1103+ # Cleanup
1104+ rm -f " ${ESP} /EFI/Linux/arch-20260320-034104-vim.efi"
1105+
1106+
10481107# ── orphan home subvolumes in GC ──────────────
10491108
10501109section " garbage_collect: orphan home subvolumes"
0 commit comments