[PATCH v2 34/35] bootstd: Check building without global bootmeths

Simon Glass sjg at chromium.org
Sat Jul 30 23:52:36 CEST 2022


Use the sandbox_flattree build to check that everything works correctly
with BOOTMETH_GLOBAL disabled.

Update the tests as needed.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 configs/sandbox_flattree_defconfig |  2 ++
 test/boot/bootflow.c               |  7 +++++++
 test/boot/bootmeth.c               | 24 +++++++++++++++++-------
 3 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index a71ce77c403..6d62feeb08a 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -11,6 +11,7 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_FIT=y
 CONFIG_FIT_SIGNATURE=y
 CONFIG_FIT_VERBOSE=y
+# CONFIG_BOOTMETH_VBE is not set
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_BOOTSTAGE_FDT=y
@@ -206,6 +207,7 @@ CONFIG_RSA_VERIFY_WITH_PKEY=y
 CONFIG_TPM=y
 CONFIG_LZ4=y
 CONFIG_ERRNO_STR=y
+# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
 CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
 CONFIG_EFI_CAPSULE_ON_DISK=y
 CONFIG_EFI_CAPSULE_FIRMWARE_FIT=y
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index d2c42e8b060..85305234e01 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -12,7 +12,9 @@
 #include <bootmeth.h>
 #include <bootstd.h>
 #include <dm.h>
+#ifdef CONFIG_SANDBOX
 #include <asm/test.h>
+#endif
 #include <dm/lists.h>
 #include <test/suites.h>
 #include <test/ut.h>
@@ -321,6 +323,7 @@ static int bootflow_iter(struct unit_test_state *uts)
 }
 BOOTSTD_TEST(bootflow_iter, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
 
+#if defined(CONFIG_SANDBOX) && defined(CONFIG_BOOTMETH_GLOBAL)
 /* Check using the system bootdev */
 static int bootflow_system(struct unit_test_state *uts)
 {
@@ -344,6 +347,7 @@ static int bootflow_system(struct unit_test_state *uts)
 }
 BOOTSTD_TEST(bootflow_system, UT_TESTF_DM | UT_TESTF_SCAN_PDATA |
 	     UT_TESTF_SCAN_FDT);
+#endif
 
 /* Check disabling a bootmethod if it requests it */
 static int bootflow_iter_disable(struct unit_test_state *uts)
@@ -388,6 +392,9 @@ BOOTSTD_TEST(bootflow_iter_disable, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
 /* Check 'bootflow scan' with a bootmeth ordering including a global bootmeth */
 static int bootflow_scan_glob_bootmeth(struct unit_test_state *uts)
 {
+	if (!IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+		return 0;
+
 	ut_assertok(bootstd_test_drop_bootdev_order(uts));
 
 	/*
diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c
index ae216293d64..fb627313396 100644
--- a/test/boot/bootmeth.c
+++ b/test/boot/bootmeth.c
@@ -23,9 +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");
-	ut_assert_nextline(" glob    2  firmware0           VBE simple");
+	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+		ut_assert_nextline(" glob    2  firmware0           VBE simple");
 	ut_assert_nextlinen("---");
-	ut_assert_nextline("(3 bootmeths)");
+	ut_assert_nextline(IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) ?
+		 "(3 bootmeths)" : "(2 bootmeths)");
 	ut_assert_console_end();
 
 	return 0;
@@ -57,9 +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");
-	ut_assert_nextline(" glob    2  firmware0           VBE simple");
+	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+		ut_assert_nextline(" glob    2  firmware0           VBE simple");
 	ut_assert_nextlinen("---");
-	ut_assert_nextline("(3 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 */
@@ -70,9 +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");
-	ut_assert_nextline(" glob    2  firmware0           VBE simple");
+	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
+		ut_assert_nextline(" glob    2  firmware0           VBE simple");
 	ut_assert_nextlinen("---");
-	ut_assert_nextline("(3 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 */
@@ -80,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("(3 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));
@@ -97,6 +104,9 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)
 	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));
-- 
2.37.1.455.g008518b4e5-goog



More information about the U-Boot mailing list