summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Villemoes <ravi@prevas.dk>2024-10-30 22:34:04 +0100
committerTom Rini <trini@konsulko.com>2024-11-15 16:36:18 -0600
commit1bf25c775010290bb4239180b17684b1657488fd (patch)
tree9c6e81f513c89740a6e0d29afbf8324b24a5a61c
parent1e2325f76069f03fe0572af9599eab16674bdfc1 (diff)
test: env: add some test cases for new "env default -k" flag
Check that the new -k flag works as expected. This also adds a test of the -a flag, which was previously missing, and as the comment says, perhaps for a good reason. At least now we have a test for it in combination with -k (and -f, because the ethaddr variables otherwise cause complaining). Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
-rw-r--r--test/env/cmd_ut_env.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c
index e1dd1a14cb0..9f16a978f2a 100644
--- a/test/env/cmd_ut_env.c
+++ b/test/env/cmd_ut_env.c
@@ -31,6 +31,46 @@ static int env_test_env_cmd(struct unit_test_state *uts)
ut_asserteq(0, run_command("env exists non_default_var2", 0));
ut_assert_console_end();
+ ut_assertok(run_command("setenv non_default_var1 3", 0));
+ ut_assert_console_end();
+
+ ut_assertok(run_command("env default -k non_default_var1", 0));
+ ut_assert_console_end();
+
+ ut_asserteq(0, run_command("env exists non_default_var1", 0));
+ ut_assert_console_end();
+
+ ut_asserteq(0, run_command("env exists non_default_var2", 0));
+ ut_assert_console_end();
+
+ ut_assertok(run_command("env default -k -a -f", 0));
+ ut_assert_nextline("## Resetting to default environment");
+ ut_assert_console_end();
+
+ ut_asserteq(0, run_command("env exists non_default_var1", 0));
+ ut_assert_console_end();
+
+ ut_asserteq(0, run_command("env exists non_default_var2", 0));
+ ut_assert_console_end();
+
+ /*
+ * While the following test of "env default -a" by itself
+ * works, it unfortunately causes an unrelated test case,
+ * env_test_fdt_import(), to fail, because the "from_fdt"
+ * variable would be removed.
+ */
+#if 0
+ ut_assertok(run_command("env default -a", 0));
+ ut_assert_nextline("## Resetting to default environment");
+ 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();
+#endif
+
return 0;
}
ENV_TEST(env_test_env_cmd, UTF_CONSOLE);