summaryrefslogtreecommitdiff
path: root/tools/dtoc/test_fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-06 10:27:38 -0600
committerSimon Glass <sjg@chromium.org>2018-07-09 09:11:00 -0600
commit116adecb5e8e343cfc73a55f25a5d3d8463f4512 (patch)
tree98514b5da662a1bc1df3cb88a6f3671e35c55fd0 /tools/dtoc/test_fdt.py
parentfe57c784ad7187318a3aa6923d82095555bb50be (diff)
downloadu-boot-116adecb5e8e343cfc73a55f25a5d3d8463f4512.tar.gz
dtoc: Add functions to add integer properties
Add a few simple functions to add a placeholder integer property, and set its value. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_fdt.py')
-rwxr-xr-xtools/dtoc/test_fdt.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 49d188b1c1..f085b1dd1a 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -319,6 +319,26 @@ class TestProp(unittest.TestCase):
self.assertTrue(isinstance(prop.value, list))
self.assertEqual(3, len(prop.value))
+ def testAdd(self):
+ """Test adding properties"""
+ self.fdt.pack()
+ # This function should automatically expand the device tree
+ self.node.AddZeroProp('one')
+ self.node.AddZeroProp('two')
+ self.node.AddZeroProp('three')
+
+ # Updating existing properties should be OK, since the device-tree size
+ # does not change
+ self.fdt.pack()
+ self.node.SetInt('one', 1)
+ self.node.SetInt('two', 2)
+ self.node.SetInt('three', 3)
+
+ # This should fail since it would need to increase the device-tree size
+ with self.assertRaises(libfdt.FdtException) as e:
+ self.node.SetInt('four', 4)
+ self.assertIn('FDT_ERR_NOSPACE', str(e.exception))
+
class TestFdtUtil(unittest.TestCase):
"""Tests for the fdt_util module