diff options
author | Simon Glass <sjg@chromium.org> | 2020-11-05 10:33:38 -0700 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-12-04 16:09:26 -0500 |
commit | f158ba15ee0f9f756193b60420adfdc0a9c1eb96 (patch) | |
tree | 7fa87c022e1258306c4c5947e661bcf039bfe7e7 /test | |
parent | 96434a76fd254248ded19e95dc967d28e65a5edf (diff) | |
download | u-boot-f158ba15ee0f9f756193b60420adfdc0a9c1eb96.zip u-boot-f158ba15ee0f9f756193b60420adfdc0a9c1eb96.tar.gz u-boot-f158ba15ee0f9f756193b60420adfdc0a9c1eb96.tar.bz2 |
bootm: Add tests for fixup_silent_linux()
This function currently has no tests. Export it so that we can implement
a simple test on sandbox. Use IS_ENABLED() to remove the unused code,
instead #ifdef.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 1 | ||||
-rw-r--r-- | test/bootm.c | 59 | ||||
-rw-r--r-- | test/cmd_ut.c | 1 |
3 files changed, 61 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile index 8296734..d4323f9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,6 +5,7 @@ ifneq ($(CONFIG_SANDBOX),) obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o endif +obj-$(CONFIG_$(SPL_)CMDLINE) += bootm.o obj-$(CONFIG_$(SPL_)CMDLINE) += cmd/ obj-$(CONFIG_$(SPL_)CMDLINE) += cmd_ut.o obj-$(CONFIG_$(SPL_)CMDLINE) += command_ut.o diff --git a/test/bootm.c b/test/bootm.c new file mode 100644 index 0000000..59d16cb --- /dev/null +++ b/test/bootm.c @@ -0,0 +1,59 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Tests for bootm routines + * + * Copyright 2020 Google LLC + */ + +#include <common.h> +#include <bootm.h> +#include <test/suites.h> +#include <test/test.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR; + +#define BOOTM_TEST(_name, _flags) UNIT_TEST(_name, _flags, bootm_test) + +#define CONSOLE_STR "console=/dev/ttyS0" + +/* Test silent processing in the bootargs variable */ +static int bootm_test_silent_var(struct unit_test_state *uts) +{ + /* 'silent_linux' not set should do nothing */ + env_set("silent_linux", NULL); + env_set("bootargs", CONSOLE_STR); + fixup_silent_linux(); + ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); + + env_set("bootargs", NULL); + fixup_silent_linux(); + ut_assertnull(env_get("bootargs")); + + ut_assertok(env_set("silent_linux", "no")); + env_set("bootargs", CONSOLE_STR); + fixup_silent_linux(); + ut_asserteq_str(CONSOLE_STR, env_get("bootargs")); + + ut_assertok(env_set("silent_linux", "yes")); + env_set("bootargs", CONSOLE_STR); + fixup_silent_linux(); + ut_asserteq_str("console=", env_get("bootargs")); + + /* Empty buffer should still add the string */ + env_set("bootargs", NULL); + fixup_silent_linux(); + ut_asserteq_str("console=", env_get("bootargs")); + + return 0; +} +BOOTM_TEST(bootm_test_silent_var, 0); + +int do_ut_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, bootm_test); + const int n_ents = ll_entry_count(struct unit_test, bootm_test); + + return cmd_ut_category("bootm", "bootm_test_", tests, n_ents, + argc, argv); +} diff --git a/test/cmd_ut.c b/test/cmd_ut.c index f79109e..fad1c89 100644 --- a/test/cmd_ut.c +++ b/test/cmd_ut.c @@ -88,6 +88,7 @@ static struct cmd_tbl cmd_ut_sub[] = { "", ""), U_BOOT_CMD_MKENT(bloblist, CONFIG_SYS_MAXARGS, 1, do_ut_bloblist, "", ""), + U_BOOT_CMD_MKENT(bootm, CONFIG_SYS_MAXARGS, 1, do_ut_bootm, "", ""), U_BOOT_CMD_MKENT(str, CONFIG_SYS_MAXARGS, 1, do_ut_str, "", ""), #endif |