[PATCH v3 14/38] test: cmd: Add a basic test for 'addrmap' command
Priyanka Jain (OSS)
priyanka.jain at oss.nxp.com
Fri Feb 26 10:36:03 CET 2021
>-----Original Message-----
>From: U-Boot <u-boot-bounces at lists.denx.de> On Behalf Of Bin Meng
>Sent: Thursday, February 25, 2021 2:53 PM
>To: Simon Glass <sjg at chromium.org>; Alexander Graf <agraf at csgraf.de>;
>Priyanka Jain <priyanka.jain at nxp.com>
>Cc: U-Boot Mailing List <u-boot at lists.denx.de>; Tom Rini
><trini at konsulko.com>
>Subject: [PATCH v3 14/38] test: cmd: Add a basic test for 'addrmap' command
>
>This adds a basic test for the newly introduced 'addrmap' command.
>
>Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
>Reviewed-by: Simon Glass <sjg at chromium.org>
>
>---
>
>(no changes since v2)
>
>Changes in v2:
>- new patch: test: cmd: Add a basic test for 'addrmap' command
>
> include/test/suites.h | 2 ++
> test/cmd/Makefile | 1 +
> test/cmd/addrmap.c | 38 ++++++++++++++++++++++++++++++++++++++
> test/cmd_ut.c | 6 ++++++
> 4 files changed, 47 insertions(+)
> create mode 100644 test/cmd/addrmap.c
>
>diff --git a/include/test/suites.h b/include/test/suites.h index
>52e8fc8..f5d8e13 100644
>--- a/include/test/suites.h
>+++ b/include/test/suites.h
>@@ -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[]);
>diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 5451e9e..8699976
>100644
>--- a/test/cmd/Makefile
>+++ b/test/cmd/Makefile
>@@ -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-y += setexpr.o
>diff --git a/test/cmd/addrmap.c b/test/cmd/addrmap.c new file mode 100644
>index 0000000..fb74448
>--- /dev/null
>+++ b/test/cmd/addrmap.c
>@@ -0,0 +1,38 @@
>+// SPDX-License-Identifier: GPL-2.0+
>+/*
>+ * Tests for addrmap command
>+ *
>+ * Copyright (C) 2021, Bin Meng <bmeng.cn at 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);
>+}
>diff --git a/test/cmd_ut.c b/test/cmd_ut.c index 90674d5..8404309 100644
>--- a/test/cmd_ut.c
>+++ b/test/cmd_ut.c
>@@ -91,6 +91,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, @@ -166,6 +169,9
>@@ static char ut_help_text[] =
> !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 */
>
>--
>2.7.4
Kindly fix below checkpatch warnings
WARNING: Possible new command - make sure you add a test
#28: FILE: include/test/suites.h:29:
+int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc,
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#46:
new file mode 100644
CHECK: Please use a blank line after function/struct/union/enum declarations
#78: FILE: test/cmd/addrmap.c:28:
+}
+ADDRMAP_TEST(addrmap_test_basic, UT_TESTF_CONSOLE_REC);
WARNING: Possible new command - make sure you add a test
#80: FILE: test/cmd/addrmap.c:30:
+int do_ut_addrmap(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
#97: FILE: test/cmd_ut.c:96:
+#ifdef CONFIG_CMD_ADDRMAP
WARNING: Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible
#108: FILE: test/cmd_ut.c:174:
+#ifdef CONFIG_CMD_ADDRMAP
total: 0 errors, 5 warnings, 1 checks, 71 lines checked
Regards
Priyanka
More information about the U-Boot
mailing list