summaryrefslogtreecommitdiff
path: root/test/boot/bootmeth.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/boot/bootmeth.c')
-rw-r--r--test/boot/bootmeth.c55
1 files changed, 50 insertions, 5 deletions
diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c
index 07776c5368d..fb627313396 100644
--- a/test/boot/bootmeth.c
+++ b/test/boot/bootmeth.c
@@ -1,13 +1,15 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Test for bootdev functions. All start with 'bootdev'
+ * Test for bootdev functions. All start with 'bootmeth'
*
* Copyright 2021 Google LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#include <common.h>
+#include <bootmeth.h>
#include <bootstd.h>
+#include <dm.h>
#include <test/suites.h>
#include <test/ut.h>
#include "bootstd_common.h"
@@ -21,8 +23,11 @@ static int bootmeth_cmd_list(struct unit_test_state *uts)
ut_assert_nextlinen("---");
ut_assert_nextline(" 0 0 syslinux Syslinux boot from a block device");
ut_assert_nextline(" 1 1 efi EFI boot from an .efi file");
+ if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+ ut_assert_nextline(" glob 2 firmware0 VBE simple");
ut_assert_nextlinen("---");
- ut_assert_nextline("(2 bootmeths)");
+ ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
+ "(3 bootmeths)" : "(2 bootmeths)");
ut_assert_console_end();
return 0;
@@ -54,8 +59,11 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)
ut_assert_nextlinen("---");
ut_assert_nextline(" 0 0 syslinux Syslinux boot from a block device");
ut_assert_nextline(" - 1 efi EFI boot from an .efi file");
+ if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+ ut_assert_nextline(" glob 2 firmware0 VBE simple");
ut_assert_nextlinen("---");
- ut_assert_nextline("(2 bootmeths)");
+ ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
+ "(3 bootmeths)" : "(2 bootmeths)");
ut_assert_console_end();
/* Check the -a flag with the reverse order */
@@ -66,8 +74,11 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)
ut_assert_nextlinen("---");
ut_assert_nextline(" 1 0 syslinux Syslinux boot from a block device");
ut_assert_nextline(" 0 1 efi EFI boot from an .efi file");
+ if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+ ut_assert_nextline(" glob 2 firmware0 VBE simple");
ut_assert_nextlinen("---");
- ut_assert_nextline("(2 bootmeths)");
+ ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
+ "(3 bootmeths)" : "(2 bootmeths)");
ut_assert_console_end();
/* Now reset the order to empty, which should show all of them again */
@@ -75,7 +86,8 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)
ut_assert_console_end();
ut_assertnull(env_get("bootmeths"));
ut_assertok(run_command("bootmeth list", 0));
- ut_assert_skip_to_line("(2 bootmeths)");
+ ut_assert_skip_to_line(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
+ "(3 bootmeths)" : "(2 bootmeths)");
/* Try reverse order */
ut_assertok(run_command("bootmeth order \"efi syslinux\"", 0));
@@ -91,6 +103,23 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)
ut_asserteq_str("efi syslinux", env_get("bootmeths"));
ut_assert_console_end();
+ /* Try with global bootmeths */
+ if (!IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+ return 0;
+
+ ut_assertok(run_command("bootmeth order \"efi firmware0\"", 0));
+ ut_assert_console_end();
+ ut_assertok(run_command("bootmeth list", 0));
+ ut_assert_nextline("Order Seq Name Description");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline(" 0 1 efi EFI boot from an .efi file");
+ ut_assert_nextline(" glob 2 firmware0 VBE simple");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(2 bootmeths)");
+ ut_assertnonnull(env_get("bootmeths"));
+ ut_asserteq_str("efi firmware0", env_get("bootmeths"));
+ ut_assert_console_end();
+
return 0;
}
BOOTSTD_TEST(bootmeth_cmd_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
@@ -120,3 +149,19 @@ static int bootmeth_env(struct unit_test_state *uts)
return 0;
}
BOOTSTD_TEST(bootmeth_env, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check the get_state_desc() method */
+static int bootmeth_state(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ char buf[50];
+
+ ut_assertok(uclass_first_device(UCLASS_BOOTMETH, &dev));
+ ut_assertnonnull(dev);
+
+ ut_assertok(bootmeth_get_state_desc(dev, buf, sizeof(buf)));
+ ut_asserteq_str("OK", buf);
+
+ return 0;
+}
+BOOTSTD_TEST(bootmeth_state, UT_TESTF_DM | UT_TESTF_SCAN_FDT);