diff options
author | Frank Rowand | 2018-02-26 14:01:22 -0800 |
---|---|---|
committer | Rob Herring | 2018-03-05 15:37:19 -0600 |
commit | a4f91f0de905dd6f91ab12dd8bfda10317fa43eb (patch) | |
tree | 3f55f61d58b893226665de80a29a7e865c014c6d /drivers/of | |
parent | b46c78661c42cb8b07eb213104c79cbab8ea7e0d (diff) |
of: unittest: clean up changeset test
In preparation for fixing __of_node_dup(), clean up the unittest
function that calls it.
Devicetree nodes created from a flattened device tree have a name
property. Follow this convention for nodes added by a changeset.
For node added by changeset, remove incorrect initialization of
child node pointer.
Add an additional node pointer 'changeset' to more naturally reflect
where in the tree the changeset is added.
Make changeset add property error messages unique.
Add whitespace to break apart logic blocks.
Signed-off-by: Frank Rowand <frank.rowand@sony.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/unittest.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 1a984586ef5c..a17195fcaeda 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -683,42 +683,72 @@ static void __init of_unittest_property_copy(void) static void __init of_unittest_changeset(void) { #ifdef CONFIG_OF_DYNAMIC - struct property *ppadd, padd = { .name = "prop-add", .length = 0, .value = "" }; + 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" }; + struct property *ppname_n21, pname_n21 = { .name = "name", .length = 3, .value = "n21" }; struct property *ppupdate, pupdate = { .name = "prop-update", .length = 5, .value = "abcd" }; struct property *ppremove; - struct device_node *n1, *n2, *n21, *nremove, *parent, *np; + struct device_node *n1, *n2, *n21, *nchangeset, *nremove, *parent, *np; struct of_changeset chgset; n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); unittest(n1, "testcase setup failure\n"); + n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); unittest(n2, "testcase setup failure\n"); + n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21"); unittest(n21, "testcase setup failure %p\n", n21); - nremove = of_find_node_by_path("/testcase-data/changeset/node-remove"); + + nchangeset = of_find_node_by_path("/testcase-data/changeset"); + nremove = of_get_child_by_name(nchangeset, "node-remove"); unittest(nremove, "testcase setup failure\n"); + ppadd = __of_prop_dup(&padd, GFP_KERNEL); unittest(ppadd, "testcase setup failure\n"); + + ppname_n1 = __of_prop_dup(&pname_n1, GFP_KERNEL); + unittest(ppname_n1, "testcase setup failure\n"); + + ppname_n2 = __of_prop_dup(&pname_n2, GFP_KERNEL); + unittest(ppname_n2, "testcase setup failure\n"); + + ppname_n21 = __of_prop_dup(&pname_n21, GFP_KERNEL); + unittest(ppname_n21, "testcase setup failure\n"); + ppupdate = __of_prop_dup(&pupdate, GFP_KERNEL); unittest(ppupdate, "testcase setup failure\n"); - parent = nremove->parent; + + parent = nchangeset; n1->parent = parent; n2->parent = parent; n21->parent = n2; - n2->child = n21; + ppremove = of_find_property(parent, "prop-remove", NULL); unittest(ppremove, "failed to find removal prop"); of_changeset_init(&chgset); + unittest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n"); + unittest(!of_changeset_add_property(&chgset, n1, ppname_n1), "fail add prop name\n"); + unittest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n"); + unittest(!of_changeset_add_property(&chgset, n2, ppname_n2), "fail add prop name\n"); + unittest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n"); + unittest(!of_changeset_add_property(&chgset, n21, ppname_n21), "fail add prop name\n"); + unittest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n"); - unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop\n"); + + unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop prop-add\n"); unittest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n"); unittest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n"); + unittest(!of_changeset_apply(&chgset), "apply failed\n"); + of_node_put(nchangeset); + /* Make sure node names are constructed correctly */ unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), "'%pOF' not added\n", n21); |