dm: core: Add a way to iterate through children, probing each
[platform/kernel/u-boot.git] / test / dm / test-fdt.c
index 8fe4425..cd65e42 100644 (file)
@@ -891,3 +891,22 @@ static int dm_test_child_ofdata(struct unit_test_state *uts)
        return 0;
 }
 DM_TEST(dm_test_child_ofdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+/* Test device_first_child_err(), etc. */
+static int dm_test_first_child_probe(struct unit_test_state *uts)
+{
+       struct udevice *bus, *dev;
+       int count;
+
+       ut_assertok(uclass_first_device_err(UCLASS_TEST_BUS, &bus));
+       count = 0;
+       device_foreach_child_probe(dev, bus) {
+               ut_assert(dev->flags & DM_FLAG_PLATDATA_VALID);
+               ut_assert(dev->flags & DM_FLAG_ACTIVATED);
+               count++;
+       }
+       ut_asserteq(3, count);
+
+       return 0;
+}
+DM_TEST(dm_test_first_child_probe, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);