summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-22 21:43:53 -0600
committerSimon Glass <sjg@chromium.org>2023-08-02 12:05:57 -0600
commit7155646b22a9ef41100cdee18f39cf353810788a (patch)
tree56b4e53645d6a9c225d47e64ff2fc830ca4c4946 /tools/dtoc/test_fdt.py
parentb2f47a599cad3b618c6d7b4356ea6ea2625309c0 (diff)
dtoc: Make properties dirty when purging them
Without the 'dirty' flag properties are not written back to the devicetree when synced. This means that new properties copied over to a node are not always written out. Fix this and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_fdt.py')
-rwxr-xr-xtools/dtoc/test_fdt.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 3e54694eec9..84dcd8b5caa 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -308,7 +308,7 @@ class TestNode(unittest.TestCase):
def test_copy_node(self):
"""Test copy_node() function"""
- def do_copy_checks(dtb, dst, expect_none):
+ def do_copy_checks(dtb, dst, second1_ph_val, expect_none):
self.assertEqual(
['/dest/base', '/dest/first@0', '/dest/existing'],
[n.path for n in dst.subnodes])
@@ -365,12 +365,22 @@ class TestNode(unittest.TestCase):
['second1', 'second2', 'second3', 'second4'],
[n.name for n in second.subnodes])
+ # Check the 'second_1_bad' phandle is not copied over
+ second1 = second.FindNode('second1')
+ self.assertTrue(second1)
+ sph = second1.props.get('phandle')
+ self.assertTrue(sph)
+ self.assertEqual(second1_ph_val, sph.bytes)
+
+
dtb = fdt.FdtScan(find_dtb_file('dtoc_test_copy.dts'))
tmpl = dtb.GetNode('/base')
dst = dtb.GetNode('/dest')
+ second1_ph_val = (dtb.GetNode('/dest/base/second/second1').
+ props['phandle'].bytes)
dst.copy_node(tmpl)
- do_copy_checks(dtb, dst, expect_none=True)
+ do_copy_checks(dtb, dst, second1_ph_val, expect_none=True)
dtb.Sync(auto_resize=True)
@@ -378,7 +388,7 @@ class TestNode(unittest.TestCase):
new_dtb = fdt.Fdt.FromData(dtb.GetContents())
new_dtb.Scan()
dst = new_dtb.GetNode('/dest')
- do_copy_checks(new_dtb, dst, expect_none=False)
+ do_copy_checks(new_dtb, dst, second1_ph_val, expect_none=False)
def test_copy_subnodes_from_phandles(self):
"""Test copy_node() function"""