[PATCH v3 5/9] device property: add tests for fwnode_property_read_string_index()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add somes tests to validate fwnode_property_read_string_index().

Signed-off-by: Clément Léger <clement.leger@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux