env: remove vars that are not in default env
current env_set_default_vars() doesn't delete var that are not in the imported env. hashtable removes vars that are not in the imported env but present in the current env only if H_NOCLEAR flag is not set. This change is to avoid passing H_NOCLEAR flag if specific vars are passed to env_set_default_vars() Without this change: Marvell>> env default boot_mode Marvell>> With the change: Marvell>> env default boot_mode WARNING: 'boot_mode' not in imported env, deleting it! Signed-off-by: Ravi Minnikanti <rminnikanti@marvell.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Tom Rini
parent
dbb6b5a010
commit
2a521d01e6
27
test/env/cmd_ut_env.c
vendored
27
test/env/cmd_ut_env.c
vendored
@@ -9,6 +9,33 @@
|
||||
#include <test/suites.h>
|
||||
#include <test/ut.h>
|
||||
|
||||
static int env_test_env_cmd(struct unit_test_state *uts)
|
||||
{
|
||||
ut_assertok(run_command("setenv non_default_var1 1", 0));
|
||||
ut_assert_console_end();
|
||||
|
||||
ut_assertok(run_command("setenv non_default_var2 1", 0));
|
||||
ut_assert_console_end();
|
||||
|
||||
ut_assertok(run_command("env print non_default_var1", 0));
|
||||
ut_assert_nextline("non_default_var1=1");
|
||||
ut_assert_console_end();
|
||||
|
||||
ut_assertok(run_command("env default non_default_var1 non_default_var2", 0));
|
||||
ut_assert_nextline("WARNING: 'non_default_var1' not in imported env, deleting it!");
|
||||
ut_assert_nextline("WARNING: 'non_default_var2' not in imported env, deleting it!");
|
||||
ut_assert_console_end();
|
||||
|
||||
ut_asserteq(1, run_command("env exists non_default_var1", 0));
|
||||
ut_assert_console_end();
|
||||
|
||||
ut_asserteq(1, run_command("env exists non_default_var2", 0));
|
||||
ut_assert_console_end();
|
||||
|
||||
return 0;
|
||||
}
|
||||
ENV_TEST(env_test_env_cmd, UT_TESTF_CONSOLE_REC);
|
||||
|
||||
int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
{
|
||||
struct unit_test *tests = UNIT_TEST_SUITE_START(env_test);
|
||||
|
||||
Reference in New Issue
Block a user