]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: cmd: Add a basic test for 'addrmap' command
authorBin Meng <bmeng.cn@gmail.com>
Thu, 25 Feb 2021 09:22:35 +0000 (17:22 +0800)
committerPriyanka Jain <priyanka.jain@nxp.com>
Fri, 5 Mar 2021 04:55:43 +0000 (10:25 +0530)
This adds a basic test for the newly introduced 'addrmap' command.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[Rebase]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
include/test/suites.h
test/cmd/Makefile
test/cmd/addrmap.c [new file with mode: 0644]
test/cmd_ut.c

index 52e8fc8155ab9ac2c822e812dda8840045819037..f5d8e139cee9b8b0aa596337233a5f9ae1fd8946 100644 (file)
@@ -26,6 +26,8 @@ int cmd_ut_category(const char *name, const char *prefix,
                    struct unit_test *tests, int n_ents,
                    int argc, char *const argv[]);
 
+int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
+                 char *const argv[]);
 int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
                   char *const argv[]);
index c84df6039537e2353aa0116ec879a38138815c67..2cfe43a6bd37cf92e3592d069092bda4aa611200 100644 (file)
@@ -6,6 +6,7 @@ ifdef CONFIG_HUSH_PARSER
 obj-$(CONFIG_CONSOLE_RECORD) += test_echo.o
 endif
 obj-y += mem.o
+obj-$(CONFIG_CMD_ADDRMAP) += addrmap.o
 obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o
 obj-$(CONFIG_CMD_PWM) += pwm.o
 obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c
new file mode 100644 (file)
index 0000000..fb74448
--- /dev/null
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Tests for addrmap command
+ *
+ * Copyright (C) 2021, Bin Meng <bmeng.cn@gmail.com>
+ */
+
+#include <common.h>
+#include <console.h>
+#include <test/suites.h>
+#include <test/ut.h>
+
+/* Declare a new addrmap test */
+#define ADDRMAP_TEST(_name, _flags)    UNIT_TEST(_name, _flags, addrmap_test)
+
+/* Test 'addrmap' command output */
+static int addrmap_test_basic(struct unit_test_state *uts)
+{
+       ut_assertok(console_record_reset_enable());
+       ut_assertok(run_command("addrmap", 0));
+       ut_assert_nextline("           vaddr            paddr             size");
+       ut_assert_nextline("================ ================ ================");
+       /* There should be at least one entry */
+       ut_assertok(!ut_check_console_end(uts));
+
+       return 0;
+}
+ADDRMAP_TEST(addrmap_test_basic, UT_TESTF_CONSOLE_REC);
+
+int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+       struct unit_test *tests = ll_entry_start(struct unit_test,
+                                                addrmap_test);
+       const int n_ents = ll_entry_count(struct unit_test, addrmap_test);
+
+       return cmd_ut_category("cmd_addrmap", "cmd_addrmap_", tests, n_ents,
+                              argc, argv);
+}
index 8f3089890ea7462698f048d64462f6e43144cb4b..8728cc865041de3a63ae3e992949f8ba22f772a4 100644 (file)
@@ -93,6 +93,9 @@ static struct cmd_tbl cmd_ut_sub[] = {
        U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""),
 #endif
        U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""),
+#ifdef CONFIG_CMD_ADDRMAP
+       U_BOOT_CMD_MKENT(addrmap, CONFIG_SYS_MAXARGS, 1, do_ut_addrmap, "", ""),
+#endif
 };
 
 static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -167,6 +170,9 @@ static char ut_help_text[] =
 #if defined(CONFIG_UT_UNICODE) && \
        !defined(CONFIG_SPL_BUILD) && !defined(API_BUILD)
        "ut unicode [test-name] - test Unicode functions\n"
+#endif
+#ifdef CONFIG_CMD_ADDRMAP
+       "ut addrmap - Very basic test of addrmap command\n"
 #endif
        ;
 #endif /* CONFIG_SYS_LONGHELP */