with open(self._fname) as fd:
self._fdt_obj = libfdt.Fdt(fd.read())
+ @staticmethod
+ def FromData(data):
+ """Create a new Fdt object from the given data
+
+ Args:
+ data: Device-tree data blob
+
+ Returns:
+ Fdt object containing the data
+ """
+ fdt = Fdt(None)
+ fdt._fdt_obj = libfdt.Fdt(bytearray(data))
+ return fdt
+
def LookupPhandle(self, phandle):
"""Look up a phandle
self.node.SetData('empty', '123')
self.assertEqual('123', prop.bytes)
+ def testFromData(self):
+ dtb2 = fdt.Fdt.FromData(self.dtb.GetContents())
+ self.assertEqual(dtb2.GetContents(), self.dtb.GetContents())
+
+ self.node.AddEmptyProp('empty', 5)
+ self.dtb.Sync(auto_resize=True)
+ self.assertTrue(dtb2.GetContents() != self.dtb.GetContents())
+
class TestFdtUtil(unittest.TestCase):
"""Tests for the fdt_util module