of: overlay: unittest: Add test for unresolved symbol
authorGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 28 Jul 2023 08:50:35 +0000 (10:50 +0200)
committerRob Herring <robh@kernel.org>
Thu, 24 Aug 2023 01:04:17 +0000 (20:04 -0500)
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>
drivers/of/unittest-data/Makefile
drivers/of/unittest-data/overlay_bad_unresolved.dtso [new file with mode: 0644]
drivers/of/unittest.c

index 1aa87508815980aed419730eb310b8155f0c5134..01a966e39f23fd0f32fd49988b2f1ad6c1175952 100644 (file)
@@ -33,7 +33,8 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtbo.o \
                            overlay_gpio_03.dtbo.o \
                            overlay_gpio_04a.dtbo.o \
                            overlay_gpio_04b.dtbo.o \
-                           overlay_pci_node.dtbo.o
+                           overlay_pci_node.dtbo.o \
+                           overlay_bad_unresolved.dtbo.o
 
 # enable creation of __symbols__ node
 DTC_FLAGS_overlay += -@
diff --git a/drivers/of/unittest-data/overlay_bad_unresolved.dtso b/drivers/of/unittest-data/overlay_bad_unresolved.dtso
new file mode 100644 (file)
index 0000000..3b75a53
--- /dev/null
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+&this_label_does_not_exist {
+       status = "ok";
+};
index 18ccfdc3dd89a39d1fe8560da6c909786255f54c..9c0f352cb241885b6857fd2140ad5ca2f907ff41 100644 (file)
@@ -3336,6 +3336,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_add_dup_node);
 OVERLAY_INFO_EXTERN(overlay_bad_add_dup_prop);
 OVERLAY_INFO_EXTERN(overlay_bad_phandle);
 OVERLAY_INFO_EXTERN(overlay_bad_symbol);
+OVERLAY_INFO_EXTERN(overlay_bad_unresolved);
 
 /* entries found by name */
 static struct overlay_info overlays[] = {
@@ -3372,6 +3373,7 @@ static struct overlay_info overlays[] = {
        OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL, -ENODEV),
        OVERLAY_INFO(overlay_bad_phandle, -EINVAL, 0),
        OVERLAY_INFO(overlay_bad_symbol, -EINVAL, -ENODEV),
+       OVERLAY_INFO(overlay_bad_unresolved, -EINVAL, 0),
        /* end marker */
        { }
 };
@@ -3776,6 +3778,21 @@ static __init void of_unittest_overlay_high_level(void)
        EXPECT_END(KERN_ERR,
                   "OF: changeset: apply failed: REMOVE_PROPERTY /testcase-data-2/substation@100/hvac-medium-2:name");
 
+       /* ---  overlay_bad_unresolved  --- */
+
+       EXPECT_BEGIN(KERN_ERR,
+                    "OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table");
+       EXPECT_BEGIN(KERN_ERR,
+                    "OF: resolver: overlay phandle fixup failed: -22");
+
+       unittest(overlay_data_apply("overlay_bad_unresolved", NULL),
+                "Adding overlay 'overlay_bad_unresolved' failed\n");
+
+       EXPECT_END(KERN_ERR,
+                  "OF: resolver: overlay phandle fixup failed: -22");
+       EXPECT_END(KERN_ERR,
+                  "OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table");
+
        return;
 
 err_unlock: