From: Mehmet Fide <[email protected]>

There is no test for the bootd command. Add one to the cmd suite that
covers the documented behaviour: bootd and its "boot" alias run the
command held in the bootcmd environment variable, and the return value
of bootd is the one of that command.

Signed-off-by: Mehmet Fide <[email protected]>
---

Notes:
    checkpatch asks for a blank line before CMD_TEST(); test/cmd/command.c and
    test/cmd/exit.c place the macro directly after the closing brace, so this
    follows the surrounding tests.

 test/cmd/Makefile |  3 +++
 test/cmd/bootd.c  | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 test/cmd/bootd.c

diff --git a/test/cmd/Makefile b/test/cmd/Makefile
index 8d36463879d..757aefa3e02 100644
--- a/test/cmd/Makefile
+++ b/test/cmd/Makefile
@@ -17,6 +17,9 @@ ifdef CONFIG_CONSOLE_RECORD
 obj-$(CONFIG_CMD_ACPI) += acpi.o
 endif
 obj-$(CONFIG_CMD_BDI) += bdinfo.o
+ifdef CONFIG_CONSOLE_RECORD
+obj-$(CONFIG_CMD_BOOTD) += bootd.o
+endif
 obj-$(CONFIG_CMD_CONFIG) += config.o
 obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o
 obj-$(CONFIG_CMD_FDT) += fdt.o
diff --git a/test/cmd/bootd.c b/test/cmd/bootd.c
new file mode 100644
index 00000000000..83dc9ab6ecc
--- /dev/null
+++ b/test/cmd/bootd.c
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for the bootd command
+ *
+ * Copyright 2026 Mehmet Fide <[email protected]>
+ */
+
+#include <command.h>
+#include <env.h>
+#include <test/cmd.h>
+#include <test/ut.h>
+
+/* Check that bootd and its "boot" alias run the bootcmd variable */
+static int cmd_bootd_test(struct unit_test_state *uts)
+{
+       ut_assertok(env_set("bootcmd", "echo hello bootd"));
+
+       ut_assertok(run_command("bootd", 0));
+       ut_assert_nextline("hello bootd");
+       ut_assert_console_end();
+
+       ut_assertok(run_command("boot", 0));
+       ut_assert_nextline("hello bootd");
+       ut_assert_console_end();
+
+       /* the return value is the one of the command in bootcmd */
+       ut_assertok(env_set("bootcmd", "false"));
+       ut_asserteq(1, run_command("bootd", 0));
+       ut_assert_console_end();
+
+       ut_assertok(env_set("bootcmd", NULL));
+
+       return 0;
+}
+CMD_TEST(cmd_bootd_test, UTF_CONSOLE);
-- 
2.54.0

Reply via email to