]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: dm: Add test for ofnode options phandle helper
authorChristian Marangi <ansuelsmth@gmail.com>
Sun, 10 Nov 2024 11:50:25 +0000 (12:50 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 6 Dec 2024 19:00:41 +0000 (13:00 -0600)
Add test for ofnode options phandle helper and add new property in the
sandbox test dts.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
test/dm/ofnode.c

index b8a464631584e6bc3306da5885bb19ffdb318d22..1ffa64a43e2bf193c1265097d4ff1c6f4f98c5a8 100644 (file)
                        testing-bool;
                        testing-int = <123>;
                        testing-str = "testing";
+                       testing-phandle = <&phandle_node_1>;
                };
        };
 
index cf10e698d9e7f55c6141762c5ba2a5e3488efb88..f16b643fa3f68de4a1b22c047f4a409ae2dc4eb7 100644 (file)
@@ -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);