diff options
author | Simon Glass <sjg@chromium.org> | 2021-03-26 06:17:27 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-04-06 07:33:19 +0300 |
commit | da393412234a37af68188e7490eba136c832a275 (patch) | |
tree | 637eaafb06d762d0a850504a3f5e0b8042022bcd /tools/dtoc/test_dtoc.py | |
parent | 3e200caff05bccc86392ba531770ebb0879ef93e (diff) | |
download | u-boot-da393412234a37af68188e7490eba136c832a275.tar.xz |
dtoc: Improve handling of reg properties
This existing code assumes that a reg property is larger than one cell,
but this is not always the case. Fix this assumption.
Also if a node's parent is missing the #address-cells and #size-cells
properties we use 2 as a default for each. But this should not happen in
practice. More likely the properties were removed for SPL due to there
being no 'u-boot,dm-pre-reloc' property, or similar. Add a warning for
this as the failure can be very confusing.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_dtoc.py')
-rwxr-xr-x | tools/dtoc/test_dtoc.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index cff522567e..a05e3d9ed6 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -1462,7 +1462,7 @@ U_BOOT_DRVINFO(test3) = { with self.assertRaises(ValueError) as exc: self.run_test(['struct'], dtb_file, output) self.assertIn( - "Node 'spl-test' reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", + "Node 'spl-test' (parent '/') reg property has 3 cells which is not a multiple of na + ns = 1 + 1)", str(exc.exception)) def test_add_prop(self): @@ -1824,3 +1824,18 @@ U_BOOT_DRVINFO(spl_test2) = { self.assertEqual( 'Warning: Cannot find header file for struct dm_test_uc_priv', stdout.getvalue().strip()) + + def test_missing_props(self): + """Test detection of a parent node with no properties""" + dtb_file = get_dtb_file('dtoc_test_noprops.dts', capture_stderr=True) + output = tools.GetOutputFilename('output') + with self.assertRaises(ValueError) as exc: + self.run_test(['struct'], dtb_file, output) + self.assertIn("Parent node '/i2c@0' has no properties - do you need", + str(exc.exception)) + + def test_single_reg(self): + """Test detection of a parent node with no properties""" + dtb_file = get_dtb_file('dtoc_test_single_reg.dts') + output = tools.GetOutputFilename('output') + self.run_test(['struct'], dtb_file, output) |