binman: Add a convenience functions for real-DTB tests
authorSimon Glass <sjg@chromium.org>
Mon, 8 Jul 2019 20:25:26 +0000 (14:25 -0600)
committerSimon Glass <sjg@chromium.org>
Wed, 24 Jul 2019 19:53:46 +0000 (12:53 -0700)
Quite a few tests will use a real device tree and need it updated with the
binman metadata. Add a helper function for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/ftest.py

index 5bde8aa30a11bd0092f5c2a70cfc181360102430..ed125670e2c28d2d6f50e9660fd923e2cc27b99e 100644 (file)
@@ -380,6 +380,17 @@ class TestFunctional(unittest.TestCase):
             if reset_dtbs and use_real_dtb:
                 self._ResetDtbs()
 
+    def _DoReadFileRealDtb(self, fname):
+        """Run binman with a real .dtb file and return the resulting data
+
+        Args:
+            fname: DT source filename to use (e.g. 082_fdt_update_all.dts)
+
+        Returns:
+            Resulting image contents
+        """
+        return self._DoReadFileDtb(fname, use_real_dtb=True, update_dtb=True)[0]
+
     def _DoReadFile(self, fname, use_real_dtb=False):
         """Helper function which discards the device-tree binary
 
@@ -1547,8 +1558,7 @@ class TestFunctional(unittest.TestCase):
 
     def testUpdateFdtAll(self):
         """Test that all device trees are updated with offset/size info"""
-        data, _, _, _ = self._DoReadFileDtb('082_fdt_update_all.dts',
-                                            use_real_dtb=True, update_dtb=True)
+        data = self._DoReadFileRealDtb('082_fdt_update_all.dts')
 
         base_expected = {
             'section:image-pos': 0,