summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLoic Poulain <loic.poulain@linaro.org>2023-01-26 10:24:19 +0100
committerJaehoon Chung <jh80.chung@samsung.com>2023-04-10 12:17:32 +0900
commit94f40b94506397d4927c800f38e96a95e5c50c71 (patch)
tree6bfeda2a6e9cb4951d4bc05f372990a7c3de2b32 /test
parent67642c1254fc7b1392c2745ead609255345f2d25 (diff)
downloadu-boot-94f40b94506397d4927c800f38e96a95e5c50c71.tar.gz
test: dm: mmc: Check block erasing boundaries
Verify that erasing blocks does not impact adjacent ones. - Write four blocks [0 1 2 3] - Erase two blocks [ 1 2 ] - Verify [0 1 2 3 ] Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/mmc.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/dm/mmc.c b/test/dm/mmc.c
index f744452ff2..b1eb8bee2f 100644
--- a/test/dm/mmc.c
+++ b/test/dm/mmc.c
@@ -30,7 +30,7 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
struct udevice *dev;
struct blk_desc *dev_desc;
int i;
- char write[1024], read[1024];
+ char write[4 * 512], read[4 * 512];
ut_assertok(uclass_get_device(UCLASS_MMC, 0, &dev));
ut_assertok(blk_get_device_by_str("mmc", "0", &dev_desc));
@@ -39,14 +39,14 @@ static int dm_test_mmc_blk(struct unit_test_state *uts)
ut_asserteq(512, dev_desc->blksz);
for (i = 0; i < sizeof(write); i++)
write[i] = i;
- ut_asserteq(2, blk_dwrite(dev_desc, 0, 2, write));
- ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
+ ut_asserteq(4, blk_dwrite(dev_desc, 0, 4, write));
+ ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
ut_asserteq_mem(write, read, sizeof(write));
- /* Now erase them */
- memset(write, '\0', sizeof(write));
- ut_asserteq(2, blk_derase(dev_desc, 0, 2));
- ut_asserteq(2, blk_dread(dev_desc, 0, 2, read));
+ /* Now erase two of them [1 - 2] and verify all blocks */
+ memset(&write[512], '\0', 2 * 512);
+ ut_asserteq(2, blk_derase(dev_desc, 1, 2));
+ ut_asserteq(4, blk_dread(dev_desc, 0, 4, read));
ut_asserteq_mem(write, read, sizeof(write));
return 0;