[PATCH v4 8/8] test: dm: Add partition type GUID lookup test
Balaji Selvanathan
balaji.selvanathan at oss.qualcomm.com
Tue Apr 28 09:31:50 CEST 2026
Add a unit test for the partition type GUID lookup functionality. The
test verifies that partitions can be correctly identified by their type
GUID, specifically testing the ChromeOS kernel partition lookup.
Reviewed-by: Simon Glass <sjg at chromium.org>
Signed-off-by: Balaji Selvanathan <balaji.selvanathan at oss.qualcomm.com>
---
Changes in v4:
- Return -EAGAIN instead of EOPNOTSUPP
- Add extra asserts for kernel partition
Changes in v3:
- Add unit test for the partition type GUID lookup functionality
---
test/dm/part.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/test/dm/part.c b/test/dm/part.c
index caae23bd4aa..7a427d3d41d 100644
--- a/test/dm/part.c
+++ b/test/dm/part.c
@@ -8,9 +8,13 @@
#include <mmc.h>
#include <part.h>
#include <part_efi.h>
+#include <asm/global_data.h>
+#include <dm/lists.h>
#include <dm/test.h>
#include <test/ut.h>
+DECLARE_GLOBAL_DATA_PTR;
+
static int do_test(struct unit_test_state *uts, int expected,
const char *part_str, bool whole)
{
@@ -195,3 +199,48 @@ static int dm_test_part_get_info_by_type(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_part_get_info_by_type, UTF_SCAN_PDATA | UTF_SCAN_FDT);
+
+static int dm_test_part_get_info_by_type_guid(struct unit_test_state *uts)
+{
+ struct udevice *dev, *blk_dev;
+ struct blk_desc *desc;
+ struct disk_partition info;
+ ofnode root, node;
+ int partnum;
+
+ if (!IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))
+ return -EAGAIN;
+
+ /* Bind the mmc5 node (ChromeOS image with type GUIDs) */
+ root = oftree_root(oftree_default());
+ node = ofnode_find_subnode(root, "mmc5");
+ ut_assert(ofnode_valid(node));
+ ut_assertok(lists_bind_fdt(gd->dm_root, node, &dev, NULL, false));
+
+ /* Get the MMC device (probes it), then walk MMC -> BLK parent link */
+ ut_assertok(uclass_get_device_by_seq(UCLASS_MMC, 5, &dev));
+ ut_assertok(blk_get_from_parent(dev, &blk_dev));
+ desc = dev_get_uclass_plat(blk_dev);
+ ut_assert(desc);
+
+ /*
+ * Test: look up the first ChromeOS kernel partition by type GUID.
+ * In the ChromeOS image KERN_A is the first partition carrying the
+ * ChromeOS kernel type GUID (fe3a2a5d-...). This is partition 2.
+ */
+ partnum = part_get_info_by_type_guid(desc,
+ "FE3A2A5D-4F32-41A7-B725-ACCC3285A309",
+ &info);
+ ut_asserteq(2, partnum);
+ ut_asserteq_str("KERN_A", info.name);
+
+ /* Test: non-existent GUID must return -ENOENT */
+ ut_asserteq(-ENOENT,
+ part_get_info_by_type_guid(desc,
+ "00000000-0000-0000-0000-000000000000",
+ &info));
+
+ return 0;
+}
+
+DM_TEST(dm_test_part_get_info_by_type_guid, UTF_SCAN_PDATA | UTF_SCAN_FDT);
--
2.34.1
More information about the U-Boot
mailing list