Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b9cf790 authored by Stefan M Schaeckeler's avatar Stefan M Schaeckeler Committed by Rob Herring
Browse files

of: unittest: for strings, account for trailing \0 in property length field



For strings, account for trailing \0 in property length field:

This is consistent with how dtc builds string properties.

Function __of_prop_dup() would misbehave on such properties as it duplicates
properties based on the property length field creating new string values
without trailing \0s.

Signed-off-by: default avatarStefan M Schaeckeler <sschaeck@cisco.com>
Reviewed-by: default avatarFrank Rowand <frank.rowand@sony.com>
Tested-by: default avatarFrank Rowand <frank.rowand@sony.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
parent 3098e5b7
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -165,20 +165,20 @@ static void __init of_unittest_dynamic(void)
	/* Add a new property - should pass*/
	/* Add a new property - should pass*/
	prop->name = "new-property";
	prop->name = "new-property";
	prop->value = "new-property-data";
	prop->value = "new-property-data";
	prop->length = strlen(prop->value);
	prop->length = strlen(prop->value) + 1;
	unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");
	unittest(of_add_property(np, prop) == 0, "Adding a new property failed\n");


	/* Try to add an existing property - should fail */
	/* Try to add an existing property - should fail */
	prop++;
	prop++;
	prop->name = "new-property";
	prop->name = "new-property";
	prop->value = "new-property-data-should-fail";
	prop->value = "new-property-data-should-fail";
	prop->length = strlen(prop->value);
	prop->length = strlen(prop->value) + 1;
	unittest(of_add_property(np, prop) != 0,
	unittest(of_add_property(np, prop) != 0,
		 "Adding an existing property should have failed\n");
		 "Adding an existing property should have failed\n");


	/* Try to modify an existing property - should pass */
	/* Try to modify an existing property - should pass */
	prop->value = "modify-property-data-should-pass";
	prop->value = "modify-property-data-should-pass";
	prop->length = strlen(prop->value);
	prop->length = strlen(prop->value) + 1;
	unittest(of_update_property(np, prop) == 0,
	unittest(of_update_property(np, prop) == 0,
		 "Updating an existing property should have passed\n");
		 "Updating an existing property should have passed\n");


@@ -186,7 +186,7 @@ static void __init of_unittest_dynamic(void)
	prop++;
	prop++;
	prop->name = "modify-property";
	prop->name = "modify-property";
	prop->value = "modify-missing-property-data-should-pass";
	prop->value = "modify-missing-property-data-should-pass";
	prop->length = strlen(prop->value);
	prop->length = strlen(prop->value) + 1;
	unittest(of_update_property(np, prop) == 0,
	unittest(of_update_property(np, prop) == 0,
		 "Updating a missing property should have passed\n");
		 "Updating a missing property should have passed\n");