diff mbox series

[v2,6/8] test: dm: Add test for ofnode options phandle helper

Message ID 20241110115054.2555-7-ansuelsmth@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show
Series led: update LED boot/activity to new property implementation | expand

Commit Message

Christian Marangi Nov. 10, 2024, 11:50 a.m. UTC
Add test for ofnode options phandle helper and add new property in the
sandbox test dts.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 arch/sandbox/dts/test.dts |  1 +
 test/dm/ofnode.c          | 11 +++++++++++
 2 files changed, 12 insertions(+)

Comments

Simon Glass Nov. 20, 2024, 1:48 p.m. UTC | #1
On Sun, 10 Nov 2024 at 04:51, Christian Marangi <ansuelsmth@gmail.com> wrote:
>
> Add test for ofnode options phandle helper and add new property in the
> sandbox test dts.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> ---
>  arch/sandbox/dts/test.dts |  1 +
>  test/dm/ofnode.c          | 11 +++++++++++
>  2 files changed, 12 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index b8a46463158..1ffa64a43e2 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -106,6 +106,7 @@ 
 			testing-bool;
 			testing-int = <123>;
 			testing-str = "testing";
+			testing-phandle = <&phandle_node_1>;
 		};
 	};
 
diff --git a/test/dm/ofnode.c b/test/dm/ofnode.c
index cf10e698d9e..f16b643fa3f 100644
--- a/test/dm/ofnode.c
+++ b/test/dm/ofnode.c
@@ -704,6 +704,10 @@  static int dm_test_ofnode_options(struct unit_test_state *uts)
 {
 	u64 bootscr_address, bootscr_offset;
 	u64 bootscr_flash_offset, bootscr_flash_size;
+	ofnode node, phandle_node, target;
+
+	node = ofnode_path("/options/u-boot");
+	ut_assert(ofnode_valid(node));
 
 	ut_assert(!ofnode_options_read_bool("missing"));
 	ut_assert(ofnode_options_read_bool("testing-bool"));
@@ -714,6 +718,13 @@  static int dm_test_ofnode_options(struct unit_test_state *uts)
 	ut_assertnull(ofnode_options_read_str("missing"));
 	ut_asserteq_str("testing", ofnode_options_read_str("testing-str"));
 
+	ut_asserteq(-EINVAL, ofnode_options_get_by_phandle("missing", &phandle_node));
+
+	target = ofnode_path("/phandle-node-1");
+	ut_assert(ofnode_valid(target));
+	ut_assertok(ofnode_options_get_by_phandle("testing-phandle", &phandle_node));
+	ut_assert(ofnode_equal(target, phandle_node));
+
 	ut_assertok(ofnode_read_bootscript_address(&bootscr_address,
 						   &bootscr_offset));
 	ut_asserteq_64(0, bootscr_address);