blob: 4af05764fb883a2b666c224958bc97ab63fbb417 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Joe Hershberger26e038f2015-05-20 14:27:36 -05002/*
3 * (C) Copyright 2015
4 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
Joe Hershberger26e038f2015-05-20 14:27:36 -05005 */
6
Joe Hershberger26e038f2015-05-20 14:27:36 -05007#include <command.h>
8#include <test/env.h>
9#include <test/suites.h>
10#include <test/ut.h>
11
Ravi Minnikanticb803d72024-08-11 11:44:15 -070012static int env_test_env_cmd(struct unit_test_state *uts)
13{
14 ut_assertok(run_command("setenv non_default_var1 1", 0));
15 ut_assert_console_end();
16
17 ut_assertok(run_command("setenv non_default_var2 1", 0));
18 ut_assert_console_end();
19
20 ut_assertok(run_command("env print non_default_var1", 0));
21 ut_assert_nextline("non_default_var1=1");
22 ut_assert_console_end();
23
24 ut_assertok(run_command("env default non_default_var1 non_default_var2", 0));
25 ut_assert_nextline("WARNING: 'non_default_var1' not in imported env, deleting it!");
26 ut_assert_nextline("WARNING: 'non_default_var2' not in imported env, deleting it!");
27 ut_assert_console_end();
28
29 ut_asserteq(1, run_command("env exists non_default_var1", 0));
30 ut_assert_console_end();
31
32 ut_asserteq(1, run_command("env exists non_default_var2", 0));
33 ut_assert_console_end();
34
35 return 0;
36}
Simon Glass11fcfa32024-08-22 07:57:50 -060037ENV_TEST(env_test_env_cmd, UTF_CONSOLE);
Ravi Minnikanticb803d72024-08-11 11:44:15 -070038
Simon Glassed38aef2020-05-10 11:40:03 -060039int do_ut_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Joe Hershberger26e038f2015-05-20 14:27:36 -050040{
Simon Glassb50211f2021-03-07 17:35:10 -070041 struct unit_test *tests = UNIT_TEST_SUITE_START(env_test);
42 const int n_ents = UNIT_TEST_SUITE_COUNT(env_test);
Joe Hershberger26e038f2015-05-20 14:27:36 -050043
Philippe Reynes1f99f842019-12-17 19:07:04 +010044 return cmd_ut_category("environment", "env_test_",
45 tests, n_ents, argc, argv);
Joe Hershberger26e038f2015-05-20 14:27:36 -050046}