]> git.sur5r.net Git - u-boot/blobdiff - tools/binman/binman.py
binman: Add support for outputing a map file
[u-boot] / tools / binman / binman.py
index 3ccf25f1f884249ca98733b6b88423539c353516..31b045337d2320efc6305ec9301f09a5220b4a7b 100755 (executable)
@@ -1,10 +1,9 @@
 #!/usr/bin/env python2
+# SPDX-License-Identifier: GPL-2.0+
 
 # Copyright (c) 2016 Google, Inc
 # Written by Simon Glass <sjg@chromium.org>
 #
-# SPDX-License-Identifier:     GPL-2.0+
-#
 # Creates binary images from input files controlled by a description
 #
 
@@ -24,18 +23,23 @@ for dirname in ['../patman', '../dtoc', '..']:
 # Bring in the libfdt module
 sys.path.insert(0, 'scripts/dtc/pylibfdt')
 
-# Also allow entry-type modules to be brought in from the etype directory.
-sys.path.insert(0, os.path.join(our_path, 'etype'))
-
 import cmdline
 import command
 import control
 
-def RunTests():
-    """Run the functional tests and any embedded doctests"""
+def RunTests(debug, args):
+    """Run the functional tests and any embedded doctests
+
+    Args:
+        debug: True to enable debugging, which shows a full stack trace on error
+        args: List of positional args provided to binman. This can hold a test
+            name to execute (as in 'binman -t testSections', for example)
+    """
+    import elf_test
     import entry_test
     import fdt_test
     import ftest
+    import image_test
     import test
     import doctest
 
@@ -45,13 +49,23 @@ def RunTests():
         suite.run(result)
 
     sys.argv = [sys.argv[0]]
+    if debug:
+        sys.argv.append('-D')
 
     # Run the entry tests first ,since these need to be the first to import the
     # 'entry' module.
     suite = unittest.TestLoader().loadTestsFromTestCase(entry_test.TestEntry)
     suite.run(result)
-    for module in (ftest.TestFunctional, fdt_test.TestFdt):
-        suite = unittest.TestLoader().loadTestsFromTestCase(module)
+    test_name = args and args[0] or None
+    for module in (ftest.TestFunctional, fdt_test.TestFdt, elf_test.TestElf,
+                   image_test.TestImage):
+        if test_name:
+            try:
+                suite = unittest.TestLoader().loadTestsFromName(args[0], module)
+            except AttributeError:
+                continue
+        else:
+            suite = unittest.TestLoader().loadTestsFromTestCase(module)
         suite.run(result)
 
     print result
@@ -110,7 +124,7 @@ def RunBinman(options, args):
         sys.tracebacklimit = 0
 
     if options.test:
-        ret_code = RunTests()
+        ret_code = RunTests(options.debug, args[1:])
 
     elif options.test_coverage:
         RunTestCoverage()