aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-10-20 18:22:55 -0600
committerTom Rini <trini@konsulko.com>2022-10-31 11:02:44 -0400
commit2ff3db3a1c5ef128a4f33c22d7be8ee37fca3613 (patch)
treeb039cad266e4cb9f32200eadbaebb5f6c484e514 /test
parent606b926f9d76eaab11be2d95cfd7734644e1627c (diff)
downloadu-boot-2ff3db3a1c5ef128a4f33c22d7be8ee37fca3613.zip
u-boot-2ff3db3a1c5ef128a4f33c22d7be8ee37fca3613.tar.gz
u-boot-2ff3db3a1c5ef128a4f33c22d7be8ee37fca3613.tar.bz2
usb: Update the test to cover reading and writing
Add test coverage for blk_write() as well. The blk_erase() is not tested for now as the USB stor interface does not support erase. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/usb.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/dm/usb.c b/test/dm/usb.c
index 445b21a..7671ef1 100644
--- a/test/dm/usb.c
+++ b/test/dm/usb.c
@@ -61,7 +61,24 @@ static int dm_test_usb_flash(struct unit_test_state *uts)
ut_asserteq(512, dev_desc->blksz);
memset(cmp, '\0', sizeof(cmp));
ut_asserteq(2, blk_read(blk, 0, 2, cmp));
- ut_assertok(strcmp(cmp, "this is a test"));
+ ut_asserteq_str("this is a test", cmp);
+
+ strcpy(cmp, "another test");
+ ut_asserteq(1, blk_write(blk, 1, 1, cmp));
+
+ memset(cmp, '\0', sizeof(cmp));
+ ut_asserteq(2, blk_read(blk, 0, 2, cmp));
+ ut_asserteq_str("this is a test", cmp);
+ ut_asserteq_str("another test", cmp + 512);
+
+ memset(cmp, '\0', sizeof(cmp));
+ ut_asserteq(1, blk_write(blk, 1, 1, cmp));
+
+ memset(cmp, '\0', sizeof(cmp));
+ ut_asserteq(2, blk_read(blk, 0, 2, cmp));
+ ut_asserteq_str("this is a test", cmp);
+ ut_asserteq_str("", cmp + 512);
+
ut_assertok(usb_stop());
return 0;