summaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-09-14 04:57:36 -0600
committerSimon Glass <sjg@chromium.org>2018-09-29 11:49:35 -0600
commit163ed6c342cfd15b623a46f3755203c712374a9a (patch)
tree5de0842cb24244db853f5253f84b865a8668206a /tools/binman/ftest.py
parentfe1ae3ecc3a2203babd7837bd2d5cf514a374c1f (diff)
binman: Allow writing a map file when something goes wrong
When we get a problem like overlapping regions it is sometimes hard to figure what what is going on. At present we don't write the map file in this case. However the file does provide useful information. Catch any packing errors and write a map file (if enabled with -m) to aid debugging. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 27dca3a2a73..abf02b62e81 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -1607,8 +1607,9 @@ class TestFunctional(unittest.TestCase):
def testExpandSizeBad(self):
"""Test an expanding entry which fails to provide contents"""
- with self.assertRaises(ValueError) as e:
- self._DoReadFileDtb('89_expand_size_bad.dts', map=True)
+ with test_util.capture_sys_output() as (stdout, stderr):
+ with self.assertRaises(ValueError) as e:
+ self._DoReadFileDtb('89_expand_size_bad.dts', map=True)
self.assertIn("Node '/binman/_testing': Cannot obtain contents when "
'expanding entry', str(e.exception))
@@ -1724,6 +1725,25 @@ class TestFunctional(unittest.TestCase):
TestFunctional._MakeInputFile('-boot', fd.read())
data = self._DoReadFile('97_elf_strip.dts')
+ def testPackOverlapMap(self):
+ """Test that overlapping regions are detected"""
+ with test_util.capture_sys_output() as (stdout, stderr):
+ with self.assertRaises(ValueError) as e:
+ self._DoTestFile('14_pack_overlap.dts', map=True)
+ map_fname = tools.GetOutputFilename('image.map')
+ self.assertEqual("Wrote map file '%s' to show errors\n" % map_fname,
+ stdout.getvalue())
+
+ # We should not get an inmage, but there should be a map file
+ self.assertFalse(os.path.exists(tools.GetOutputFilename('image.bin')))
+ self.assertTrue(os.path.exists(map_fname))
+ map_data = tools.ReadFile(map_fname)
+ self.assertEqual('''ImagePos Offset Size Name
+<none> 00000000 00000007 main-section
+<none> 00000000 00000004 u-boot
+<none> 00000003 00000004 u-boot-align
+''', map_data)
+
if __name__ == "__main__":
unittest.main()