aboutsummaryrefslogtreecommitdiff
path: root/tests/pylibfdt_tests.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-06-06 15:37:04 -0600
committerDavid Gibson <david@gibson.dropbear.id.au>2018-06-09 23:36:33 +1000
commit5a598671fdbf20355ecbaf59d9f502e689df683f (patch)
treeb371e2f5ecd7679897e4a33adf8444a015de721b /tests/pylibfdt_tests.py
parent483e170625e1b6905fc4c40db92ee48d47ee3283 (diff)
downloaddtc-5a598671fdbf20355ecbaf59d9f502e689df683f.zip
dtc-5a598671fdbf20355ecbaf59d9f502e689df683f.tar.gz
dtc-5a598671fdbf20355ecbaf59d9f502e689df683f.tar.bz2
pylibfdt: Support device-tree creation/expansion
Add support for fdt_open_into() and fdt_create_empty_tree() from the Python library. The former is named resize() since it better fits with what the Python binding actually does. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tests/pylibfdt_tests.py')
-rw-r--r--tests/pylibfdt_tests.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
index b624f7b..ea38b78 100644
--- a/tests/pylibfdt_tests.py
+++ b/tests/pylibfdt_tests.py
@@ -55,7 +55,7 @@ import unittest
sys.path.insert(0, '../pylibfdt')
import libfdt
-from libfdt import FdtException, QUIET_NOTFOUND, QUIET_ALL
+from libfdt import Fdt, FdtException, QUIET_NOTFOUND, QUIET_ALL
def get_err(err_code):
"""Convert an error code into an error message
@@ -364,6 +364,22 @@ class PyLibfdtTests(unittest.TestCase):
self.fdt.get_mem_rsv(0))
self.assertEquals([123456789, 010000], self.fdt.get_mem_rsv(1))
+ def testEmpty(self):
+ """Test that we can create an empty tree"""
+ self.assertEquals(-libfdt.NOSPACE,
+ Fdt.create_empty_tree(1, (libfdt.NOSPACE,)))
+ fdt = Fdt.create_empty_tree(128)
+ self.assertEquals(128, fdt.totalsize())
+
+ def testOpenInto(self):
+ """Test that we can resize a tree"""
+ fdt = Fdt.create_empty_tree(128)
+ self.assertEquals(128, fdt.totalsize())
+ fdt.resize(256)
+ self.assertEquals(256, fdt.totalsize())
+ fdt.pack()
+ self.assertTrue(fdt.totalsize() < 128)
+
if __name__ == "__main__":
unittest.main()