dtoc: Add a test for the fdt_util.EnsureCompiled with indir

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

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-08-17 17:37:04 -06:00
parent da2183fd74
commit 85d560becc
3 changed files with 29 additions and 0 deletions

View File

@@ -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"

View File

@@ -0,0 +1,5 @@
// SPDX-License-Identifier: GPL-2.0+
/ {
#address-cells = <1>;
#size-cells = <1>;
};

View File

@@ -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)