diff mbox series

[U-Boot,v3,08/31] test: dm: blk: Correct blk_base test case

Message ID 1539595287-31378-9-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Simon Glass
Headers show
Series virtio: Introduce VirtIO driver support | expand

Commit Message

Bin Meng Oct. 15, 2018, 9:21 a.m. UTC
The blk_base test case creates a USB mass storage block device with
the Sandbox host block device as its parent. This does not make any
sense and causes potential issue, for example if the test case tries
to read/write anything on the USB mass storage block device it will
definitely fail as its parent is not on USB bus at all.

Correct the test case by creating another Sandbox host block device
instead of the USB mass storage one and adjust the case accordingly.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 test/dm/blk.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

Comments

Simon Glass Oct. 24, 2018, 5:32 p.m. UTC | #1
The blk_base test case creates a USB mass storage block device with
the Sandbox host block device as its parent. This does not make any
sense and causes potential issue, for example if the test case tries
to read/write anything on the USB mass storage block device it will
definitely fail as its parent is not on USB bus at all.

Correct the test case by creating another Sandbox host block device
instead of the USB mass storage one and adjust the case accordingly.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 test/dm/blk.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

Applied to u-boot-dm/next, thanks!
diff mbox series

Patch

diff --git a/test/dm/blk.c b/test/dm/blk.c
index 4de477b..9c71adc 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -15,34 +15,29 @@  DECLARE_GLOBAL_DATA_PTR;
 /* Test that block devices can be created */
 static int dm_test_blk_base(struct unit_test_state *uts)
 {
-	struct udevice *blk, *usb_blk, *dev;
+	struct udevice *blk1, *blk3, *dev;
 
 	/* Make sure there are no block devices */
-	ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_BLK, 0, &blk));
+	ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_BLK, 0, &dev));
 
 	/* Create two, one the parent of the other */
 	ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
-				      IF_TYPE_HOST, 1, 512, 2, &blk));
-	ut_assertok(blk_create_device(blk, "usb_storage_blk", "test",
-				      IF_TYPE_USB, 3, 512, 2, &usb_blk));
+				      IF_TYPE_HOST, 1, 512, 2, &blk1));
+	ut_assertok(blk_create_device(blk1, "sandbox_host_blk", "test",
+				      IF_TYPE_HOST, 3, 512, 2, &blk3));
 
 	/* Check we can find them */
 	ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev));
 	ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
-	ut_asserteq_ptr(blk, dev);
-
-	ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_USB, 0, &dev));
-	ut_assertok(blk_get_device(IF_TYPE_USB, 3, &dev));
-	ut_asserteq_ptr(usb_blk, dev);
+	ut_asserteq_ptr(blk1, dev);
+	ut_assertok(blk_get_device(IF_TYPE_HOST, 3, &dev));
+	ut_asserteq_ptr(blk3, dev);
 
 	/* Check we can iterate */
 	ut_assertok(blk_first_device(IF_TYPE_HOST, &dev));
-	ut_asserteq_ptr(blk, dev);
-	ut_asserteq(-ENODEV, blk_next_device(&dev));
-
-	ut_assertok(blk_first_device(IF_TYPE_USB, &dev));
-	ut_asserteq_ptr(usb_blk, dev);
-	ut_asserteq(-ENODEV, blk_next_device(&dev));
+	ut_asserteq_ptr(blk1, dev);
+	ut_assertok(blk_next_device(&dev));
+	ut_asserteq_ptr(blk3, dev);
 
 	return 0;
 }