aboutsummaryrefslogtreecommitdiff
path: root/test/boot
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-10-31 14:43:04 -0400
committerTom Rini <trini@konsulko.com>2022-10-31 14:43:04 -0400
commita90afc6730e6c67ad37f4c98a02891a93b4ff971 (patch)
tree724c085433631e142a56c052d667139cba29b4a6 /test/boot
parent6f38d91158e7e4199753b79e0a25c1a65175aba4 (diff)
parent77bec9e3d8bd2dc307447b92a3d5cefd693a62ad (diff)
Merge branch '2022-10-31-vbe-implement-the-full-firmware-flow'
To quote Simon: This series provides an implementation of VBE from TPL through to U-Boot proper, using VBE to load the relevant firmware stages. It buils a single image.bin file containing all the phases: TPL - initial phase, loads VPL using binman symbols VPL - main firmware phase, loads SPL using VBE parameters SPL - loads U-Boot proper using VBE parameters U-Boot - final firmware phase, where OS booting is processed This series does not include the OS-booting phase. That will be the subject of a future series. The implementation is entirely handled by sandbox. It should be possible to enable this on a real board without much effort, but that is also the subject of a future series.
Diffstat (limited to 'test/boot')
-rw-r--r--test/boot/Makefile1
-rw-r--r--test/boot/bootflow.c4
-rw-r--r--test/boot/bootmeth.c13
-rw-r--r--test/boot/image.c36
-rw-r--r--test/boot/vbe_fixup.c19
-rw-r--r--test/boot/vbe_simple.c9
6 files changed, 64 insertions, 18 deletions
diff --git a/test/boot/Makefile b/test/boot/Makefile
index 5bb3f88975..d724629d3b 100644
--- a/test/boot/Makefile
+++ b/test/boot/Makefile
@@ -3,6 +3,7 @@
# Copyright 2021 Google LLC
obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
+obj-$(CONFIG_FIT) += image.o
ifdef CONFIG_OF_LIVE
obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 1e8ea754bc..e1e0708210 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -330,7 +330,7 @@ static int bootflow_system(struct unit_test_state *uts)
struct udevice *dev;
if (!IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR))
- return 0;
+ return -EAGAIN;
ut_assertok(uclass_get_device_by_name(UCLASS_BOOTMETH, "efi_mgr",
&dev));
sandbox_set_fake_efi_mgr_dev(dev, true);
@@ -395,7 +395,7 @@ BOOTSTD_TEST(bootflow_iter_disable, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
static int bootflow_scan_glob_bootmeth(struct unit_test_state *uts)
{
if (!IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
- return 0;
+ return -EAGAIN;
ut_assertok(bootstd_test_drop_bootdev_order(uts));
diff --git a/test/boot/bootmeth.c b/test/boot/bootmeth.c
index f0b5ab9adb..0098ef3efd 100644
--- a/test/boot/bootmeth.c
+++ b/test/boot/bootmeth.c
@@ -103,10 +103,17 @@ 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 */
+ return 0;
+}
+BOOTSTD_TEST(bootmeth_cmd_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
+/* Check 'bootmeth order' command with global bootmeths */
+static int bootmeth_cmd_order_glob(struct unit_test_state *uts)
+{
if (!IS_ENABLED(CONFIG_BOOTMETH_GLOBAL))
- return 0;
+ return -EAGAIN;
+ console_record_reset_enable();
ut_assertok(run_command("bootmeth order \"efi firmware0\"", 0));
ut_assert_console_end();
ut_assertok(run_command("bootmeth list", 0));
@@ -122,7 +129,7 @@ static int bootmeth_cmd_order(struct unit_test_state *uts)
return 0;
}
-BOOTSTD_TEST(bootmeth_cmd_order, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+BOOTSTD_TEST(bootmeth_cmd_order_glob, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
/* Check 'bootmeths' env var */
static int bootmeth_env(struct unit_test_state *uts)
diff --git a/test/boot/image.c b/test/boot/image.c
new file mode 100644
index 0000000000..2844b05785
--- /dev/null
+++ b/test/boot/image.c
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for vbe-simple bootmeth. All start with 'vbe_simple'
+ *
+ * Copyright 2023 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <common.h>
+#include <image.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include "bootstd_common.h"
+
+/* Test of image phase */
+static int test_image_phase(struct unit_test_state *uts)
+{
+ int val;
+
+ ut_asserteq_str("U-Boot phase", genimg_get_phase_name(IH_PHASE_U_BOOT));
+ ut_asserteq_str("SPL Phase", genimg_get_phase_name(IH_PHASE_SPL));
+ ut_asserteq_str("any", genimg_get_phase_name(IH_PHASE_NONE));
+ ut_asserteq_str("Unknown Phase", genimg_get_phase_name(-1));
+
+ ut_asserteq(IH_PHASE_U_BOOT, genimg_get_phase_id("u-boot"));
+ ut_asserteq(IH_PHASE_SPL, genimg_get_phase_id("spl"));
+ ut_asserteq(IH_PHASE_NONE, genimg_get_phase_id("none"));
+ ut_asserteq(-1, genimg_get_phase_id("fred"));
+
+ val = image_ph(IH_PHASE_SPL, IH_TYPE_FIRMWARE);
+ ut_asserteq(IH_PHASE_SPL, image_ph_phase(val));
+ ut_asserteq(IH_TYPE_FIRMWARE, image_ph_type(val));
+
+ return 0;
+}
+BOOTSTD_TEST(test_image_phase, 0);
diff --git a/test/boot/vbe_fixup.c b/test/boot/vbe_fixup.c
index 1b488e25ab..eba5c4ebe6 100644
--- a/test/boot/vbe_fixup.c
+++ b/test/boot/vbe_fixup.c
@@ -13,21 +13,18 @@
#include <test/ut.h>
#include "bootstd_common.h"
-/* Basic test of reading nvdata and updating a fwupd node in the device tree */
-static int vbe_test_fixup(struct unit_test_state *uts)
+/*
+ * Basic test of reading nvdata and updating a fwupd node in the device tree
+ * This test works when called from test_vbe.py and it must use the flat tree,
+ * since device tree fix-ups do not yet support live tree.
+ */
+static int vbe_test_fixup_norun(struct unit_test_state *uts)
{
ofnode chosen, node;
const char *data;
oftree tree;
int size;
- /*
- * This test works when called from test_vbe.py and it must use the
- * flat tree, since device tree fix-ups do not yet support live tree.
- */
- if (!working_fdt)
- return 0;
-
tree = oftree_from_fdt(working_fdt);
ut_assert(oftree_valid(tree));
@@ -55,5 +52,5 @@ static int vbe_test_fixup(struct unit_test_state *uts)
return 0;
}
-BOOTSTD_TEST(vbe_test_fixup,
- UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_FLAT_TREE);
+BOOTSTD_TEST(vbe_test_fixup_norun, UT_TESTF_DM | UT_TESTF_SCAN_FDT |
+ UT_TESTF_FLAT_TREE | UT_TESTF_MANUAL);
diff --git a/test/boot/vbe_simple.c b/test/boot/vbe_simple.c
index faba9e8f90..5e61840652 100644
--- a/test/boot/vbe_simple.c
+++ b/test/boot/vbe_simple.c
@@ -16,7 +16,12 @@
#include <test/ut.h>
#include "bootstd_common.h"
-/* Basic test of reading nvdata and updating a fwupd node in the device tree */
+/*
+ * Basic test of reading nvdata and updating a fwupd node in the device tree
+ *
+ * This sets up its own VBE info in the device, using bootstd_setup_for_tests()
+ * then does a VBE fixup and checks that everything is present.
+ */
static int vbe_simple_test_base(struct unit_test_state *uts)
{
const char *version, *bl_version;
@@ -77,7 +82,7 @@ static int vbe_simple_test_base(struct unit_test_state *uts)
bl_version = ofnode_read_string(node, "bootloader-version");
ut_assertnonnull(bl_version);
- ut_asserteq_str(version_string, bl_version);
+ ut_asserteq_str(version_string + 7, bl_version);
return 0;
}