[Crosstoolchain-logs] [device-tree-compiler] 46/57: pylibfdt: Add support for fdt_parent_offset()

Vagrant Cascadian vagrant at moszumanska.debian.org
Thu Sep 28 22:04:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

vagrant pushed a commit to branch upstream/latest
in repository device-tree-compiler.

commit a3ae43723687cd9e14e8e6c95c01152887ba94ac
Author: Simon Glass <sjg at chromium.org>
Date:   Sat Aug 19 11:17:58 2017 -0600

    pylibfdt: Add support for fdt_parent_offset()
    
    Add this into the class to simplify use of this function.
    
    Signed-off-by: Simon Glass <sjg at chromium.org>
    Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 pylibfdt/libfdt.i       | 15 +++++++++++++++
 tests/pylibfdt_tests.py | 13 +++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index 0731202..5a1eba5 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -360,6 +360,21 @@ class Fdt:
         """
         return fdt_get_phandle(self._fdt, nodeoffset)
 
+    def parent_offset(self, nodeoffset, quiet=()):
+        """Get the offset of a node's parent
+
+        Args:
+            nodeoffset: Node offset to check
+            quiet: Errors to ignore (empty to raise on all errors)
+
+        Returns:
+            The offset of the parent node, if any
+
+        Raises:
+            FdtException if no parent found or other error occurs
+        """
+        return check_err(fdt_parent_offset(self._fdt, nodeoffset), quiet)
+
 
 class Property:
     """Holds a device tree property name and value.
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 at 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 at 2')
+        self.assertEquals(0, self.fdt.parent_offset(node1))
+        node2 = self.fdt.path_offset('/subnode at 2/subsubnode at 0')
+        self.assertEquals(node1, self.fdt.parent_offset(node2))
+
 if __name__ == "__main__":
     unittest.main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list