From c9156d41b13ac68938201b3519e09d1ebbc0bf32 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 18 Jan 2022 14:27:54 +0100 Subject: [PATCH] [bootloader] Extend tests and docs with a few more error cases --- src/modules/bootloader/bootloader.conf | 2 ++ .../tests/test-bootloader-efiname.py | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/modules/bootloader/bootloader.conf b/src/modules/bootloader/bootloader.conf index e2401cf11..804f3a00a 100644 --- a/src/modules/bootloader/bootloader.conf +++ b/src/modules/bootloader/bootloader.conf @@ -53,6 +53,8 @@ efiBootMgr: "efibootmgr" # @@PHRASE@@ can be used to obtain a unique 1-to-3-word suffix # from a dictionary of space-themed words # Note that these must be at the **end** of the *efiBootloaderId* value. +# There must also be at most one of them. If there is none, no suffix- +# processing is done and the *efiBootloaderId* is used unchanged. # # efiBootloaderId: "dirname" diff --git a/src/modules/bootloader/tests/test-bootloader-efiname.py b/src/modules/bootloader/tests/test-bootloader-efiname.py index bb3952b0d..a6643743f 100644 --- a/src/modules/bootloader/tests/test-bootloader-efiname.py +++ b/src/modules/bootloader/tests/test-bootloader-efiname.py @@ -27,15 +27,28 @@ for n in range(10): print(g.next()) # it's random, nothing to assert -# Check two invalid things +# Check invalid things try: g = main.get_efi_suffix_generator("derp") - raise TypeError("Shouldn't get generator") + raise TypeError("Shouldn't get generator (no indicator)") except ValueError as e: pass try: g = main.get_efi_suffix_generator("derp@@HEX@@") - raise TypeError("Shouldn't get generator") + raise TypeError("Shouldn't get generator (unknown indicator)") except ValueError as e: pass + +try: + g = main.get_efi_suffix_generator("derp@@SERIAL@@x") + raise TypeError("Shouldn't get generator (trailing garbage)") +except ValueError as e: + pass + +try: + g = main.get_efi_suffix_generator("derp@@SERIAL@@@@RANDOM@@") + raise TypeError("Shouldn't get generator (multiple indicators)") +except ValueError as e: + pass +