mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
test: dm: part: add test for part_get_info_by_uuid
Add a new unit test for the part_get_info_by_uuid() function. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Patrice Chotard
parent
2a55938b42
commit
27a928553a
@@ -195,3 +195,56 @@ 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_uuid(struct unit_test_state *uts)
|
||||
{
|
||||
struct disk_partition parts[] = {
|
||||
{
|
||||
.start = 48,
|
||||
.size = 1,
|
||||
.name = "test1",
|
||||
.uuid = "c5bce7a2-03f0-4d03-9048-01ff23b9d527",
|
||||
},
|
||||
{
|
||||
.start = 49,
|
||||
.size = 1,
|
||||
.name = "test2",
|
||||
.uuid = "9df346e8-2c53-4cd8-b9ac-3af83f9a9b74",
|
||||
},
|
||||
};
|
||||
char disk_guid[UUID_STR_LEN + 1] =
|
||||
"8d60b397-1bb6-4d33-80ee-b1587d24c2f8";
|
||||
struct blk_desc *mmc_dev_desc;
|
||||
struct disk_partition info;
|
||||
int part, i;
|
||||
|
||||
ut_asserteq(2, blk_get_device_by_str("mmc", "2", &mmc_dev_desc));
|
||||
|
||||
if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
|
||||
for (i = 0; i < ARRAY_SIZE(parts); i++)
|
||||
gen_rand_uuid_str(parts[i].uuid, UUID_STR_FORMAT_STD);
|
||||
|
||||
gen_rand_uuid_str(disk_guid, UUID_STR_FORMAT_STD);
|
||||
}
|
||||
|
||||
ut_assertok(gpt_restore(mmc_dev_desc, disk_guid, parts,
|
||||
ARRAY_SIZE(parts)));
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(parts); i++) {
|
||||
part = part_get_info_by_uuid(mmc_dev_desc, parts[i].uuid,
|
||||
&info);
|
||||
|
||||
ut_asserteq(i + 1, part);
|
||||
ut_asserteq_str(parts[i].name, info.name);
|
||||
ut_asserteq(parts[i].start, info.start);
|
||||
ut_asserteq(parts[i].size, info.size);
|
||||
}
|
||||
|
||||
part = part_get_info_by_uuid(mmc_dev_desc,
|
||||
"00000000-0000-0000-0000-000000000000",
|
||||
&info);
|
||||
ut_assert(part < 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
DM_TEST(dm_test_part_get_info_by_uuid, UTF_SCAN_PDATA | UTF_SCAN_FDT);
|
||||
|
||||
Reference in New Issue
Block a user