]> git.sur5r.net Git - u-boot/commitdiff
dm: test: Add tests for get/find uclass devices
authorPrzemyslaw Marczak <p.marczak@samsung.com>
Wed, 15 Apr 2015 11:07:20 +0000 (13:07 +0200)
committerSimon Glass <sjg@chromium.org>
Wed, 22 Apr 2015 17:03:14 +0000 (11:03 -0600)
This commit introduces simple tests for functions:
- uclass_find_first_device()
- uclass_find_next_device()
- uclass_first_device()
- uclass_next_device()

Tests added by this commit:
- Test: dm_test_uclass_devices_find:
  * call uclass_find_first_device(), then check if: (dev != NULL), (ret == 0)
  * for the rest devices, call uclass_find_next_device() and do the same check

- Test: dm_test_uclass_devices_get:
  * call uclass_first_device(), then check if:
    -- (dev != NULL), (ret == 0), device_active()
  * for the rest devices, call uclass_next_device() and do the same check

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Cc: Simon Glass <sjg@chromium.org>
Acked-by: Simon Glass <sjg@chromium.org>
test/dm/core.c

index 009ad369366c9205e92a2d2fad79aa244a75a63d..3a8dd1d7e8caf6ce4f2864abbfd829795db5e0cb 100644 (file)
@@ -656,9 +656,41 @@ static int dm_test_uclass_before_ready(struct dm_test_state *dms)
 
        return 0;
 }
-
 DM_TEST(dm_test_uclass_before_ready, 0);
 
+static int dm_test_uclass_devices_find(struct dm_test_state *dms)
+{
+       struct udevice *dev;
+       int ret;
+
+       for (ret = uclass_find_first_device(UCLASS_TEST, &dev);
+            dev;
+            ret = uclass_find_next_device(&dev)) {
+               ut_assert(!ret);
+               ut_assert(dev);
+       }
+
+       return 0;
+}
+DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA);
+
+static int dm_test_uclass_devices_get(struct dm_test_state *dms)
+{
+       struct udevice *dev;
+       int ret;
+
+       for (ret = uclass_first_device(UCLASS_TEST, &dev);
+            dev;
+            ret = uclass_next_device(&dev)) {
+               ut_assert(!ret);
+               ut_assert(dev);
+               ut_assert(device_active(dev));
+       }
+
+       return 0;
+}
+DM_TEST(dm_test_uclass_devices_get, DM_TESTF_SCAN_PDATA);
+
 static int dm_test_device_get_uclass_id(struct dm_test_state *dms)
 {
        struct udevice *dev;