summaryrefslogtreecommitdiff
path: root/tests/pylibfdt_tests.py
diff options
context:
space:
mode:
author Simon Glass <sjg@chromium.org> 2017-08-19 11:18:01 -0600
committer David Gibson <david@gibson.dropbear.id.au> 2017-08-21 10:17:57 +1000
commit5bed86aee9e82cd8467560a9a39358943aaa4ad9 (patch)
tree40f5d7b228272c05b3be83107f6660ea8d6bfa0c /tests/pylibfdt_tests.py
parent46f31b65b3b3b1c284027ac6c287c75df64c126d (diff)
pylibfdt: Add support for fdt_subnode_offset()
Add this into the class to simplify use of this function. 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.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
index 8028c1a..95d911a 100644
--- a/tests/pylibfdt_tests.py
+++ b/tests/pylibfdt_tests.py
@@ -118,6 +118,18 @@ class PyLibfdtTests(unittest.TestCase):
fdt = libfdt.Fdt('a string')
self.assertEquals(e.exception.err, -libfdt.BADMAGIC)
+ def testSubnodeOffset(self):
+ """check that we can locate a subnode by name"""
+ node1 = self.fdt.path_offset('/subnode@1')
+ self.assertEquals(self.fdt.subnode_offset(0, 'subnode@1'), node1)
+
+ with self.assertRaises(FdtException) as e:
+ self.fdt.subnode_offset(0, 'missing')
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ node2 = self.fdt.path_offset('/subnode@1/subsubnode')
+ self.assertEquals(self.fdt.subnode_offset(node1, 'subsubnode'), node2)
+
def testPathOffset(self):
"""Check that we can find the offset of a node"""
self.assertEquals(self.fdt.path_offset('/'), 0)