diff options
Diffstat (limited to 'drivers/of/unittest.c')
-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) | |||
683 | static void __init of_unittest_changeset(void) | 683 | static void __init of_unittest_changeset(void) |
684 | { | 684 | { |
685 | #ifdef CONFIG_OF_DYNAMIC | 685 | #ifdef CONFIG_OF_DYNAMIC |
686 | struct property *ppadd, padd = { .name = "prop-add", .length = 0, .value = "" }; | 686 | struct property *ppadd, padd = { .name = "prop-add", .length = 1, .value = "" }; |
687 | struct property *ppname_n1, pname_n1 = { .name = "name", .length = 3, .value = "n1" }; | ||
688 | struct property *ppname_n2, pname_n2 = { .name = "name", .length = 3, .value = "n2" }; | ||
689 | struct property *ppname_n21, pname_n21 = { .name = "name", .length = 3, .value = "n21" }; | ||
687 | struct property *ppupdate, pupdate = { .name = "prop-update", .length = 5, .value = "abcd" }; | 690 | struct property *ppupdate, pupdate = { .name = "prop-update", .length = 5, .value = "abcd" }; |
688 | struct property *ppremove; | 691 | struct property *ppremove; |
689 | struct device_node *n1, *n2, *n21, *nremove, *parent, *np; | 692 | struct device_node *n1, *n2, *n21, *nchangeset, *nremove, *parent, *np; |
690 | struct of_changeset chgset; | 693 | struct of_changeset chgset; |
691 | 694 | ||
692 | n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); | 695 | n1 = __of_node_dup(NULL, "/testcase-data/changeset/n1"); |
693 | unittest(n1, "testcase setup failure\n"); | 696 | unittest(n1, "testcase setup failure\n"); |
697 | |||
694 | n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); | 698 | n2 = __of_node_dup(NULL, "/testcase-data/changeset/n2"); |
695 | unittest(n2, "testcase setup failure\n"); | 699 | unittest(n2, "testcase setup failure\n"); |
700 | |||
696 | n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21"); | 701 | n21 = __of_node_dup(NULL, "%s/%s", "/testcase-data/changeset/n2", "n21"); |
697 | unittest(n21, "testcase setup failure %p\n", n21); | 702 | unittest(n21, "testcase setup failure %p\n", n21); |
698 | nremove = of_find_node_by_path("/testcase-data/changeset/node-remove"); | 703 | |
704 | nchangeset = of_find_node_by_path("/testcase-data/changeset"); | ||
705 | nremove = of_get_child_by_name(nchangeset, "node-remove"); | ||
699 | unittest(nremove, "testcase setup failure\n"); | 706 | unittest(nremove, "testcase setup failure\n"); |
707 | |||
700 | ppadd = __of_prop_dup(&padd, GFP_KERNEL); | 708 | ppadd = __of_prop_dup(&padd, GFP_KERNEL); |
701 | unittest(ppadd, "testcase setup failure\n"); | 709 | unittest(ppadd, "testcase setup failure\n"); |
710 | |||
711 | ppname_n1 = __of_prop_dup(&pname_n1, GFP_KERNEL); | ||
712 | unittest(ppname_n1, "testcase setup failure\n"); | ||
713 | |||
714 | ppname_n2 = __of_prop_dup(&pname_n2, GFP_KERNEL); | ||
715 | unittest(ppname_n2, "testcase setup failure\n"); | ||
716 | |||
717 | ppname_n21 = __of_prop_dup(&pname_n21, GFP_KERNEL); | ||
718 | unittest(ppname_n21, "testcase setup failure\n"); | ||
719 | |||
702 | ppupdate = __of_prop_dup(&pupdate, GFP_KERNEL); | 720 | ppupdate = __of_prop_dup(&pupdate, GFP_KERNEL); |
703 | unittest(ppupdate, "testcase setup failure\n"); | 721 | unittest(ppupdate, "testcase setup failure\n"); |
704 | parent = nremove->parent; | 722 | |
723 | parent = nchangeset; | ||
705 | n1->parent = parent; | 724 | n1->parent = parent; |
706 | n2->parent = parent; | 725 | n2->parent = parent; |
707 | n21->parent = n2; | 726 | n21->parent = n2; |
708 | n2->child = n21; | 727 | |
709 | ppremove = of_find_property(parent, "prop-remove", NULL); | 728 | ppremove = of_find_property(parent, "prop-remove", NULL); |
710 | unittest(ppremove, "failed to find removal prop"); | 729 | unittest(ppremove, "failed to find removal prop"); |
711 | 730 | ||
712 | of_changeset_init(&chgset); | 731 | of_changeset_init(&chgset); |
732 | |||
713 | unittest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n"); | 733 | unittest(!of_changeset_attach_node(&chgset, n1), "fail attach n1\n"); |
734 | unittest(!of_changeset_add_property(&chgset, n1, ppname_n1), "fail add prop name\n"); | ||
735 | |||
714 | unittest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n"); | 736 | unittest(!of_changeset_attach_node(&chgset, n2), "fail attach n2\n"); |
737 | unittest(!of_changeset_add_property(&chgset, n2, ppname_n2), "fail add prop name\n"); | ||
738 | |||
715 | unittest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n"); | 739 | unittest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n"); |
740 | unittest(!of_changeset_add_property(&chgset, n21, ppname_n21), "fail add prop name\n"); | ||
741 | |||
716 | unittest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n"); | 742 | unittest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n"); |
717 | unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop\n"); | 743 | |
744 | unittest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop prop-add\n"); | ||
718 | unittest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n"); | 745 | unittest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n"); |
719 | unittest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n"); | 746 | unittest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n"); |
747 | |||
720 | unittest(!of_changeset_apply(&chgset), "apply failed\n"); | 748 | unittest(!of_changeset_apply(&chgset), "apply failed\n"); |
721 | 749 | ||
750 | of_node_put(nchangeset); | ||
751 | |||
722 | /* Make sure node names are constructed correctly */ | 752 | /* Make sure node names are constructed correctly */ |
723 | unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), | 753 | unittest((np = of_find_node_by_path("/testcase-data/changeset/n2/n21")), |
724 | "'%pOF' not added\n", n21); | 754 | "'%pOF' not added\n", n21); |