[PATCH 0/2] Fixes to allow 'ut bootm' to pass when run interactively

Starting a sandbox session and running 'ut bootm' on the command line instead of using pytest with --verbose will result in some test failures. This series makes the tests more deterministic so that they will better control their environment and hence will work as expected whether or not they are invoked with '--verbose'. The series starts with a small fix to the parameters of bootm_process_cmdline that one commit incorrectly added using a bool when it had been updated to take flags by the preceeding commit.
Andrew Goodbody (2): test: bootm: bootm_process_cmdline_env takes flags test: bootm: Ensure GD_FLG_SILENT is reset
test/bootm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)

The function bootm_process_cmdline_env takes flags as its third parameter, not a bool. Correct the usage by replacing 'true' with BOOTM_CL_ALL so that the intent is clear. A similar change was made throughtout this file in the previous commit to the one mentioned below as being fixed.
Fixes: 4448fe8e4e7c ("bootm: Allow updating the bootargs in a buffer") Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org ---
test/bootm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/bootm.c b/test/bootm.c index 26c15552bf..5f57ecb337 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -27,11 +27,11 @@ static int bootm_test_nop(struct unit_test_state *uts) char buf[BUF_SIZE];
*buf = '\0'; - ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true)); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); ut_asserteq_str("", buf);
strcpy(buf, "test"); - ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true)); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); ut_asserteq_str("test", buf);
return 0; @@ -45,21 +45,21 @@ static int bootm_test_nospace(struct unit_test_state *uts)
/* Zero buffer size */ *buf = '\0'; - ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, true)); + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, BOOTM_CL_ALL));
/* Buffer string not terminated */ memset(buf, 'a', BUF_SIZE); - ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true)); + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL));
/* Not enough space to copy string */ memset(buf, '\0', BUF_SIZE); memset(buf, 'a', BUF_SIZE / 2); - ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true)); + ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL));
/* Just enough space */ memset(buf, '\0', BUF_SIZE); memset(buf, 'a', BUF_SIZE / 2 - 1); - ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true)); + ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL));
return 0; }

On Fri, 1 Nov 2024 at 07:03, Andrew Goodbody andrew.goodbody@linaro.org wrote:
The function bootm_process_cmdline_env takes flags as its third parameter, not a bool. Correct the usage by replacing 'true' with BOOTM_CL_ALL so that the intent is clear. A similar change was made throughtout this file in the previous
spelling
commit to the one mentioned below as being fixed.
Fixes: 4448fe8e4e7c ("bootm: Allow updating the bootargs in a buffer") Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org
test/bootm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/test/bootm.c b/test/bootm.c index 26c15552bf..5f57ecb337 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -27,11 +27,11 @@ static int bootm_test_nop(struct unit_test_state *uts) char buf[BUF_SIZE];
*buf = '\0';
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true));
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); ut_asserteq_str("", buf); strcpy(buf, "test");
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true));
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); ut_asserteq_str("test", buf); return 0;
@@ -45,21 +45,21 @@ static int bootm_test_nospace(struct unit_test_state *uts)
/* Zero buffer size */ *buf = '\0';
ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, true));
ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, BOOTM_CL_ALL)); /* Buffer string not terminated */ memset(buf, 'a', BUF_SIZE);
ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true));
ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); /* Not enough space to copy string */ memset(buf, '\0', BUF_SIZE); memset(buf, 'a', BUF_SIZE / 2);
ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, true));
ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); /* Just enough space */ memset(buf, '\0', BUF_SIZE); memset(buf, 'a', BUF_SIZE / 2 - 1);
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, true));
ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); return 0;
}
2.39.5

Some bootm tests expect that GD_FLG_SILENT is reset in order to work as expected. This is the state if the test is run with 'pytest --verbose' but not if run from, say, the sandbox command line. So reset the flag for those tests that rely on it being reset. This has to be done in each test as the test infrastructure will set it again before every test when not invoked with 'pytest --verbose'.
Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org ---
test/bootm.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/test/bootm.c b/test/bootm.c index 5f57ecb337..52b83f149c 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -26,6 +26,9 @@ static int bootm_test_nop(struct unit_test_state *uts) { char buf[BUF_SIZE];
+ /* This tests relies on GD_FLG_SILENT not being set */ + gd->flags &= ~GD_FLG_SILENT; + *buf = '\0'; ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); ut_asserteq_str("", buf); @@ -43,6 +46,9 @@ static int bootm_test_nospace(struct unit_test_state *uts) { char buf[BUF_SIZE];
+ /* This tests relies on GD_FLG_SILENT not being set */ + gd->flags &= ~GD_FLG_SILENT; + /* Zero buffer size */ *buf = '\0'; ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, BOOTM_CL_ALL)); @@ -70,6 +76,9 @@ static int bootm_test_silent(struct unit_test_state *uts) { char buf[BUF_SIZE];
+ /* This tests relies on GD_FLG_SILENT not being set */ + gd->flags &= ~GD_FLG_SILENT; + /* 'silent_linux' not set should do nothing */ env_set("silent_linux", NULL); strcpy(buf, CONSOLE_STR);

On Fri, 1 Nov 2024 at 07:03, Andrew Goodbody andrew.goodbody@linaro.org wrote:
Some bootm tests expect that GD_FLG_SILENT is reset in order to work as expected. This is the state if the test is run with 'pytest --verbose' but not if run from, say, the sandbox command line. So reset the flag for those tests that rely on it being reset. This has to be done in each test as the test infrastructure will set it again before every test when not invoked with 'pytest --verbose'.
Signed-off-by: Andrew Goodbody andrew.goodbody@linaro.org
test/bootm.c | 9 +++++++++ 1 file changed, 9 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/test/bootm.c b/test/bootm.c index 5f57ecb337..52b83f149c 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -26,6 +26,9 @@ static int bootm_test_nop(struct unit_test_state *uts) { char buf[BUF_SIZE];
/* This tests relies on GD_FLG_SILENT not being set */
gd->flags &= ~GD_FLG_SILENT;
*buf = '\0'; ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); ut_asserteq_str("", buf);
@@ -43,6 +46,9 @@ static int bootm_test_nospace(struct unit_test_state *uts) { char buf[BUF_SIZE];
/* This tests relies on GD_FLG_SILENT not being set */
gd->flags &= ~GD_FLG_SILENT;
/* Zero buffer size */ *buf = '\0'; ut_asserteq(-ENOSPC, bootm_process_cmdline(buf, 0, BOOTM_CL_ALL));
@@ -70,6 +76,9 @@ static int bootm_test_silent(struct unit_test_state *uts) { char buf[BUF_SIZE];
/* This tests relies on GD_FLG_SILENT not being set */
gd->flags &= ~GD_FLG_SILENT;
/* 'silent_linux' not set should do nothing */ env_set("silent_linux", NULL); strcpy(buf, CONSOLE_STR);
-- 2.39.5

On Fri, 01 Nov 2024 13:02:52 +0000, Andrew Goodbody wrote:
Starting a sandbox session and running 'ut bootm' on the command line instead of using pytest with --verbose will result in some test failures. This series makes the tests more deterministic so that they will better control their environment and hence will work as expected whether or not they are invoked with '--verbose'. The series starts with a small fix to the parameters of bootm_process_cmdline that one commit incorrectly added using a bool when it had been updated to take flags by the preceeding commit.
[...]
Applied to u-boot/master, thanks!
participants (3)
-
Andrew Goodbody
-
Simon Glass
-
Tom Rini