[Concept,09/15] dtoc: Add a test for the fdt_util.EnsureCompiled with indir

Message ID 20250819193918.874215-10-sjg@u-boot.org
State New
Headers
Series test: Improvements to make check et al |

Commit Message

Simon Glass Aug. 19, 2025, 7:39 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Provide a test which covers this feature of the EnsureCompiled()
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/dtoc/test/dtoc_test_inc.dts | 14 ++++++++++++++
 tools/dtoc/test/test-include.dtsi |  5 +++++
 tools/dtoc/test_fdt.py            | 10 ++++++++++
 3 files changed, 29 insertions(+)
 create mode 100644 tools/dtoc/test/dtoc_test_inc.dts
 create mode 100644 tools/dtoc/test/test-include.dtsi
  

Patch

diff --git a/tools/dtoc/test/dtoc_test_inc.dts b/tools/dtoc/test/dtoc_test_inc.dts
new file mode 100644
index 00000000000..bf87fffb8fc
--- /dev/null
+++ b/tools/dtoc/test/dtoc_test_inc.dts
@@ -0,0 +1,14 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Test device tree file for dtoc
+ *
+ * Copyright 2017 Google, Inc
+ */
+
+/dts-v1/;
+
+/ {
+};
+
+/include/ "test-include.dtsi"
+#include "test-include.dtsi"
diff --git a/tools/dtoc/test/test-include.dtsi b/tools/dtoc/test/test-include.dtsi
new file mode 100644
index 00000000000..45b9da6dd0a
--- /dev/null
+++ b/tools/dtoc/test/test-include.dtsi
@@ -0,0 +1,5 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+};
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index a0bed4e18bb..d66b7eb0f98 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -932,6 +932,16 @@  class TestFdtUtil(unittest.TestCase):
         finally:
             tools.outdir = old_outdir
 
+    def test_ensure_compiled_indir(self):
+        """Test compiling with input directories specified"""
+        tmpdir = tempfile.mkdtemp(prefix='test_fdt.')
+        dest = os.path.join(tmpdir, 'try.dts')
+        shutil.copy(find_dtb_file('dtoc_test_inc.dts'), dest)
+
+        dtb = fdt_util.EnsureCompiled(dest, indir=['tools/dtoc/test'])
+        self.assertEqual(dtb, fdt_util.EnsureCompiled(dtb))
+        shutil.rmtree(tmpdir)
+
     def test_get_phandle_name_offset(self):
         val = fdt_util.GetPhandleNameOffset(self.node, 'missing')
         self.assertIsNone(val)