Message ID | 20241106135017.696551-1-andrew.goodbody@linaro.org |
---|---|
State | New |
Headers | show |
Series | test: bootm: Ensure tests can be run twice | expand |
Hi Andrew, On Wed, 6 Nov 2024 at 06:50, Andrew Goodbody <andrew.goodbody@linaro.org> wrote: > > Some of the bootm tests rely on state that is assumed to be > correct but is changed by the tests. This means that running > 'ut bootm' twice will result in failures on the second run > as the state left by the first run is not what the tests > expect. > Fix this by ensuring the state is as expected by explicitly > setting that state. > > Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> > --- > > test/bootm.c | 3 +++ > 1 file changed, 3 insertions(+) Reviewed-by: Simon Glass <sjg@chromium.org> We could implement save/restore for the environment (in tests), but for now this seems like a good solution. > > diff --git a/test/bootm.c b/test/bootm.c > index 52b83f149c..9455f44884 100644 > --- a/test/bootm.c > +++ b/test/bootm.c > @@ -28,6 +28,7 @@ static int bootm_test_nop(struct unit_test_state *uts) > > /* This tests relies on GD_FLG_SILENT not being set */ > gd->flags &= ~GD_FLG_SILENT; > + env_set("silent_linux", NULL); > > *buf = '\0'; > ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); > @@ -183,6 +184,7 @@ static int bootm_test_subst(struct unit_test_state *uts) > ut_asserteq(0, bootm_process_cmdline(buf, 22, BOOTM_CL_SUBST)); > > /* Check multiple substitutions */ > + ut_assertok(env_set("bvar", NULL)); > ut_assertok(env_set("var", "abc")); > strcpy(buf, "some${var}thing${bvar}else"); > ut_asserteq(0, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); > @@ -201,6 +203,7 @@ BOOTM_TEST(bootm_test_subst, 0); > /* Test silent processing in the bootargs variable */ > static int bootm_test_silent_var(struct unit_test_state *uts) > { > + ut_assertok(env_set("var", NULL)); > env_set("bootargs", NULL); > ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SUBST)); > ut_assertnull(env_get("bootargs")); > -- > 2.39.5 > Regards, Simon
On Wed, 06 Nov 2024 13:50:17 +0000, Andrew Goodbody wrote: > Some of the bootm tests rely on state that is assumed to be > correct but is changed by the tests. This means that running > 'ut bootm' twice will result in failures on the second run > as the state left by the first run is not what the tests > expect. > Fix this by ensuring the state is as expected by explicitly > setting that state. > > [...] Applied to u-boot/next, thanks!
diff --git a/test/bootm.c b/test/bootm.c index 52b83f149c..9455f44884 100644 --- a/test/bootm.c +++ b/test/bootm.c @@ -28,6 +28,7 @@ static int bootm_test_nop(struct unit_test_state *uts) /* This tests relies on GD_FLG_SILENT not being set */ gd->flags &= ~GD_FLG_SILENT; + env_set("silent_linux", NULL); *buf = '\0'; ut_assertok(bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_ALL)); @@ -183,6 +184,7 @@ static int bootm_test_subst(struct unit_test_state *uts) ut_asserteq(0, bootm_process_cmdline(buf, 22, BOOTM_CL_SUBST)); /* Check multiple substitutions */ + ut_assertok(env_set("bvar", NULL)); ut_assertok(env_set("var", "abc")); strcpy(buf, "some${var}thing${bvar}else"); ut_asserteq(0, bootm_process_cmdline(buf, BUF_SIZE, BOOTM_CL_SUBST)); @@ -201,6 +203,7 @@ BOOTM_TEST(bootm_test_subst, 0); /* Test silent processing in the bootargs variable */ static int bootm_test_silent_var(struct unit_test_state *uts) { + ut_assertok(env_set("var", NULL)); env_set("bootargs", NULL); ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SUBST)); ut_assertnull(env_get("bootargs"));
Some of the bootm tests rely on state that is assumed to be correct but is changed by the tests. This means that running 'ut bootm' twice will result in failures on the second run as the state left by the first run is not what the tests expect. Fix this by ensuring the state is as expected by explicitly setting that state. Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org> --- test/bootm.c | 3 +++ 1 file changed, 3 insertions(+)