Simon Glass | 07a8886 | 2020-11-05 10:33:38 -0700 | [diff] [blame^] | 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); |
| 26 | fixup_silent_linux(); |
| 27 | ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); |
| 28 | |
| 29 | env_set("bootargs", NULL); |
| 30 | fixup_silent_linux(); |
| 31 | ut_assertnull(env_get("bootargs")); |
| 32 | |
| 33 | ut_assertok(env_set("silent_linux", "no")); |
| 34 | env_set("bootargs", CONSOLE_STR); |
| 35 | fixup_silent_linux(); |
| 36 | ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); |
| 37 | |
| 38 | ut_assertok(env_set("silent_linux", "yes")); |
| 39 | env_set("bootargs", CONSOLE_STR); |
| 40 | fixup_silent_linux(); |
| 41 | ut_asserteq_str("console=", env_get("bootargs")); |
| 42 | |
| 43 | /* Empty buffer should still add the string */ |
| 44 | env_set("bootargs", NULL); |
| 45 | fixup_silent_linux(); |
| 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 | } |