diff options
author | Simon Glass <sjg@chromium.org> | 2023-07-22 21:43:55 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-08-02 12:05:57 -0600 |
commit | 589c2d9e514412aba4556d06ce3bdfb9c8800fa1 (patch) | |
tree | 22c0d9ddedbb960b7387cde30593ebb70e3c0672 /tools/dtoc/test_fdt.py | |
parent | 8df8b6d670e299764e28f07cc9a607a4309e7c44 (diff) |
fdt: Allow copying phandles into templates
Allow phandles to be copied over from a template. This can potentially
cause duplicate phandles, so detect this and report an error.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_fdt.py')
-rwxr-xr-x | tools/dtoc/test_fdt.py | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index f77e48b54ea..0b01518f3a5 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -340,8 +340,8 @@ class TestNode(unittest.TestCase): over = dtb.GetNode('/dest/base/over') self.assertTrue(over) - # Make sure that the phandle for 'over' is not copied - self.assertNotIn('phandle', over.props.keys()) + # Make sure that the phandle for 'over' is copied + self.assertIn('phandle', over.props.keys()) second = dtb.GetNode('/dest/base/second') self.assertTrue(second) @@ -349,7 +349,7 @@ class TestNode(unittest.TestCase): [n.name for n in chk.subnodes]) self.assertEqual(chk, over.parent) self.assertEqual( - {'bootph-all', 'compatible', 'reg', 'low-power'}, + {'bootph-all', 'compatible', 'reg', 'low-power', 'phandle'}, over.props.keys()) if expect_none: @@ -385,9 +385,22 @@ class TestNode(unittest.TestCase): dtb.Sync(auto_resize=True) - # Now check that the FDT looks correct + # Now check the resulting FDT. It should have duplicate phandles since + # 'over' has been copied to 'dest/base/over' but still exists in its old + # place new_dtb = fdt.Fdt.FromData(dtb.GetContents()) + with self.assertRaises(ValueError) as exc: + new_dtb.Scan() + self.assertIn( + 'Duplicate phandle 1 in nodes /dest/base/over and /base/over', + str(exc.exception)) + + # Remove the source nodes for the copy + new_dtb.GetNode('/base').Delete() + + # Now it should scan OK new_dtb.Scan() + dst = new_dtb.GetNode('/dest') do_copy_checks(new_dtb, dst, second1_ph_val, expect_none=False) |