]>
Commit | Line | Data |
---|---|---|
f158ba15 SG |
1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | |
3 | * Tests for bootm routines | |
4 | * | |
5 | * Copyright 2020 Google LLC | |
6 | */ | |
7 | ||
8 | #include <common.h> | |
9 | #include <bootm.h> | |
10 | #include <test/suites.h> | |
11 | #include <test/test.h> | |
12 | #include <test/ut.h> | |
13 | ||
14 | DECLARE_GLOBAL_DATA_PTR; | |
15 | ||
16 | #define BOOTM_TEST(_name, _flags) UNIT_TEST(_name, _flags, bootm_test) | |
17 | ||
18 | #define CONSOLE_STR "console=/dev/ttyS0" | |
19 | ||
20 | /* Test silent processing in the bootargs variable */ | |
21 | static int bootm_test_silent_var(struct unit_test_state *uts) | |
22 | { | |
23 | /* 'silent_linux' not set should do nothing */ | |
24 | env_set("silent_linux", NULL); | |
25 | env_set("bootargs", CONSOLE_STR); | |
d9477a0a | 26 | ut_assertok(bootm_process_cmdline_env(true)); |
f158ba15 SG |
27 | ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); |
28 | ||
29 | env_set("bootargs", NULL); | |
d9477a0a | 30 | ut_assertok(bootm_process_cmdline_env(true)); |
f158ba15 SG |
31 | ut_assertnull(env_get("bootargs")); |
32 | ||
33 | ut_assertok(env_set("silent_linux", "no")); | |
34 | env_set("bootargs", CONSOLE_STR); | |
d9477a0a | 35 | ut_assertok(bootm_process_cmdline_env(true)); |
f158ba15 SG |
36 | ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); |
37 | ||
38 | ut_assertok(env_set("silent_linux", "yes")); | |
39 | env_set("bootargs", CONSOLE_STR); | |
d9477a0a | 40 | ut_assertok(bootm_process_cmdline_env(true)); |
f158ba15 SG |
41 | ut_asserteq_str("console=", env_get("bootargs")); |
42 | ||
43 | /* Empty buffer should still add the string */ | |
44 | env_set("bootargs", NULL); | |
d9477a0a | 45 | ut_assertok(bootm_process_cmdline_env(true)); |
f158ba15 SG |
46 | ut_asserteq_str("console=", env_get("bootargs")); |
47 | ||
48 | return 0; | |
49 | } | |
50 | BOOTM_TEST(bootm_test_silent_var, 0); | |
51 | ||
52 | int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) | |
53 | { | |
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); | |
56 | ||
57 | return cmd_ut_category("bootm", "bootm_test_", tests, n_ents, | |
58 | argc, argv); | |
59 | } |