aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBin Meng2018-10-15 04:21:04 -0500
committerSimon Glass2018-11-14 11:16:27 -0600
commitfa583f86c97f407997f1c46b8009b26c4c58efb9 (patch)
treea37dec5b1c44219324f934b69902f4d45a5dde6b
parentf371ad3064699f460711523db5e8177a0fc7b22e (diff)
downloadu-boot-fa583f86c97f407997f1c46b8009b26c4c58efb9.tar.gz
u-boot-fa583f86c97f407997f1c46b8009b26c4c58efb9.tar.xz
u-boot-fa583f86c97f407997f1c46b8009b26c4c58efb9.zip
test: dm: blk: Correct blk_base test case
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>
-rw-r--r--test/dm/blk.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/test/dm/blk.c b/test/dm/blk.c
index 4de477bafa..9c71adc69d 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -15,34 +15,29 @@ DECLARE_GLOBAL_DATA_PTR;
15/* Test that block devices can be created */ 15/* Test that block devices can be created */
16static int dm_test_blk_base(struct unit_test_state *uts) 16static int dm_test_blk_base(struct unit_test_state *uts)
17{ 17{
18 struct udevice *blk, *usb_blk, *dev; 18 struct udevice *blk1, *blk3, *dev;
19 19
20 /* Make sure there are no block devices */ 20 /* Make sure there are no block devices */
21 ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_BLK, 0, &blk)); 21 ut_asserteq(-ENODEV, uclass_get_device_by_seq(UCLASS_BLK, 0, &dev));
22 22
23 /* Create two, one the parent of the other */ 23 /* Create two, one the parent of the other */
24 ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test", 24 ut_assertok(blk_create_device(gd->dm_root, "sandbox_host_blk", "test",
25 IF_TYPE_HOST, 1, 512, 2, &blk)); 25 IF_TYPE_HOST, 1, 512, 2, &blk1));
26 ut_assertok(blk_create_device(blk, "usb_storage_blk", "test", 26 ut_assertok(blk_create_device(blk1, "sandbox_host_blk", "test",
27 IF_TYPE_USB, 3, 512, 2, &usb_blk)); 27 IF_TYPE_HOST, 3, 512, 2, &blk3));
28 28
29 /* Check we can find them */ 29 /* Check we can find them */
30 ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev)); 30 ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_HOST, 0, &dev));
31 ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev)); 31 ut_assertok(blk_get_device(IF_TYPE_HOST, 1, &dev));
32 ut_asserteq_ptr(blk, dev); 32 ut_asserteq_ptr(blk1, dev);
33 33 ut_assertok(blk_get_device(IF_TYPE_HOST, 3, &dev));
34 ut_asserteq(-ENODEV, blk_get_device(IF_TYPE_USB, 0, &dev)); 34 ut_asserteq_ptr(blk3, dev);
35 ut_assertok(blk_get_device(IF_TYPE_USB, 3, &dev));
36 ut_asserteq_ptr(usb_blk, dev);
37 35
38 /* Check we can iterate */ 36 /* Check we can iterate */
39 ut_assertok(blk_first_device(IF_TYPE_HOST, &dev)); 37 ut_assertok(blk_first_device(IF_TYPE_HOST, &dev));
40 ut_asserteq_ptr(blk, dev); 38 ut_asserteq_ptr(blk1, dev);
41 ut_asserteq(-ENODEV, blk_next_device(&dev)); 39 ut_assertok(blk_next_device(&dev));
42 40 ut_asserteq_ptr(blk3, dev);
43 ut_assertok(blk_first_device(IF_TYPE_USB, &dev));
44 ut_asserteq_ptr(usb_blk, dev);
45 ut_asserteq(-ENODEV, blk_next_device(&dev));
46 41
47 return 0; 42 return 0;
48} 43}