From 5bd32a96adec37811e8ba5f88a07b3908db14d5f Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:41:02 +0200 Subject: test: bdinfo: Rename bdinfo_test_move() to bdinfo_test_full() Rename bdinfo_test_move() to bdinfo_test_full(). The former is a remnant of deriving this test from another test. No functional change. Reviewed-by: Simon Glass Signed-off-by: Marek Vasut --- test/cmd/bdinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 8c09281cac0..b2896e8eb41 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -130,7 +130,7 @@ static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) return 0; } -static int bdinfo_test_move(struct unit_test_state *uts) +static int bdinfo_test_full(struct unit_test_state *uts) { struct bd_info *bd = gd->bd; int i; @@ -217,7 +217,7 @@ static int bdinfo_test_move(struct unit_test_state *uts) return 0; } -BDINFO_TEST(bdinfo_test_move, UT_TESTF_CONSOLE_REC); +BDINFO_TEST(bdinfo_test_full, UT_TESTF_CONSOLE_REC); int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { -- cgit v1.3.1 From 4823b05f01873826f063848bcad3446025917de2 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:41:03 +0200 Subject: test: bdinfo: Test both bdinfo and bdinfo -a Factor out the core of test for all bdinfo output into bdinfo_test_all() and then reuse it to verify that both 'bdinfo' and 'bdinfo -a' print all the bdinfo output. Reviewed-by: Simon Glass Signed-off-by: Marek Vasut --- test/cmd/bdinfo.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index b2896e8eb41..509a8b5c586 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -130,15 +130,11 @@ static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) return 0; } -static int bdinfo_test_full(struct unit_test_state *uts) +static int bdinfo_test_all(struct unit_test_state *uts) { struct bd_info *bd = gd->bd; int i; - /* Test moving the working BDINFO to a new location */ - ut_assertok(console_record_reset_enable()); - ut_assertok(run_commandf("bdinfo")); - ut_assertok(test_num_l(uts, "boot_params", 0)); for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { @@ -212,6 +208,17 @@ static int bdinfo_test_full(struct unit_test_state *uts) ut_assertok(test_num_l(uts, "malloc base", gd_malloc_start())); } + return 0; +} + +static int bdinfo_test_full(struct unit_test_state *uts) +{ + /* Test BDINFO full print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("bdinfo")); + ut_assertok(bdinfo_test_all(uts)); + ut_assertok(run_commandf("bdinfo -a")); + ut_assertok(bdinfo_test_all(uts)); ut_assertok(ut_check_console_end(uts)); return 0; -- cgit v1.3.1 From 8827a38714526adcff95271bac6a9bb49b9c0b83 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:41:04 +0200 Subject: test: bdinfo: Test bdinfo -h The bdinfo -h should print error message that -h is an unknown parameter and then command help text. Test the expected output. Reviewed-by: Simon Glass Signed-off-by: Marek Vasut --- test/cmd/bdinfo.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test') diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 509a8b5c586..2f34d877e5c 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -226,6 +226,23 @@ static int bdinfo_test_full(struct unit_test_state *uts) BDINFO_TEST(bdinfo_test_full, UT_TESTF_CONSOLE_REC); +static int bdinfo_test_help(struct unit_test_state *uts) +{ + /* Test BDINFO unknown option help text print */ + ut_assertok(console_record_reset_enable()); + ut_asserteq(1, run_commandf("bdinfo -h")); + ut_assert_nextlinen("bdinfo: invalid option -- h"); + ut_assert_nextlinen("bdinfo - print Board Info structure"); + ut_assert_nextline_empty(); + ut_assert_nextlinen("Usage:"); + ut_assert_nextlinen("bdinfo"); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +BDINFO_TEST(bdinfo_test_help, UT_TESTF_CONSOLE_REC); + int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo_test); -- cgit v1.3.1 From 2696f3ab8101d0037b4fca9b982595b2f935946d Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:41:05 +0200 Subject: test: bdinfo: Test bdinfo -m The bdinfo -m should print only the board memory layout. Test the expected output. Signed-off-by: Marek Vasut Reviewed-by: Simon Glass --- test/cmd/bdinfo.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index 2f34d877e5c..c9be182e370 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -130,13 +130,11 @@ static int lmb_test_dump_all(struct unit_test_state *uts, struct lmb *lmb) return 0; } -static int bdinfo_test_all(struct unit_test_state *uts) +static int bdinfo_check_mem(struct unit_test_state *uts) { struct bd_info *bd = gd->bd; int i; - ut_assertok(test_num_l(uts, "boot_params", 0)); - for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { if (bd->bi_dram[i].size) { ut_assertok(test_num_l(uts, "DRAM bank", i)); @@ -147,6 +145,15 @@ static int bdinfo_test_all(struct unit_test_state *uts) } } + return 0; +} + +static int bdinfo_test_all(struct unit_test_state *uts) +{ + ut_assertok(test_num_l(uts, "boot_params", 0)); + + ut_assertok(bdinfo_check_mem(uts)); + /* CONFIG_SYS_HAS_SRAM testing not supported */ ut_assertok(test_num_l(uts, "flashstart", 0)); ut_assertok(test_num_l(uts, "flashsize", 0)); @@ -243,6 +250,19 @@ static int bdinfo_test_help(struct unit_test_state *uts) BDINFO_TEST(bdinfo_test_help, UT_TESTF_CONSOLE_REC); +static int bdinfo_test_memory(struct unit_test_state *uts) +{ + /* Test BDINFO memory layout only print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("bdinfo -m")); + ut_assertok(bdinfo_check_mem(uts)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +BDINFO_TEST(bdinfo_test_memory, UT_TESTF_CONSOLE_REC); + int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo_test); -- cgit v1.3.1 From 3ff2d796a6f251637c3ee71bb7f1e3d6964dafa2 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 7 Oct 2023 23:41:06 +0200 Subject: test: bdinfo: Test bdinfo -e The bdinfo -e should print only the board ethernet settings. Test the expected output. Reviewed-by: Simon Glass Signed-off-by: Marek Vasut --- test/cmd/bdinfo.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test') diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c index c9be182e370..9744bd16df9 100644 --- a/test/cmd/bdinfo.c +++ b/test/cmd/bdinfo.c @@ -263,6 +263,20 @@ static int bdinfo_test_memory(struct unit_test_state *uts) BDINFO_TEST(bdinfo_test_memory, UT_TESTF_CONSOLE_REC); +static int bdinfo_test_eth(struct unit_test_state *uts) +{ + /* Test BDINFO ethernet settings only print */ + ut_assertok(console_record_reset_enable()); + ut_assertok(run_commandf("bdinfo -e")); + if (IS_ENABLED(CONFIG_CMD_NET)) + ut_assertok(test_eth(uts)); + ut_assertok(ut_check_console_end(uts)); + + return 0; +} + +BDINFO_TEST(bdinfo_test_eth, UT_TESTF_CONSOLE_REC); + int do_ut_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct unit_test *tests = UNIT_TEST_SUITE_START(bdinfo_test); -- cgit v1.3.1