]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: add test of 'config' command
authorRasmus Villemoes <rv@rasmusvillemoes.dk>
Wed, 8 Jul 2026 20:37:11 +0000 (22:37 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 21 Jul 2026 19:51:07 +0000 (13:51 -0600)
Add some test cases for the 'config' command, including the ability to
filter the output.

Signed-off-by: Rasmus Villemoes <rv@rasmusvillemoes.dk>
Reviewed-by: Simon Glass <sjg@chromium.org>
test/cmd/Makefile
test/cmd/config.c [new file with mode: 0644]

index 8d6932f1176c188378f35a01af0603353585caf9..8d36463879d31cd21b65fc56f51fa4081c771d98 100644 (file)
@@ -17,6 +17,7 @@ ifdef CONFIG_CONSOLE_RECORD
 obj-$(CONFIG_CMD_ACPI) += acpi.o
 endif
 obj-$(CONFIG_CMD_BDI) += bdinfo.o
+obj-$(CONFIG_CMD_CONFIG) += config.o
 obj-$(CONFIG_COREBOOT_SYSINFO) += coreboot.o
 obj-$(CONFIG_CMD_FDT) += fdt.o
 obj-$(CONFIG_CMD_HASH) += hash.o
diff --git a/test/cmd/config.c b/test/cmd/config.c
new file mode 100644 (file)
index 0000000..5a48060
--- /dev/null
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Tests for config command
+ */
+
+#include <console.h>
+#include <test/cmd.h>
+#include <test/ut.h>
+
+static int cmd_test_config(struct unit_test_state *uts)
+{
+       ut_assertok(run_command("config", 0));
+       ut_assert_skip_to_line("# Automatically generated file; DO NOT EDIT.");
+       ut_assert_skip_to_linen("# Compiler:");
+       ut_assert_skip_to_line("CONFIG_CMD_CONFIG=y");
+
+       console_record_reset_enable();
+
+       ut_assertok(run_command("config cmd_config=y", 0));
+       ut_assert_nextline("CONFIG_CMD_CONFIG=y");
+       ut_assert_console_end();
+
+       ut_assertok(run_command("config 'this string never appears in .config'", 0));
+       ut_assert_console_end();
+
+       return 0;
+}
+CMD_TEST(cmd_test_config, UTF_CONSOLE);