[U-Boot] [PATCH 2/8] test: Add tests for uclass_{first, next}_device_compat

Mario Six mario.six at gdsys.cc
Wed Mar 28 12:38:26 UTC 2018


Add tests for the uclass_{first,next}_device_compat functions.

Signed-off-by: Mario Six <mario.six at gdsys.cc>
---
 test/dm/core.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/test/dm/core.c b/test/dm/core.c
index 052bf8fffb..7df197eb40 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -852,6 +852,35 @@ static int dm_test_uclass_devices_get_by_name(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_uclass_devices_get_by_name, DM_TESTF_SCAN_FDT);

+static int dm_test_uclass_devices_get_by_compat(struct unit_test_state *uts)
+{
+	struct udevice *testdev;
+	int ret;
+
+	for (ret = uclass_first_device_compat(UCLASS_TEST_FDT, &testdev, "denx,u-boot-fdt-test");
+	     testdev;
+	     ret = uclass_next_device_compat(&testdev, "denx,u-boot-fdt-test")) {
+		ut_assertok(ret);
+		ut_assert(testdev);
+		ut_assert(device_active(testdev));
+		ut_asserteq(device_is_compatible(testdev, "denx,u-boot-fdt-test"), true);
+		ut_asserteq(device_is_compatible(testdev, "google,another-fdt-test"), false);
+	}
+
+	for (ret = uclass_first_device_compat(UCLASS_TEST_FDT, &testdev, "google,another-fdt-test");
+	     testdev;
+	     ret = uclass_next_device_compat(&testdev, "google,another-fdt-test")) {
+		ut_assertok(ret);
+		ut_assert(testdev);
+		ut_assert(device_active(testdev));
+		ut_asserteq(device_is_compatible(testdev, "denx,u-boot-fdt-test"), false);
+		ut_asserteq(device_is_compatible(testdev, "google,another-fdt-test"), true);
+	}
+
+	return 0;
+}
+DM_TEST(dm_test_uclass_devices_get_by_compat, DM_TESTF_SCAN_FDT);
+
 static int dm_test_device_get_uclass_id(struct unit_test_state *uts)
 {
 	struct udevice *dev;
--
2.16.1



More information about the U-Boot mailing list