mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
pylibfdt: add FdtRo.get_path()
Add a new Python method wrapping fdt_get_path() from the C API. Also add a test for the new method. Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Message-Id: <20220419194537.63170-1-luca@z3ntu.xyz> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
c001fc01a4
commit
ed310803ea
2 changed files with 41 additions and 0 deletions
|
@ -348,6 +348,19 @@ class PyLibfdtBasicTests(unittest.TestCase):
|
|||
self.assertEqual("/subnode@1/subsubnode", self.fdt3.get_alias('ss1'))
|
||||
self.assertEqual("/subnode@1/subsubnode/subsubsubnode", self.fdt3.get_alias('sss1'))
|
||||
|
||||
def testGetPath(self):
|
||||
"""Test for the get_path() method"""
|
||||
node = self.fdt.path_offset('/subnode@1')
|
||||
node2 = self.fdt.path_offset('/subnode@1/subsubnode')
|
||||
self.assertEqual("/subnode@1", self.fdt.get_path(node))
|
||||
self.assertEqual("/subnode@1/subsubnode", self.fdt.get_path(node2))
|
||||
|
||||
with self.assertRaises(FdtException) as e:
|
||||
self.fdt.get_path(-1)
|
||||
self.assertEqual(e.exception.err, -libfdt.BADOFFSET)
|
||||
|
||||
self.assertEqual(-libfdt.BADOFFSET, self.fdt.get_path(-1, quiet=(libfdt.BADOFFSET,)))
|
||||
|
||||
def testParentOffset(self):
|
||||
"""Test for the parent_offset() method"""
|
||||
self.assertEqual(-libfdt.NOTFOUND,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue