summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-29 04:23:10 +0300
committerSimon Glass <sjg@chromium.org>2021-08-01 18:05:24 +0300
commitca04494d76bf1152cd9ab1f67af5101c86e0824f (patch)
treefe4d76d9f16f939914bca1af05da83b05d055cdd /tools/dtoc/test_fdt.py
parentdf82de805172687e88dd7d72b68a9223b0a4c269 (diff)
downloadu-boot-ca04494d76bf1152cd9ab1f67af5101c86e0824f.tar.xz
dtoc: Fix widening an int array to an int
An int array can hold a single int so we should not need to do anything in the widening operation. However due to a quirk in the code, an int[3] widened with an int produced an int[4]. Fix this and add a test. Fix a comment typo while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'tools/dtoc/test_fdt.py')
-rwxr-xr-xtools/dtoc/test_fdt.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 856392b1bd..857861c14e 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -379,7 +379,7 @@ class TestProp(unittest.TestCase):
self.assertEqual(Type.INT, prop.type)
self.assertEqual(1, fdt32_to_cpu(prop.value))
- # Convert singla value to array
+ # Convert single value to array
prop2 = self.node.props['intarray']
prop.Widen(prop2)
self.assertEqual(Type.INT, prop.type)
@@ -422,6 +422,15 @@ class TestProp(unittest.TestCase):
self.assertTrue(isinstance(prop.value, list))
self.assertEqual(3, len(prop.value))
+ # Widen an array of ints with an int (should do nothing)
+ prop = self.node.props['intarray']
+ prop2 = node2.props['intarray']
+ self.assertEqual(Type.INT, prop.type)
+ self.assertEqual(3, len(prop.value))
+ prop.Widen(prop2)
+ self.assertEqual(Type.INT, prop.type)
+ self.assertEqual(3, len(prop.value))
+
def testAdd(self):
"""Test adding properties"""
self.fdt.pack()