[U-Boot] [PATCH v2 4/4] test: Add tests for dev_{enable, disable}_by_path

Mario Six mario.six at gdsys.cc
Fri Apr 27 12:51:49 UTC 2018


Add tests for the dev_{enable,disable}_by_path functions.

Signed-off-by: Mario Six <mario.six at gdsys.cc>

---

v1 -> v2:
New in v2

---
 test/dm/test-fdt.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 3067510433..903b8cc9dc 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -515,3 +515,30 @@ static int dm_test_fdt_livetree_writing(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_fdt_livetree_writing, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
+
+static int dm_test_fdt_disable_enable_by_path(struct unit_test_state *uts)
+{
+	ofnode node;
+
+	if (!of_live_active()) {
+		printf("Live tree not active; ignore test\n");
+		return 0;
+	}
+
+	node = ofnode_path("/usb at 2");
+
+	/* Test enabling devices */
+
+	ut_assert(!of_device_is_available(ofnode_to_np(node)));
+	dev_enable_by_path("/usb at 2");
+	ut_assert(of_device_is_available(ofnode_to_np(node)));
+
+	/* Test disabling devices */
+
+	ut_assert(of_device_is_available(ofnode_to_np(node)));
+	dev_disable_by_path("/usb at 2");
+	ut_assert(!of_device_is_available(ofnode_to_np(node)));
+
+	return 0;
+}
+DM_TEST(dm_test_fdt_disable_enable_by_path, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);
--
2.16.1



More information about the U-Boot mailing list