aboutsummaryrefslogtreecommitdiff
path: root/tests/installer-steps/test_switch_udev_hook.py
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-24 12:57:29 -0500
committerCraig Jennings <c@cjennings.net>2026-07-24 12:57:29 -0500
commit249bb93b29ef471a6529d2d5bb96df87e1ac1a8a (patch)
tree055130bd142df402c9ea45e0323fc0064370c9f3 /tests/installer-steps/test_switch_udev_hook.py
parentc63a0626d3564c324f57cbbbb9eac340690dd830 (diff)
downloadarchsetup-249bb93b29ef471a6529d2d5bb96df87e1ac1a8a.tar.gz
archsetup-249bb93b29ef471a6529d2d5bb96df87e1ac1a8a.zip
fix(installer): derive the wireless regdom by pattern and retire two inert hooks
The regulatory domain came from a fixed offset, "${current_lang:3:2}", which is right only for a two-letter language code. validate_config accepts three-letter languages and glibc ships 75 of them, so ber_DZ.UTF-8 yielded "_D" and C yielded "". A garbage region matches no line in the regdom file, sed exits 0, and the || error_warn could never fire, so WiFi sat on the conservative "00" domain in silence. locale_country matches the _CC group instead of counting characters, and set_wireless_regdom verifies the substitution actually landed. That second half is the part worth keeping: every sed -i in this installer shares the stance that a no-match is indistinguishable from success, and this is the one where the silence costs something. switch_udev_hook_to_systemd now rewrites keymap and consolefont to sd-vconsole when it performs the swap. Both are busybox-only run_hook scripts, so a systemd initramfs installs them and never runs them, and this machine's own HOOKS line carries all three today. Cosmetic on a box that just boots, and not cosmetic on one asking for a passphrase with a non-US layout, which is exactly what sd-vconsole restores. The two collapse into one entry and an existing sd-vconsole is not duplicated. Before building it I answered the question the task left open. This machine is KEYMAP=us with no encrypt hook, so no prompt, but the function runs on LUKS machines where there is one, and sd-vconsole ships with mkinitcpio. 364 unit tests, exit 0. Adds tests/installer-steps/test_wireless_regdom.py (16) and 7 sd-vconsole cases. Every guard proven by deleting it, including one whose first version passed with the guard gone because a later check caught the same case.
Diffstat (limited to 'tests/installer-steps/test_switch_udev_hook.py')
-rw-r--r--tests/installer-steps/test_switch_udev_hook.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/installer-steps/test_switch_udev_hook.py b/tests/installer-steps/test_switch_udev_hook.py
index 54969e6..f6d1dc2 100644
--- a/tests/installer-steps/test_switch_udev_hook.py
+++ b/tests/installer-steps/test_switch_udev_hook.py
@@ -108,6 +108,57 @@ class SwitchUdevHookToSystemd(unittest.TestCase):
self.assertEqual(rc_of(r), 1)
self.assertNotIn("BACKUP:", r.stdout, "a declined swap must not touch the file")
+ def test_keymap_and_consolefont_become_sd_vconsole(self):
+ """Both are busybox-only run_hook scripts, so a systemd initramfs
+ installs them and never executes them. sd-vconsole is the systemd
+ equivalent, and it ships with mkinitcpio. Without this the early console
+ keeps the default font and keymap until systemd-vconsole-setup runs in
+ the real root -- cosmetic on a machine that just boots, and not cosmetic
+ at all on one that asks for a passphrase with a non-US layout."""
+ r = run("HOOKS=(base udev keymap consolefont block filesystems fsck)\n")
+ conf = r.stdout.split("CONF:[")[1]
+ self.assertIn("sd-vconsole", conf)
+ self.assertNotIn("keymap", conf)
+ self.assertNotIn("consolefont", conf)
+ self.assertEqual(rc_of(r), 0)
+
+ def test_keymap_alone_becomes_sd_vconsole(self):
+ r = run("HOOKS=(base udev keymap block filesystems)\n")
+ conf = r.stdout.split("CONF:[")[1]
+ self.assertIn("sd-vconsole", conf)
+ self.assertNotIn("keymap", conf)
+
+ def test_consolefont_alone_becomes_sd_vconsole(self):
+ r = run("HOOKS=(base udev consolefont block filesystems)\n")
+ conf = r.stdout.split("CONF:[")[1]
+ self.assertIn("sd-vconsole", conf)
+ self.assertNotIn("consolefont", conf)
+
+ def test_the_two_collapse_into_one_sd_vconsole(self):
+ r = run("HOOKS=(base udev keymap block consolefont filesystems)\n")
+ conf = r.stdout.split("CONF:[")[1].split("]")[0]
+ self.assertEqual(conf.count("sd-vconsole"), 1)
+
+ def test_an_existing_sd_vconsole_is_not_duplicated(self):
+ r = run("HOOKS=(base udev sd-vconsole keymap block filesystems)\n")
+ conf = r.stdout.split("CONF:[")[1].split("]")[0]
+ self.assertEqual(conf.count("sd-vconsole"), 1)
+ self.assertNotIn("keymap", conf)
+
+ def test_a_conf_with_neither_hook_is_unchanged_apart_from_the_swap(self):
+ r = run("HOOKS=(base udev block filesystems fsck)\n")
+ conf = r.stdout.split("CONF:[")[1]
+ self.assertNotIn("sd-vconsole", conf)
+ self.assertIn("systemd", conf)
+
+ def test_a_refused_swap_leaves_keymap_alone(self):
+ # No swap means busybox init still runs, and keymap still works there.
+ r = run("HOOKS=(base udev keymap encrypt filesystems)\n")
+ conf = r.stdout.split("CONF:[")[1]
+ self.assertIn("keymap", conf)
+ self.assertNotIn("sd-vconsole", conf)
+ self.assertEqual(rc_of(r), 1)
+
def test_tab_separated_encrypt_hook_blocks_the_swap(self):
# The token class was [( ] / [ )], which is a literal space and does
# not include a tab. mkinitcpio's HOOKS is a bash array literal, and