Skip to content

Commit eb38b95

Browse files
geerturobherring
authored andcommitted
of: overlay: unittest: Add test for unresolved symbol
Add a test to exercise the error paths when trying to apply an overlay with an unresolved symbol and cleaning up the resulting partial state. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/580394587976975770c84411896fce9fbbcf25fa.1690533838.git.geert+renesas@glider.be Signed-off-by: Rob Herring <robh@kernel.org>
1 parent ee32072 commit eb38b95

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

drivers/of/unittest-data/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtbo.o \
3333
overlay_gpio_03.dtbo.o \
3434
overlay_gpio_04a.dtbo.o \
3535
overlay_gpio_04b.dtbo.o \
36-
overlay_pci_node.dtbo.o
36+
overlay_pci_node.dtbo.o \
37+
overlay_bad_unresolved.dtbo.o
3738

3839
# enable creation of __symbols__ node
3940
DTC_FLAGS_overlay += -@
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/dts-v1/;
3+
/plugin/;
4+
5+
&this_label_does_not_exist {
6+
status = "ok";
7+
};

drivers/of/unittest.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3336,6 +3336,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_add_dup_node);
33363336
OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop);
33373337
OVERLAY_INFO_EXTERN(overlay_bad_phandle);
33383338
OVERLAY_INFO_EXTERN(overlay_bad_symbol);
3339+
OVERLAY_INFO_EXTERN(overlay_bad_unresolved);
33393340

33403341
/* entries found by name */
33413342
static struct overlay_info overlays[] = {
@@ -3372,6 +3373,7 @@ static struct overlay_info overlays[] = {
33723373
OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL, -ENODEV),
33733374
OVERLAY_INFO(overlay_bad_phandle, -EINVAL, 0),
33743375
OVERLAY_INFO(overlay_bad_symbol, -EINVAL, -ENODEV),
3376+
OVERLAY_INFO(overlay_bad_unresolved, -EINVAL, 0),
33753377
/* end marker */
33763378
{ }
33773379
};
@@ -3776,6 +3778,21 @@ static __init void of_unittest_overlay_high_level(void)
37763778
EXPECT_END(KERN_ERR,
37773779
"OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/hvac-medium-2:name");
37783780

3781+
/* --- overlay_bad_unresolved --- */
3782+
3783+
EXPECT_BEGIN(KERN_ERR,
3784+
"OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table");
3785+
EXPECT_BEGIN(KERN_ERR,
3786+
"OF: resolver: overlay phandle fixup failed: -22");
3787+
3788+
unittest(overlay_data_apply("overlay_bad_unresolved", NULL),
3789+
"Adding overlay 'overlay_bad_unresolved' failed\n");
3790+
3791+
EXPECT_END(KERN_ERR,
3792+
"OF: resolver: overlay phandle fixup failed: -22");
3793+
EXPECT_END(KERN_ERR,
3794+
"OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table");
3795+
37793796
return;
37803797

37813798
err_unlock:

0 commit comments

Comments
 (0)