summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/boot/Makefile4
-rw-r--r--test/boot/bootflow.c106
-rw-r--r--test/boot/bootmeth.c55
-rw-r--r--test/boot/vbe_simple.c115
-rw-r--r--test/dm/ofnode.c132
-rw-r--r--test/dm/test-fdt.c53
-rw-r--r--test/py/tests/test_event_dump.py1
-rw-r--r--test/test-main.c7
8 files changed, 390 insertions, 83 deletions
diff --git a/test/boot/Makefile b/test/boot/Makefile
index 1730792b5fa..9e9d5ae21f3 100644
--- a/test/boot/Makefile
+++ b/test/boot/Makefile
@@ -3,3 +3,7 @@
# Copyright 2021 Google LLC
obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
+
+ifdef CONFIG_OF_LIVE
+obj-$(CONFIG_BOOTMETH_VBE_SIMPLE) += vbe_simple.o
+endif
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 1ebb789e97b..85305234e01 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -9,13 +9,33 @@
#include <common.h>
#include <bootdev.h>
#include <bootflow.h>
+#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>
#include "bootstd_common.h"
+static int inject_response(struct unit_test_state *uts)
+{
+ /*
+ * The image being booted presents a menu of options:
+ *
+ * Fedora-Workstation-armhfp-31-1.9 Boot Options.
+ * 1: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+ * Enter choice:
+ *
+ * Provide input for this, to avoid waiting two seconds for a timeout.
+ */
+ ut_asserteq(2, console_in_puts("1\n"));
+
+ return 0;
+}
+
/* Check 'bootflow scan/list' commands */
static int bootflow_cmd(struct unit_test_state *uts)
{
@@ -73,7 +93,7 @@ static int bootflow_cmd_glob(struct unit_test_state *uts)
ut_assertok(bootstd_test_drop_bootdev_order(uts));
console_record_reset_enable();
- ut_assertok(run_command("bootflow scan -l", 0));
+ ut_assertok(run_command("bootflow scan -lG", 0));
ut_assert_nextline("Scanning for bootflows in all bootdevs");
ut_assert_nextline("Seq Method State Uclass Part Name Filename");
ut_assert_nextlinen("---");
@@ -105,7 +125,7 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts)
ut_assertok(bootstd_test_drop_bootdev_order(uts));
console_record_reset_enable();
- ut_assertok(run_command("bootflow scan -ale", 0));
+ ut_assertok(run_command("bootflow scan -aleG", 0));
ut_assert_nextline("Scanning for bootflows in all bootdevs");
ut_assert_nextline("Seq Method State Uclass Part Name Filename");
ut_assert_nextlinen("---");
@@ -188,6 +208,7 @@ BOOTSTD_TEST(bootflow_cmd_info, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
static int bootflow_scan_boot(struct unit_test_state *uts)
{
console_record_reset_enable();
+ ut_assertok(inject_response(uts));
ut_assertok(run_command("bootflow scan -b", 0));
ut_assert_nextline(
"** Booting bootflow 'mmc1.bootdev.part_1' with syslinux");
@@ -215,7 +236,7 @@ static int bootflow_iter(struct unit_test_state *uts)
/* The first device is mmc2.bootdev which has no media */
ut_asserteq(-EPROTONOSUPPORT,
- bootflow_scan_first(&iter, BOOTFLOWF_ALL, &bflow));
+ bootflow_scan_first(&iter, BOOTFLOWF_ALL | BOOTFLOWF_SKIP_GLOBAL, &bflow));
ut_asserteq(2, iter.num_methods);
ut_asserteq(0, iter.cur_method);
ut_asserteq(0, iter.part);
@@ -224,7 +245,7 @@ static int bootflow_iter(struct unit_test_state *uts)
ut_asserteq(0, bflow.err);
/*
- * This shows MEDIA even though there is none, since int
+ * This shows MEDIA even though there is none, since in
* bootdev_find_in_blk() we call part_get_info() which returns
* -EPROTONOSUPPORT. Ideally it would return -EEOPNOTSUPP and we would
* know.
@@ -302,34 +323,31 @@ 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)
{
- struct udevice *bootstd, *dev;
+ struct udevice *dev;
- /* Add the EFI bootmgr driver */
- ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
- ut_assertok(device_bind_driver(bootstd, "bootmeth_efi_mgr", "bootmgr",
- &dev));
-
- /* Add the system bootdev that it uses */
- ut_assertok(device_bind_driver(bootstd, "system_bootdev",
- "system-bootdev", &dev));
-
- ut_assertok(bootstd_test_drop_bootdev_order(uts));
+ ut_assertok(uclass_get_device_by_name(UCLASS_BOOTMETH, "efi_mgr",
+ &dev));
+ sandbox_set_fake_efi_mgr_dev(dev, true);
/* We should get a single 'bootmgr' method right at the end */
bootstd_clear_glob();
console_record_reset_enable();
ut_assertok(run_command("bootflow scan -l", 0));
- ut_assert_skip_to_line(" 1 bootmgr ready bootstd 0 <NULL> <NULL>");
- ut_assert_nextline("No more bootdevs");
- ut_assert_skip_to_line("(2 bootflows, 2 valid)");
+ ut_assert_skip_to_line(
+ " 0 efi_mgr ready (none) 0 <NULL> <NULL>");
+ ut_assert_skip_to_line("No more bootdevs");
+ ut_assert_skip_to_line("(5 bootflows, 5 valid)");
ut_assert_console_end();
return 0;
}
-BOOTSTD_TEST(bootflow_system, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+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)
@@ -344,13 +362,11 @@ static int bootflow_iter_disable(struct unit_test_state *uts)
ut_assertok(device_bind_driver(bootstd, "bootmeth_sandbox", "sandbox",
&dev));
- /* Add the system bootdev that it uses */
- ut_assertok(device_bind_driver(bootstd, "system_bootdev",
- "system-bootdev", &dev));
-
ut_assertok(bootstd_test_drop_bootdev_order(uts));
bootstd_clear_glob();
+ console_record_reset_enable();
+ ut_assertok(inject_response(uts));
ut_assertok(run_command("bootflow scan -lb", 0));
/* Try to boot the bootmgr flow, which will fail */
@@ -358,6 +374,7 @@ static int bootflow_iter_disable(struct unit_test_state *uts)
ut_assertok(bootflow_scan_first(&iter, 0, &bflow));
ut_asserteq(3, iter.num_methods);
ut_asserteq_str("sandbox", iter.method->name);
+ ut_assertok(inject_response(uts));
ut_asserteq(-ENOTSUPP, bootflow_run_boot(&iter, &bflow));
ut_assert_skip_to_line("Boot method 'sandbox' failed and will not be retried");
@@ -372,6 +389,47 @@ static int bootflow_iter_disable(struct unit_test_state *uts)
}
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));
+
+ /*
+ * Make sure that the -G flag makes the scan fail, since this is not
+ * supported when an ordering is provided
+ */
+ console_record_reset_enable();
+ ut_assertok(bootmeth_set_order("efi firmware0"));
+ ut_assertok(run_command("bootflow scan -lG", 0));
+ ut_assert_nextline("Scanning for bootflows in all bootdevs");
+ ut_assert_nextline(
+ "Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(0 bootflows, 0 valid)");
+ ut_assert_console_end();
+
+ ut_assertok(run_command("bootflow scan -l", 0));
+ ut_assert_nextline("Scanning for bootflows in all bootdevs");
+ ut_assert_nextline(
+ "Seq Method State Uclass Part Name Filename");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("Scanning global bootmeth 'firmware0':");
+ ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':");
+ ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':");
+ ut_assert_nextline("Scanning bootdev 'mmc0.bootdev':");
+ ut_assert_nextline("No more bootdevs");
+ ut_assert_nextlinen("---");
+ ut_assert_nextline("(0 bootflows, 0 valid)");
+ ut_assert_console_end();
+
+ return 0;
+}
+BOOTSTD_TEST(bootflow_scan_glob_bootmeth, UT_TESTF_DM | UT_TESTF_SCAN_FDT);
+
/* Check 'bootflow boot' to boot a selected bootflow */
static int bootflow_cmd_boot(struct unit_test_state *uts)
{
@@ -382,6 +440,8 @@ static int bootflow_cmd_boot(struct unit_test_state *uts)
ut_assert_console_end();
ut_assertok(run_command("bootflow select 0", 0));
ut_assert_console_end();
+
+ ut_assertok(inject_response(uts));
ut_asserteq(1, run_command("bootflow boot", 0));
ut_assert_nextline(
"** Booting bootflow 'mmc1.bootdev.part_1' with syslinux");
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 <[email protected]>
*/
#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);
diff --git a/test/boot/vbe_simple.c b/test/boot/vbe_simple.c
new file mode 100644
index 00000000000..2f6979cafcf
--- /dev/null
+++ b/test/boot/vbe_simple.c
@@ -0,0 +1,115 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test for vbe-simple bootmeth. All start with 'vbe_simple'
+ *
+ * Copyright 2023 Google LLC
+ * Written by Simon Glass <[email protected]>
+ */
+
+#include <common.h>
+#include <bootmeth.h>
+#include <dm.h>
+#include <image.h>
+#include <memalign.h>
+#include <mmc.h>
+#include <of_live.h>
+#include <vbe.h>
+#include <version_string.h>
+#include <linux/log2.h>
+#include <test/suites.h>
+#include <test/ut.h>
+#include <u-boot/crc.h>
+#include "bootstd_common.h"
+
+#define NVDATA_START_BLK ((0x400 + 0x400) / MMC_MAX_BLOCK_LEN)
+#define VERSION_START_BLK ((0x400 + 0x800) / MMC_MAX_BLOCK_LEN)
+#define TEST_VERSION "U-Boot v2022.04-local2"
+#define TEST_VERNUM 0x00010002
+
+/* Basic test of reading nvdata and updating a fwupd node in the device tree */
+static int vbe_simple_test_base(struct unit_test_state *uts)
+{
+ ALLOC_CACHE_ALIGN_BUFFER(u8, buf, MMC_MAX_BLOCK_LEN);
+ const char *version, *bl_version;
+ struct event_ft_fixup fixup;
+ struct udevice *dev, *mmc;
+ struct device_node *np;
+ struct blk_desc *desc;
+ char fdt_buf[0x400];
+ char info[100];
+ int node_ofs;
+ ofnode node;
+ u32 vernum;
+
+ /* Set up the version string */
+ ut_assertok(uclass_get_device(UCLASS_MMC, 1, &mmc));
+ desc = blk_get_by_device(mmc);
+ ut_assertnonnull(desc);
+
+ memset(buf, '\0', MMC_MAX_BLOCK_LEN);
+ strcpy(buf, TEST_VERSION);
+ if (blk_dwrite(desc, VERSION_START_BLK, 1, buf) != 1)
+ return log_msg_ret("write", -EIO);
+
+ /* Set up the nvdata */
+ memset(buf, '\0', MMC_MAX_BLOCK_LEN);
+ buf[1] = ilog2(0x40) << 4 | 1;
+ *(u32 *)(buf + 4) = TEST_VERNUM;
+ buf[0] = crc8(0, buf + 1, 0x3f);
+ if (blk_dwrite(desc, NVDATA_START_BLK, 1, buf) != 1)
+ return log_msg_ret("write", -EIO);
+
+ /* Read the version back */
+ ut_assertok(vbe_find_by_any("firmware0", &dev));
+ ut_assertok(bootmeth_get_state_desc(dev, info, sizeof(info)));
+ ut_asserteq_str("Version: " TEST_VERSION "\nVernum: 1/2", info);
+
+ ut_assertok(fdt_create_empty_tree(fdt_buf, sizeof(fdt_buf)));
+ node_ofs = fdt_add_subnode(fdt_buf, 0, "chosen");
+ ut_assert(node_ofs > 0);
+
+ node_ofs = fdt_add_subnode(fdt_buf, node_ofs, "fwupd");
+ ut_assert(node_ofs > 0);
+
+ node_ofs = fdt_add_subnode(fdt_buf, node_ofs, "firmware0");
+ ut_assert(node_ofs > 0);
+
+ /*
+ * This can only work on the live tree, since the ofnode interface for
+ * flat tree assumes that ofnode points to the control FDT
+ */
+ ut_assertok(unflatten_device_tree(fdt_buf, &np));
+
+ /*
+ * It would be better to call image_setup_libfdt() here, but that
+ * function does not allow passing an ofnode. We can pass fdt_buf but
+ * when it comes to send the evenr, it creates an ofnode that uses the
+ * control FDT, since it has no way of accessing the live tree created
+ * here.
+ *
+ * Two fix this we need:
+ * - image_setup_libfdt() is updated to use ofnode
+ * - ofnode updated to support access to an FDT other than the control
+ * FDT. This is partially implemented with live tree, but not with
+ * flat tree
+ */
+ fixup.tree.np = np;
+ ut_assertok(event_notify(EVT_FT_FIXUP, &fixup, sizeof(fixup)));
+
+ node = ofnode_path_root(fixup.tree, "/chosen/fwupd/firmware0");
+
+ version = ofnode_read_string(node, "cur-version");
+ ut_assertnonnull(version);
+ ut_asserteq_str(TEST_VERSION, version);
+
+ ut_assertok(ofnode_read_u32(node, "cur-vernum", &vernum));
+ ut_asserteq(TEST_VERNUM, vernum);
+
+ bl_version = ofnode_read_string(node, "bootloader-version");
+ ut_assertnonnull(bl_version);
+ ut_asserteq_str(version_string, bl_version);
+
+ return 0;
+}
+BOOTSTD_TEST(vbe_simple_test_base, UT_TESTF_DM | UT_TESTF_SCAN_FDT |
+ UT_TESTF_LIVE_TREE);
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index 61ae1db62d7..f80993f8927 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -3,8 +3,13 @@
#include <common.h>
#include <dm.h>
#include <log.h>
+#include <of_live.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
#include <dm/of_extra.h>
+#include <dm/root.h>
#include <dm/test.h>
+#include <dm/uclass-internal.h>
#include <test/test.h>
#include <test/ut.h>
@@ -469,3 +474,130 @@ static int dm_test_ofnode_get_phy(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_ofnode_get_phy, 0);
+
+/**
+ * make_ofnode_fdt() - Create an FDT for testing with ofnode
+ *
+ * The size is set to the minimum needed
+ *
+ * @uts: Test state
+ * @fdt: Place to write FDT
+ * @size: Maximum size of space for fdt
+ */
+static int make_ofnode_fdt(struct unit_test_state *uts, void *fdt, int size)
+{
+ ut_assertok(fdt_create(fdt, size));
+ ut_assertok(fdt_finish_reservemap(fdt));
+ ut_assert(fdt_begin_node(fdt, "") >= 0);
+
+ ut_assert(fdt_begin_node(fdt, "aliases") >= 0);
+ ut_assertok(fdt_property_string(fdt, "mmc0", "/new-mmc"));
+ ut_assertok(fdt_end_node(fdt));
+
+ ut_assert(fdt_begin_node(fdt, "new-mmc") >= 0);
+ ut_assertok(fdt_end_node(fdt));
+
+ ut_assertok(fdt_end_node(fdt));
+ ut_assertok(fdt_finish(fdt));
+
+ return 0;
+}
+
+static int dm_test_ofnode_root(struct unit_test_state *uts)
+{
+ struct device_node *root = NULL;
+ char fdt[256];
+ oftree tree;
+ ofnode node;
+
+ /* Check that aliases work on the control FDT */
+ node = ofnode_get_aliases_node("ethernet3");
+ ut_assert(ofnode_valid(node));
+ ut_asserteq_str("sbe5", ofnode_get_name(node));
+
+ ut_assertok(make_ofnode_fdt(uts, fdt, sizeof(fdt)));
+ if (of_live_active()) {
+ ut_assertok(unflatten_device_tree(fdt, &root));
+ tree.np = root;
+ } else {
+ tree.fdt = fdt;
+ }
+
+ /* Make sure they don't work on this new tree */
+ node = ofnode_path_root(tree, "mmc0");
+ ut_assert(!ofnode_valid(node));
+
+ /* It should appear in the new tree */
+ node = ofnode_path_root(tree, "/new-mmc");
+ ut_assert(ofnode_valid(node));
+
+ /* ...and not in the control FDT */
+ node = ofnode_path_root(oftree_default(), "/new-mmc");
+ ut_assert(!ofnode_valid(node));
+
+ free(root);
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_root, UT_TESTF_SCAN_FDT);
+
+static int dm_test_ofnode_livetree_writing(struct unit_test_state *uts)
+{
+ struct udevice *dev;
+ ofnode node;
+
+ /* Test enabling devices */
+ node = ofnode_path("/usb@2");
+
+ ut_assert(!ofnode_is_enabled(node));
+ ut_assertok(ofnode_set_enabled(node, true));
+ ut_asserteq(true, ofnode_is_enabled(node));
+
+ device_bind_driver_to_node(dm_root(), "usb_sandbox", "usb@2", node,
+ &dev);
+ ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, &dev));
+
+ /* Test string property setting */
+ ut_assert(device_is_compatible(dev, "sandbox,usb"));
+ ofnode_write_string(node, "compatible", "gdsys,super-usb");
+ ut_assert(device_is_compatible(dev, "gdsys,super-usb"));
+ ofnode_write_string(node, "compatible", "sandbox,usb");
+ ut_assert(device_is_compatible(dev, "sandbox,usb"));
+
+ /* Test setting generic properties */
+
+ /* Non-existent in DTB */
+ ut_asserteq_64(FDT_ADDR_T_NONE, dev_read_addr(dev));
+ /* reg = 0x42, size = 0x100 */
+ ut_assertok(ofnode_write_prop(node, "reg",
+ "\x00\x00\x00\x42\x00\x00\x01\x00", 8));
+ ut_asserteq(0x42, dev_read_addr(dev));
+
+ /* Test disabling devices */
+ device_remove(dev, DM_REMOVE_NORMAL);
+ device_unbind(dev);
+
+ ut_assert(ofnode_is_enabled(node));
+ ut_assertok(ofnode_set_enabled(node, false));
+ ut_assert(!ofnode_is_enabled(node));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_livetree_writing,
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_OR_FLAT);
+
+static int dm_test_ofnode_u32(struct unit_test_state *uts)
+{
+ ofnode node;
+
+ node = ofnode_path("/lcd");
+ ut_assert(ofnode_valid(node));
+ ut_asserteq(1366, ofnode_read_u32_default(node, "xres", 123));
+ ut_assertok(ofnode_write_u32(node, "xres", 1367));
+ ut_asserteq(1367, ofnode_read_u32_default(node, "xres", 123));
+ ut_assertok(ofnode_write_u32(node, "xres", 1366));
+
+ return 0;
+}
+DM_TEST(dm_test_ofnode_u32,
+ UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT | UT_TESTF_LIVE_OR_FLAT);
diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index f9e81747595..6118ad42ca8 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -17,7 +17,6 @@
#include <dm/devres.h>
#include <dm/uclass-internal.h>
#include <dm/util.h>
-#include <dm/lists.h>
#include <dm/of_access.h>
#include <linux/ioport.h>
#include <test/test.h>
@@ -735,58 +734,6 @@ static int dm_test_fdt_remap_addr_name_live(struct unit_test_state *uts)
DM_TEST(dm_test_fdt_remap_addr_name_live,
UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-static int dm_test_fdt_livetree_writing(struct unit_test_state *uts)
-{
- struct udevice *dev;
- ofnode node;
-
- if (!of_live_active()) {
- printf("Live tree not active; ignore test\n");
- return 0;
- }
-
- /* Test enabling devices */
-
- node = ofnode_path("/usb@2");
-
- ut_assert(!of_device_is_available(ofnode_to_np(node)));
- ofnode_set_enabled(node, true);
- ut_assert(of_device_is_available(ofnode_to_np(node)));
-
- device_bind_driver_to_node(dm_root(), "usb_sandbox", "usb@2", node,
- &dev);
- ut_assertok(uclass_find_device_by_seq(UCLASS_USB, 2, &dev));
-
- /* Test string property setting */
-
- ut_assert(device_is_compatible(dev, "sandbox,usb"));
- ofnode_write_string(node, "compatible", "gdsys,super-usb");
- ut_assert(device_is_compatible(dev, "gdsys,super-usb"));
- ofnode_write_string(node, "compatible", "sandbox,usb");
- ut_assert(device_is_compatible(dev, "sandbox,usb"));
-
- /* Test setting generic properties */
-
- /* Non-existent in DTB */
- ut_asserteq_64(FDT_ADDR_T_NONE, dev_read_addr(dev));
- /* reg = 0x42, size = 0x100 */
- ut_assertok(ofnode_write_prop(node, "reg", 8,
- "\x00\x00\x00\x42\x00\x00\x01\x00"));
- ut_asserteq(0x42, dev_read_addr(dev));
-
- /* Test disabling devices */
-
- device_remove(dev, DM_REMOVE_NORMAL);
- device_unbind(dev);
-
- ut_assert(of_device_is_available(ofnode_to_np(node)));
- ofnode_set_enabled(node, false);
- ut_assert(!of_device_is_available(ofnode_to_np(node)));
-
- return 0;
-}
-DM_TEST(dm_test_fdt_livetree_writing, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-
static int dm_test_fdt_disable_enable_by_path(struct unit_test_state *uts)
{
ofnode node;
diff --git a/test/py/tests/test_event_dump.py b/test/py/tests/test_event_dump.py
index b753e804ac3..bc54149e8f2 100644
--- a/test/py/tests/test_event_dump.py
+++ b/test/py/tests/test_event_dump.py
@@ -16,5 +16,6 @@ def test_event_dump(u_boot_console):
out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox])
expect = '''.*Event type Id Source location
-------------------- ------------------------------ ------------------------------
+EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple.c:.*
EVT_MISC_INIT_F sandbox_misc_init_f .*arch/sandbox/cpu/start.c:'''
assert re.match(expect, out, re.MULTILINE) is not None
diff --git a/test/test-main.c b/test/test-main.c
index ee38d1faea8..31837e57a8f 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -228,8 +228,10 @@ static int test_pre_run(struct unit_test_state *uts, struct unit_test *test)
uts->start = mallinfo();
- if (test->flags & UT_TESTF_SCAN_PDATA)
+ if (test->flags & UT_TESTF_SCAN_PDATA) {
ut_assertok(dm_scan_plat(false));
+ ut_assertok(dm_scan_other(false));
+ }
if (test->flags & UT_TESTF_PROBE_TEST)
ut_assertok(do_autoprobe(uts));
@@ -338,7 +340,8 @@ static int ut_run_test_live_flat(struct unit_test_state *uts,
/* Run with the live tree if possible */
runs = 0;
if (CONFIG_IS_ENABLED(OF_LIVE)) {
- if (!(test->flags & UT_TESTF_FLAT_TREE)) {
+ if (!(test->flags &
+ (UT_TESTF_FLAT_TREE | UT_TESTF_LIVE_OR_FLAT))) {
uts->of_live = true;
ut_assertok(ut_run_test(uts, test, test->name));
runs++;