* [PATCH] libfdt: tests: Add a test to check phandles are not overwritten
@ 2023-04-19 6:51 Uwe Kleine-König
0 siblings, 0 replies; only message in thread
From: Uwe Kleine-König @ 2023-04-19 6:51 UTC (permalink / raw)
To: David Gibson, Jon Loeliger
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Yves-Alexis Perez,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ
Application of an overlay should not overwrite already existing phandles
as this probably breaks references in the base device tree.
Note this is currently failing.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
Hello,
I found an old conversation[1] about this bug during the spring cleanup of
my mailbox. I tried fixing the problem, but didn't manage in the short
time I planned to spend on this. So here comes only a test that
currently fails. I don't know yet if/when I will look again into this
problem, but if someone else fixes it, I won't be angry. :-)
Best regards
Uwe
[1] https://www.spinics.net/lists/devicetree-compiler/msg03932.html
tests/overlay_base_phandle.dts | 17 +++++++++++++++++
tests/overlay_overlay_phandle.dts | 23 +++++++++++++++++++++++
tests/run_tests.sh | 14 ++++++++++++++
3 files changed, 54 insertions(+)
create mode 100644 tests/overlay_base_phandle.dts
create mode 100644 tests/overlay_overlay_phandle.dts
diff --git a/tests/overlay_base_phandle.dts b/tests/overlay_base_phandle.dts
new file mode 100644
index 000000000000..623b9269d7dd
--- /dev/null
+++ b/tests/overlay_base_phandle.dts
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2023 Uwe Kleine-König
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/dts-v1/;
+
+/ {
+ node_a: a {
+ prop = "blub";
+ };
+
+ node_b: b {
+ a = <&node_a>;
+ };
+};
diff --git a/tests/overlay_overlay_phandle.dts b/tests/overlay_overlay_phandle.dts
new file mode 100644
index 000000000000..b6ee1e35085e
--- /dev/null
+++ b/tests/overlay_overlay_phandle.dts
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2023 Uwe Kleine-König
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/dts-v1/;
+/plugin/;
+
+/ {
+ fragment@0 {
+ target-path = "/";
+
+ __overlay__ {
+ node_a2: a {
+ };
+
+ c {
+ a = <&node_a2>;
+ };
+ };
+ };
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index f899d8cbfe69..ada4af428058 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -1028,6 +1028,20 @@ fdtoverlay_tests() {
run_dtc_test -@ -I dts -O dtb -o $stacked_addlabeldtb $stacked_addlabel
run_fdtoverlay_test baz "/foonode/barnode/baznode" "baz-property" "-ts" ${stacked_base_nolabeldtb} ${stacked_addlabel_targetdtb} ${stacked_addlabeldtb} ${stacked_bardtb} ${stacked_bazdtb}
+
+ # verify that labels are not overwritten
+ run_dtc_test -@ -I dts -O dtb -o overlay_base_phandle.test.dtb "$SRCDIR/overlay_base_phandle.dts"
+ run_dtc_test -@ -I dts -O dtb -o overlay_overlay_phandle.test.dtb "$SRCDIR/overlay_overlay_phandle.dts"
+ run_wrap_test $FDTOVERLAY -i overlay_base_phandle.test.dtb -o overlay_base_phandleO.test.dtb overlay_overlay_phandle.test.dtb
+
+ ba=$($DTGET overlay_base_phandleO.test.dtb /b a)
+ ca=$($DTGET overlay_base_phandleO.test.dtb /c a)
+ shorten_echo "check phandle wasn't overwritten: "
+ if test "$ba" = "$ca"; then
+ PASS
+ else
+ FAIL
+ fi
}
pylibfdt_tests () {
base-commit: 2cdf93a6d402a161edf16de6011bd5ad76382e92
--
2.39.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-19 6:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-19 6:51 [PATCH] libfdt: tests: Add a test to check phandles are not overwritten Uwe Kleine-König
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).