1 // SPDX-License-Identifier: GPL-2.0+
3 * Tests for bootm routines
5 * Copyright 2020 Google LLC
10 #include <test/suites.h>
11 #include <test/test.h>
14 DECLARE_GLOBAL_DATA_PTR;
16 #define BOOTM_TEST(_name, _flags) UNIT_TEST(_name, _flags, bootm_test)
18 #define CONSOLE_STR "console=/dev/ttyS0"
20 /* Test silent processing in the bootargs variable */
21 static int bootm_test_silent_var(struct unit_test_state *uts)
23 /* 'silent_linux' not set should do nothing */
24 env_set("silent_linux", NULL);
25 env_set("bootargs", CONSOLE_STR);
26 ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
27 ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
29 env_set("bootargs", NULL);
30 ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
31 ut_assertnull(env_get("bootargs"));
33 ut_assertok(env_set("silent_linux", "no"));
34 env_set("bootargs", CONSOLE_STR);
35 ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
36 ut_asserteq_str(CONSOLE_STR, env_get("bootargs"));
38 ut_assertok(env_set("silent_linux", "yes"));
39 env_set("bootargs", CONSOLE_STR);
40 ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
41 ut_asserteq_str("console=", env_get("bootargs"));
43 /* Empty buffer should still add the string */
44 env_set("bootargs", NULL);
45 ut_assertok(bootm_process_cmdline_env(BOOTM_CL_SILENT));
46 ut_asserteq_str("console=", env_get("bootargs"));
50 BOOTM_TEST(bootm_test_silent_var, 0);
52 int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
54 struct unit_test *tests = ll_entry_start(struct unit_test, bootm_test);
55 const int n_ents = ll_entry_count(struct unit_test, bootm_test);
57 return cmd_ut_category("bootm", "bootm_test_", tests, n_ents,