Messages in this thread Patch in this message | | | From | Clément Léger <> | Subject | [PATCH v3 5/9] device property: add tests for fwnode_property_read_string_index() | Date | Fri, 25 Mar 2022 12:31:44 +0100 |
| |
Add somes tests to validate fwnode_property_read_string_index().
Signed-off-by: Clément Léger <clement.leger@bootlin.com> --- drivers/base/test/property-entry-test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/drivers/base/test/property-entry-test.c b/drivers/base/test/property-entry-test.c index 6071d5bc128c..9edbaa53a950 100644 --- a/drivers/base/test/property-entry-test.c +++ b/drivers/base/test/property-entry-test.c @@ -318,6 +318,24 @@ static void pe_test_strings(struct kunit *test) KUNIT_EXPECT_EQ(test, error, 0); KUNIT_EXPECT_STREQ(test, str, "string-a"); + error = fwnode_property_read_string_index(node, "str", 0, strs); + KUNIT_EXPECT_EQ(test, error, 0); + KUNIT_EXPECT_STREQ(test, strs[0], "single"); + + error = fwnode_property_read_string_index(node, "strs", 0, strs); + KUNIT_EXPECT_EQ(test, error, 0); + KUNIT_EXPECT_STREQ(test, strs[0], "string-a"); + + error = fwnode_property_read_string_index(node, "strs", 1, strs); + KUNIT_EXPECT_EQ(test, error, 0); + KUNIT_EXPECT_STREQ(test, strs[0], "string-b"); + + error = fwnode_property_read_string_index(node, "str", 1, strs); + KUNIT_EXPECT_EQ(test, error, -ENODATA); + + error = fwnode_property_read_string_index(node, "strs", 3, strs); + KUNIT_EXPECT_EQ(test, error, -ENODATA); + fwnode_remove_software_node(node); } -- 2.34.1
| |