Skip to contentSkip to conversation

tests/lib/functional_test: Unregister commands on module unload

PATCH In review Daniel Kiper via Grub-devel 1 participant 1 message Nov 18, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 6/8 tests/lib/functional_test: Unregister commands on module unload

From: Alec Brown <[email protected]>

When the functional_test module is loaded, both the functional_test and all_functional_test commands are registered but only the all_functional_test command is being unregistered since it was the last to set the cmd variable that gets unregistered when the module is unloaded. To unregister both commands, we need to create an additional grub_extcmd_t variable.

---
 grub-core/tests/lib/functional_test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
grub-core/tests/lib/functional_test.c +4 -3
index 94a606bf9..776934e1f 100644
@@ -92,17 +92,18 @@ grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)),
   return GRUB_ERR_NONE;
 }
 
-static grub_extcmd_t cmd;
+static grub_extcmd_t cmd, cmd_all;
 
 GRUB_MOD_INIT (functional_test)
 {
   cmd = grub_register_extcmd ("functional_test", grub_functional_test, 0, 0,
 			      "Run all loaded functional tests.", 0);
-  cmd = grub_register_extcmd ("all_functional_test", grub_functional_all_tests, 0, 0,
-			      "Run all functional tests.", 0);
+  cmd_all = grub_register_extcmd ("all_functional_test", grub_functional_all_tests, 0, 0,
+				  "Run all functional tests.", 0);
 }
 
 GRUB_MOD_FINI (functional_test)
 {
   grub_unregister_extcmd (cmd);
+  grub_unregister_extcmd (cmd_all);
 }
Signature · 7 lines
2.11.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel