summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2023-08-01 11:46:29 -0600
committerRob Herring <robh@kernel.org>2023-08-23 20:04:17 -0500
commit500d45100aa8546a000eef85bba8c2abc7b36e92 (patch)
treed544810504dc2b25ea8a5547c69c90165251b074 /drivers/of
parentb37c60d23df71ae6c09856cab4b853aea11f0615 (diff)
of: unittest: Check tree matches original after reverting a changeset
Enhance the changeset unittest to ensure after a revert, the tree matches the original tree before the changeset was applied. Specifically, check an added node is removed, a removed property is added back, and an updated property has its original value. Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/unittest.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 33c20edcc92c..064a41007a50 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -797,6 +797,7 @@ static void __init of_unittest_property_copy(void)
static void __init of_unittest_changeset(void)
{
#ifdef CONFIG_OF_DYNAMIC
+ int ret;
struct property *ppadd, padd = { .name = "prop-add", .length = 1, .value = "" };
struct property *ppname_n1, pname_n1 = { .name = "name", .length = 3, .value = "n1" };
struct property *ppname_n2, pname_n2 = { .name = "name", .length = 3, .value = "n2" };
@@ -807,6 +808,7 @@ static void __init of_unittest_changeset(void)
static const char * const str_array[] = { "str1", "str2", "str3" };
const u32 u32_array[] = { 1, 2, 3 };
struct of_changeset chgset;
+ const char *propstr = NULL;
n1 = __of_node_dup(NULL, "n1");
unittest(n1, "testcase setup failure\n");
@@ -886,6 +888,17 @@ static void __init of_unittest_changeset(void)
unittest(!of_changeset_revert(&chgset), "revert failed\n");
+ unittest(!of_find_node_by_path("/testcase-data/changeset/n2/n21"),
+ "'%pOF' still present after revert\n", n21);
+
+ ppremove = of_find_property(parent, "prop-remove", NULL);
+ unittest(ppremove, "failed to find removed prop after revert\n");
+
+ ret = of_property_read_string(parent, "prop-update", &propstr);
+ unittest(!ret, "failed to find updated prop after revert\n");
+ if (!ret)
+ unittest(strcmp(propstr, "hello") == 0, "original value not in updated property after revert");
+
of_changeset_destroy(&chgset);
of_node_put(n1);