diff mbox series

test: bdinfo: Handle systems without getopt

Message ID 20231210150213.124370-1-marek.vasut+renesas@mailbox.org
State Accepted
Commit be4a5f7c35685d228b3abc398a8d86c434274de5
Delegated to: Tom Rini
Headers show
Series test: bdinfo: Handle systems without getopt | expand

Commit Message

Marek Vasut Dec. 10, 2023, 3:01 p.m. UTC
Systems without getopt support fall back to plain full bdinfo print,
handle such a case, which occurs e.g. with sandbox_flattree_defconfig .

Fixes: 8827a3871452 ("test: bdinfo: Test bdinfo -h")
Fixes: 2696f3ab8101 ("test: bdinfo: Test bdinfo -m")
Fixes: 3ff2d796a6f2 ("test: bdinfo: Test bdinfo -e")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
---
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
 test/cmd/bdinfo.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

Comments

Tom Rini Dec. 10, 2023, 3:16 p.m. UTC | #1
On Sun, Dec 10, 2023 at 04:01:56PM +0100, Marek Vasut wrote:

> Systems without getopt support fall back to plain full bdinfo print,
> handle such a case, which occurs e.g. with sandbox_flattree_defconfig .
> 
> Fixes: 8827a3871452 ("test: bdinfo: Test bdinfo -h")
> Fixes: 2696f3ab8101 ("test: bdinfo: Test bdinfo -m")
> Fixes: 3ff2d796a6f2 ("test: bdinfo: Test bdinfo -e")
> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/test/cmd/bdinfo.c b/test/cmd/bdinfo.c
index 9744bd16df9..053f2224919 100644
--- a/test/cmd/bdinfo.c
+++ b/test/cmd/bdinfo.c
@@ -237,12 +237,17 @@  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");
+	if (!CONFIG_IS_ENABLED(GETOPT)) {
+		ut_asserteq(0, run_commandf("bdinfo -h"));
+		ut_assertok(bdinfo_test_all(uts));
+	} else {
+		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;
@@ -255,7 +260,10 @@  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));
+	if (!CONFIG_IS_ENABLED(GETOPT))
+		ut_assertok(bdinfo_test_all(uts));
+	else
+		ut_assertok(bdinfo_check_mem(uts));
 	ut_assertok(ut_check_console_end(uts));
 
 	return 0;
@@ -268,7 +276,9 @@  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))
+	if (!CONFIG_IS_ENABLED(GETOPT))
+		ut_assertok(bdinfo_test_all(uts));
+	else if (IS_ENABLED(CONFIG_CMD_NET))
 		ut_assertok(test_eth(uts));
 	ut_assertok(ut_check_console_end(uts));