summaryrefslogtreecommitdiff
path: root/tests/pylibfdt_tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pylibfdt_tests.py')
-rw-r--r--tests/pylibfdt_tests.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
index 64b5bd1..68d6aaa 100644
--- a/tests/pylibfdt_tests.py
+++ b/tests/pylibfdt_tests.py
@@ -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,
@@ -382,6 +395,25 @@ class PyLibfdtBasicTests(unittest.TestCase):
self.get_prop("prop-uint64").as_uint64())
self.assertEqual(-2, self.get_prop("prop-int64").as_int64())
+ def testGetIntListProperties(self):
+ """Test that we can access properties as integer lists"""
+ self.assertEqual([128, -16, -2],
+ self.get_prop("prop-int32-array").as_int32_list())
+ self.assertEqual([0x1, 0x98765432, 0xdeadbeef],
+ self.get_prop("prop-uint32-array").as_uint32_list())
+ self.assertEqual([0x100000000, -2],
+ self.get_prop("prop-int64-array").as_int64_list())
+ self.assertEqual([0x100000000, 0x1],
+ self.get_prop("prop-uint64-array").as_uint64_list())
+
+ def testGetStringlistProperties(self):
+ """Test that we can access properties as string list"""
+ node = self.fdt.path_offset('/subnode@1/subsubnode')
+ self.assertEqual(["subsubnode1", "subsubnode"],
+ self.fdt.getprop(node, "compatible").as_stringlist())
+ self.assertEqual(["this is a placeholder string", "string2"],
+ self.fdt.getprop(node, "placeholder").as_stringlist())
+
def testReserveMap(self):
"""Test that we can access the memory reserve map"""
self.assertEqual(2, self.fdt.num_mem_rsv())