summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2023-07-18 09:55:32 -0400
committerTom Rini <[email protected]>2023-07-18 09:55:32 -0400
commit890233ca5569e5787d8407596a12b9fca80952bf (patch)
tree966b9beb01a0ca57045bec4b4da2e16cb792757f /test
parent13aa090b87a0fbdfe690011669b9fdb96bb1ccc7 (diff)
parent4dc5e26242101f9090209e659e60422634c8bbcf (diff)
Merge branch '2023-07-17-assorted-updates'
- Merge in some Kconfig dependencies fixes, typo fixes, erofs update, shell portability fix, an env save fix, better mbr+gpt support, and some android A/B enhancements.
Diffstat (limited to 'test')
-rw-r--r--test/dm/part.c115
-rw-r--r--test/py/tests/test_cat/conftest.py3
-rw-r--r--test/py/tests/test_xxd/conftest.py3
3 files changed, 106 insertions, 15 deletions
diff --git a/test/dm/part.c b/test/dm/part.c
index 35e99eeb01a..d6e43458127 100644
--- a/test/dm/part.c
+++ b/test/dm/part.c
@@ -17,10 +17,12 @@ static int do_test(struct unit_test_state *uts, int expected,
struct blk_desc *mmc_dev_desc;
struct disk_partition part_info;
- ut_asserteq(expected,
- part_get_info_by_dev_and_name_or_num("mmc", part_str,
- &mmc_dev_desc,
- &part_info, whole));
+ int ret = part_get_info_by_dev_and_name_or_num("mmc", part_str,
+ &mmc_dev_desc,
+ &part_info, whole);
+
+ ut_assertf(expected == ret, "test(%d, \"%s\", %d) == %d", expected,
+ part_str, whole, ret);
return 0;
}
@@ -76,15 +78,15 @@ static int dm_test_part(struct unit_test_state *uts)
test(-EINVAL, "#test1", true);
test(1, "2", false);
test(1, "2", true);
- test(-ENOENT, "1:0", false);
- test(0, "1:0", true);
- test(1, "1:1", false);
- test(2, "1:2", false);
- test(1, "1.0", false);
- test(0, "1.0:0", true);
- test(1, "1.0:1", false);
- test(2, "1.0:2", false);
- test(-EINVAL, "1#bogus", false);
+ test(-ENOENT, "2:0", false);
+ test(0, "2:0", true);
+ test(1, "2:1", false);
+ test(2, "2:2", false);
+ test(1, "2.0", false);
+ test(0, "2.0:0", true);
+ test(1, "2.0:1", false);
+ test(2, "2.0:2", false);
+ test(-EINVAL, "2#bogus", false);
test(1, "2#test1", false);
test(2, "2#test2", false);
ret = 0;
@@ -106,3 +108,90 @@ static int dm_test_part_bootable(struct unit_test_state *uts)
return 0;
}
DM_TEST(dm_test_part_bootable, UT_TESTF_SCAN_FDT);
+
+static int do_get_info_test(struct unit_test_state *uts,
+ struct blk_desc *dev_desc, int part, int part_type,
+ struct disk_partition const *reference)
+{
+ struct disk_partition p;
+ int ret;
+
+ memset(&p, 0, sizeof(p));
+
+ ret = part_get_info_by_type(dev_desc, part, part_type, &p);
+ printf("part_get_info_by_type(%d, 0x%x) = %d\n", part, part_type, ret);
+ if (ut_assertok(ret)) {
+ return 0;
+ }
+
+ ut_asserteq(reference->start, p.start);
+ ut_asserteq(reference->size, p.size);
+ ut_asserteq(reference->sys_ind, p.sys_ind);
+
+ return 0;
+}
+
+static int dm_test_part_get_info_by_type(struct unit_test_state *uts)
+{
+ char str_disk_guid[UUID_STR_LEN + 1];
+ struct blk_desc *mmc_dev_desc;
+ struct disk_partition gpt_parts[] = {
+ {
+ .start = 48, /* GPT data takes up the first 34 blocks or so */
+ .size = 1,
+ .name = "test1",
+ .sys_ind = 0,
+ },
+ {
+ .start = 49,
+ .size = 1,
+ .name = "test2",
+ .sys_ind = 0,
+ },
+ };
+ struct disk_partition mbr_parts[] = {
+ {
+ .start = 1,
+ .size = 33,
+ .name = "gpt",
+ .sys_ind = EFI_PMBR_OSTYPE_EFI_GPT,
+ },
+ {
+ .start = 48,
+ .size = 1,
+ .name = "test1",
+ .sys_ind = 0x83,
+ },
+ };
+
+ ut_asserteq(2, blk_get_device_by_str("mmc", "2", &mmc_dev_desc));
+ if (CONFIG_IS_ENABLED(RANDOM_UUID)) {
+ gen_rand_uuid_str(gpt_parts[0].uuid, UUID_STR_FORMAT_STD);
+ gen_rand_uuid_str(gpt_parts[1].uuid, UUID_STR_FORMAT_STD);
+ gen_rand_uuid_str(str_disk_guid, UUID_STR_FORMAT_STD);
+ }
+ ut_assertok(gpt_restore(mmc_dev_desc, str_disk_guid, gpt_parts,
+ ARRAY_SIZE(gpt_parts)));
+
+ ut_assertok(write_mbr_partitions(mmc_dev_desc, mbr_parts,
+ ARRAY_SIZE(mbr_parts), 0));
+
+#define get_info_test(_part, _part_type, _reference) \
+ ut_assertok(do_get_info_test(uts, mmc_dev_desc, _part, _part_type, \
+ _reference))
+
+ for (int i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ get_info_test(i + 1, PART_TYPE_UNKNOWN, &gpt_parts[i]);
+ }
+
+ for (int i = 0; i < ARRAY_SIZE(mbr_parts); i++) {
+ get_info_test(i + 1, PART_TYPE_DOS, &mbr_parts[i]);
+ }
+
+ for (int i = 0; i < ARRAY_SIZE(gpt_parts); i++) {
+ get_info_test(i + 1, PART_TYPE_EFI, &gpt_parts[i]);
+ }
+
+ return 0;
+}
+DM_TEST(dm_test_part_get_info_by_type, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
diff --git a/test/py/tests/test_cat/conftest.py b/test/py/tests/test_cat/conftest.py
index fc396f50d32..320e7ebd295 100644
--- a/test/py/tests/test_cat/conftest.py
+++ b/test/py/tests/test_cat/conftest.py
@@ -32,4 +32,5 @@ def cat_data(u_boot_config):
pytest.skip('Setup failed')
finally:
shutil.rmtree(mnt_point)
- os.remove(image_path)
+ if os.path.exists(image_path):
+ os.remove(image_path)
diff --git a/test/py/tests/test_xxd/conftest.py b/test/py/tests/test_xxd/conftest.py
index f35b8f11136..47c7cce1aa9 100644
--- a/test/py/tests/test_xxd/conftest.py
+++ b/test/py/tests/test_xxd/conftest.py
@@ -32,4 +32,5 @@ def xxd_data(u_boot_config):
pytest.skip('Setup failed')
finally:
shutil.rmtree(mnt_point)
- os.remove(image_path)
+ if os.path.exists(image_path):
+ os.remove(image_path)