This adds a unittest to test applying/reverting an overlay that contains
a link between two devices.

Signed-off-by: Michael Auchter <michael.auch...@ni.com>
---
 drivers/of/unittest-data/Makefile       |  1 +
 drivers/of/unittest-data/overlay_16.dts | 26 +++++++++++++++++++++++++
 drivers/of/unittest.c                   | 16 +++++++++++++++
 3 files changed, 43 insertions(+)
 create mode 100644 drivers/of/unittest-data/overlay_16.dts

diff --git a/drivers/of/unittest-data/Makefile 
b/drivers/of/unittest-data/Makefile
index 009f4045c8e4..91a1ebbc451b 100644
--- a/drivers/of/unittest-data/Makefile
+++ b/drivers/of/unittest-data/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_OF_OVERLAY) += overlay.dtb.o \
                            overlay_12.dtb.o \
                            overlay_13.dtb.o \
                            overlay_15.dtb.o \
+                           overlay_16.dtb.o \
                            overlay_bad_add_dup_node.dtb.o \
                            overlay_bad_add_dup_prop.dtb.o \
                            overlay_bad_phandle.dtb.o \
diff --git a/drivers/of/unittest-data/overlay_16.dts 
b/drivers/of/unittest-data/overlay_16.dts
new file mode 100644
index 000000000000..eda206e2ebca
--- /dev/null
+++ b/drivers/of/unittest-data/overlay_16.dts
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+/plugin/;
+
+/* overlay_16 - device links */
+
+&unittest_test_bus {
+
+       /* suppress DTC warning */
+       #address-cells = <1>;
+       #size-cells = <0>;
+
+       unittest16: test-unittest16 {
+               #clock-cells = <0>;
+               compatible = "unittest";
+               status = "okay";
+               reg = <16>;
+       };
+
+       test-unittest161 {
+               compatible = "unittest";
+               status = "okay";
+               reg = <161>;
+               clocks = <&unittest16>;
+       };
+};
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 5579584758b7..d94dafb3746f 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -2369,6 +2369,18 @@ static void __init of_unittest_overlay_11(void)
        unittest(ret == 0, "overlay test %d failed; overlay apply\n", 11);
 }
 
+/* test insertion of an overlay that references another node */
+static void __init of_unittest_overlay_16(void)
+{
+       int ret;
+
+       /* device should disable */
+       ret = of_unittest_apply_revert_overlay_check(16, 16, 0, 1,
+                       PDEV_OVERLAY);
+
+       unittest(ret == 0, "overlay test %d failed; overlay apply\n", 16);
+}
+
 #if IS_BUILTIN(CONFIG_I2C) && IS_ENABLED(CONFIG_OF_OVERLAY)
 
 struct unittest_i2c_bus_data {
@@ -2757,6 +2769,8 @@ static void __init of_unittest_overlay(void)
        of_unittest_overlay_i2c_cleanup();
 #endif
 
+       of_unittest_overlay_16();
+
        of_unittest_overlay_gpio();
 
        of_unittest_destroy_tracked_overlays();
@@ -2812,6 +2826,7 @@ OVERLAY_INFO_EXTERN(overlay_11);
 OVERLAY_INFO_EXTERN(overlay_12);
 OVERLAY_INFO_EXTERN(overlay_13);
 OVERLAY_INFO_EXTERN(overlay_15);
+OVERLAY_INFO_EXTERN(overlay_16);
 OVERLAY_INFO_EXTERN(overlay_gpio_01);
 OVERLAY_INFO_EXTERN(overlay_gpio_02a);
 OVERLAY_INFO_EXTERN(overlay_gpio_02b);
@@ -2842,6 +2857,7 @@ static struct overlay_info overlays[] = {
        OVERLAY_INFO(overlay_12, 0),
        OVERLAY_INFO(overlay_13, 0),
        OVERLAY_INFO(overlay_15, 0),
+       OVERLAY_INFO(overlay_16, 0),
        OVERLAY_INFO(overlay_gpio_01, 0),
        OVERLAY_INFO(overlay_gpio_02a, 0),
        OVERLAY_INFO(overlay_gpio_02b, 0),
-- 
2.25.4

Reply via email to