diff mbox series

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

Message ID 20180626064651.8551-4-mario.six@gdsys.cc
State Accepted
Commit 172942a4a0afe12a603470db7728f3871a81de01
Delegated to: Simon Glass
Headers show
Series [U-Boot,v3,1/4] core: Add functions to set properties in live-tree | expand

Commit Message

Mario Six June 26, 2018, 6:46 a.m. UTC
Add tests for the dev_{enable,disable}_by_path functions.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Mario Six <mario.six@gdsys.cc>

---

v2 -> v3:
* Fixed style violations

v1 -> v2:
New in v2

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

--
2.11.0

Comments

Simon Glass Oct. 2, 2018, 11:20 a.m. UTC | #1
On 25 June 2018 at 23:46, Mario Six <mario.six@gdsys.cc> wrote:
> Add tests for the dev_{enable,disable}_by_path functions.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Signed-off-by: Mario Six <mario.six@gdsys.cc>
>
> ---
>
> v2 -> v3:
> * Fixed style violations
>
> v1 -> v2:
> New in v2
>
> ---
>  test/dm/test-fdt.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)

Applied to u-boot-dm, and now in mainline, thanks!
diff mbox series

Patch

diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 1e3faf15227..dae99ed7e5c 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -515,3 +515,31 @@  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@2");
+
+	/* Test enabling devices */
+
+	ut_assert(!of_device_is_available(ofnode_to_np(node)));
+	dev_enable_by_path("/usb@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@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);