aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-08-19 11:17:58 -0600
committerDavid Gibson <david@gibson.dropbear.id.au>2017-08-21 10:00:44 +1000
commita3ae43723687cd9e14e8e6c95c01152887ba94ac (patch)
treee500129239c4588d1fa791063df80192fa1cdc5d /tests
parenta198af80344cb4ffc480dc2673ee2935ea618f1d (diff)
downloaddtc-a3ae43723687cd9e14e8e6c95c01152887ba94ac.zip
dtc-a3ae43723687cd9e14e8e6c95c01152887ba94ac.tar.gz
dtc-a3ae43723687cd9e14e8e6c95c01152887ba94ac.tar.bz2
pylibfdt: Add support for fdt_parent_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')
-rw-r--r--tests/pylibfdt_tests.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
index 14820d5..6b024d4 100644
--- a/tests/pylibfdt_tests.py
+++ b/tests/pylibfdt_tests.py
@@ -295,5 +295,18 @@ class PyLibfdtTests(unittest.TestCase):
node2 = self.fdt.path_offset('/subnode@2')
self.assertEquals(0x2000, self.fdt.get_phandle(node2))
+ def testParentOffset(self):
+ """Test for the parent_offset() method"""
+ self.assertEquals(-libfdt.NOTFOUND,
+ self.fdt.parent_offset(0, QUIET_NOTFOUND))
+ with self.assertRaises(FdtException) as e:
+ self.fdt.parent_offset(0)
+ self.assertEquals(e.exception.err, -libfdt.NOTFOUND)
+
+ node1 = self.fdt.path_offset('/subnode@2')
+ self.assertEquals(0, self.fdt.parent_offset(node1))
+ node2 = self.fdt.path_offset('/subnode@2/subsubnode@0')
+ self.assertEquals(node1, self.fdt.parent_offset(node2))
+
if __name__ == "__main__":
unittest.main()