[PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()

Zijun Hu posted 7 patches 1 year ago
There is a newer version of this series
[PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
Posted by Zijun Hu 1 year ago
From: Zijun Hu <quic_zijuhu@quicinc.com>

To test of_find_node_opts_by_path() take @path argument with pattern:

"alias-name/node-name-1/.../node-name-N:options", for example:
"testcase-alias/phandle-tests/consumer-a:testaliasoption"

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/of/unittest.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index daf9a2dddd7e0dbc680f708496b6dce6d23999cf..ed343509505f536436f8457bd200ccc323acffdf 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -161,6 +161,15 @@ static void __init of_unittest_find_node_by_name(void)
 		 "option alias path test, subcase #1 failed\n");
 	of_node_put(np);
 
+	np = of_find_node_opts_by_path("testcase-alias/phandle-tests/consumer-a:testaliasoption",
+				       &options);
+	name = kasprintf(GFP_KERNEL, "%pOF", np);
+	unittest(np && name && !strcmp("/testcase-data/phandle-tests/consumer-a", name) &&
+		 !strcmp("testaliasoption", options),
+		 "option alias path test, subcase #2 failed\n");
+	of_node_put(np);
+	kfree(name);
+
 	np = of_find_node_opts_by_path("testcase-alias:testaliasoption", NULL);
 	unittest(np, "NULL option alias path test failed\n");
 	of_node_put(np);

-- 
2.34.1
Re: [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
Posted by Rob Herring 1 year ago
On Sun, Dec 15, 2024 at 6:41 PM Zijun Hu <zijun_hu@icloud.com> wrote:
>
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> To test of_find_node_opts_by_path() take @path argument with pattern:
>
> "alias-name/node-name-1/.../node-name-N:options", for example:
> "testcase-alias/phandle-tests/consumer-a:testaliasoption"

The test passes with or without patch 1 applied.

Rob
Re: [PATCH v2 2/7] of: unittest: Add a test case for API of_find_node_opts_by_path()
Posted by Rob Herring 1 year ago
On Mon, Dec 16, 2024 at 1:23 PM Rob Herring <robh@kernel.org> wrote:
>
> On Sun, Dec 15, 2024 at 6:41 PM Zijun Hu <zijun_hu@icloud.com> wrote:
> >
> > From: Zijun Hu <quic_zijuhu@quicinc.com>
> >
> > To test of_find_node_opts_by_path() take @path argument with pattern:
> >
> > "alias-name/node-name-1/.../node-name-N:options", for example:
> > "testcase-alias/phandle-tests/consumer-a:testaliasoption"
>
> The test passes with or without patch 1 applied.

Sorry, an error running the test on my part. This and patch 1 applied.

Thanks,
Rob