[PATCH 03/30] sandbox: Drop the 'starting...' message unless testing

Simon Glass sjg at chromium.org
Thu Jan 28 16:11:44 CET 2021


This message is annoying since it is only useful for testing. Add a flag
to control whether it is emitted or not, so it can be supressed by
default.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 arch/sandbox/cpu/start.c         | 15 +++++++++++++--
 arch/sandbox/include/asm/state.h |  1 +
 test/py/tests/test_log.py        |  2 +-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 25425809747..dc7797ae109 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -388,6 +388,15 @@ static int sandbox_cmdline_cb_select_unittests(struct sandbox_state *state,
 }
 SANDBOX_CMDLINE_OPT_SHORT(select_unittests, 'k', 1, "Select unit tests to run");
 
+static int sandbox_cmdline_cb_log_test(struct sandbox_state *state,
+				       const char *arg)
+{
+	state->log_test = true;
+
+	return 0;
+}
+SANDBOX_CMDLINE_OPT(log_test, 0, "Show logging info on startup (for testing)");
+
 static void setup_ram_buf(struct sandbox_state *state)
 {
 	/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
@@ -488,8 +497,10 @@ int main(int argc, char *argv[])
 	gd->reloc_off = (ulong)gd->arch.text_base;
 
 	/* sandbox test: log functions called before log_init in board_init_f */
-	log_info("sandbox: starting...\n");
-	log_debug("debug: %s\n", __func__);
+	if (state->log_test) {
+		log_info("sandbox: starting...\n");
+		log_debug("debug: %s\n", __func__);
+	}
 
 	/* Do pre- and post-relocation init */
 	board_init_f(0);
diff --git a/arch/sandbox/include/asm/state.h b/arch/sandbox/include/asm/state.h
index bca13069824..d0e7fdbd5b0 100644
--- a/arch/sandbox/include/asm/state.h
+++ b/arch/sandbox/include/asm/state.h
@@ -105,6 +105,7 @@ struct sandbox_state {
 	struct list_head mapmem_head;	/* struct sandbox_mapmem_entry */
 	bool hwspinlock;		/* Hardware Spinlock status */
 	bool allow_memio;		/* Allow readl() etc. to work */
+	bool log_test;			/* Output some log info for testing */
 
 	/*
 	 * This struct is getting large.
diff --git a/test/py/tests/test_log.py b/test/py/tests/test_log.py
index f889120f2b3..e2955ab0770 100644
--- a/test/py/tests/test_log.py
+++ b/test/py/tests/test_log.py
@@ -43,7 +43,7 @@ def test_log_dropped(u_boot_console):
     """Test dropped 'log' message when debug_uart is activated"""
 
     cons = u_boot_console
-    cons.restart_uboot()
+    cons.restart_uboot_with_flags(['--log_test'])
     output = cons.get_spawn_output().replace('\r', '')
     assert 'sandbox: starting...' in output
     assert (not 'debug: main' in output)
-- 
2.30.0.280.ga3ce27912f-goog



More information about the U-Boot mailing list