pylibfdt: Add support for fdt_next_node()

This function requires a bit of typemap effort to get the depth parameter
to work correctly. Add support for it, along with a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Simon Glass 2018-06-06 15:37:01 -06:00 committed by David Gibson
parent f0f8c91698
commit 582a7159a5
2 changed files with 51 additions and 0 deletions

View file

@ -220,6 +220,24 @@ class PyLibfdtTests(unittest.TestCase):
self.assertEquals(libfdt.strerror(-libfdt.NOTFOUND),
'FDT_ERR_NOTFOUND')
def testNextNodeOffset(self):
"""Check that we can walk through nodes"""
node_list = []
node = 0
depth = 0
while depth >= 0:
node_list.append([depth, self.fdt.get_name(node)])
node, depth = self.fdt.next_node(node, depth, (libfdt.BADOFFSET,))
self.assertEquals(node_list, [
[0, ''],
[1, 'subnode@1'],
[2, 'subsubnode'],
[2, 'ss1'],
[1, 'subnode@2'],
[2, 'subsubnode@0'],
[2, 'ss2'],
])
def testFirstNextSubnodeOffset(self):
"""Check that we can walk through subnodes"""
node_list = []