Message ID | 20210304135118.643277-5-sjg@chromium.org |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show |
Series | test: Refactor tests to have a single test runner | expand |
On 3/4/21 2:50 PM, Simon Glass wrote: > 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@chromium.org> > --- > > (no changes since v1) > > 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 c4c4128d465..3dcab6a0cc8 100644 > --- a/arch/sandbox/cpu/start.c > +++ b/arch/sandbox/cpu/start.c > @@ -389,6 +389,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 */ > @@ -491,8 +500,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__); > + } Why don't you drop the message entirely? test_log_dropped() could live well without this message: Just check that you after restarting you reach a prompt and 'debug: main' is not in the output. Best regards Heinrich > > /* 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) >
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c index c4c4128d465..3dcab6a0cc8 100644 --- a/arch/sandbox/cpu/start.c +++ b/arch/sandbox/cpu/start.c @@ -389,6 +389,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 */ @@ -491,8 +500,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)
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@chromium.org> --- (no changes since v1) 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(-)