Add control of capturing output into u_boot_pylib and the tools which
use it.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 tools/binman/ftest.py           |  3 ++-
 tools/binman/main.py            |  4 ++--
 tools/buildman/main.py          |  2 +-
 tools/dtoc/main.py              |  5 +++--
 tools/dtoc/test_fdt.py          |  2 +-
 tools/patman/__main__.py        |  2 +-
 tools/u_boot_pylib/__main__.py  |  2 +-
 tools/u_boot_pylib/test_util.py | 10 +++++++---
 8 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 3fb7416a567..f20a9d9bb54 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -270,7 +270,7 @@ class TestFunctional(unittest.TestCase):
 
     @classmethod
     def setup_test_args(cls, preserve_indir=False, preserve_outdirs=False,
-                        toolpath=None, verbosity=None):
+                        toolpath=None, verbosity=None, no_capture=False):
         """Accept arguments controlling test execution
 
         Args:
@@ -285,6 +285,7 @@ class TestFunctional(unittest.TestCase):
         cls.preserve_outdirs = preserve_outdirs
         cls.toolpath = toolpath
         cls.verbosity = verbosity
+        cls.no_capture = no_capture
 
     def _CheckBintool(self, bintool):
         if not bintool.is_present():
diff --git a/tools/binman/main.py b/tools/binman/main.py
index 326f5c93155..fa5ad79ca0e 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -77,8 +77,8 @@ def RunTests(debug, verbosity, processes, test_preserve_dirs, 
args, toolpath):
     # Run the entry tests first ,since these need to be the first to import the
     # 'entry' module.
     result = test_util.run_test_suites(
-        'binman', debug, verbosity, test_preserve_dirs, processes, test_name,
-        toolpath,
+        'binman', debug, verbosity, False, test_preserve_dirs, processes,
+        test_name, toolpath,
         [bintool_test.TestBintool, entry_test.TestEntry, ftest.TestFunctional,
          fdt_test.TestFdt, elf_test.TestElf, image_test.TestImage,
          cbfs_util_test.TestCbfs, fip_util_test.TestFip])
diff --git a/tools/buildman/main.py b/tools/buildman/main.py
index 72571b226d9..77b9bebed27 100755
--- a/tools/buildman/main.py
+++ b/tools/buildman/main.py
@@ -49,7 +49,7 @@ def run_tests(skip_net_tests, debug, verbose, args):
     # Run the entry tests first ,since these need to be the first to import the
     # 'entry' module.
     result = test_util.run_test_suites(
-        'buildman', debug, verbose, False, args.threads, test_name, [],
+        'buildman', debug, verbose, False, False, args.threads, test_name, [],
         [test.TestBuild, func_test.TestFunctional, 'buildman.toolchain'])
 
     return (0 if result.wasSuccessful() else 1)
diff --git a/tools/dtoc/main.py b/tools/dtoc/main.py
index 6c91450410e..59b98b0fa9f 100755
--- a/tools/dtoc/main.py
+++ b/tools/dtoc/main.py
@@ -58,8 +58,9 @@ def run_tests(processes, args):
     test_dtoc.setup()
 
     result = test_util.run_test_suites(
-        toolname='dtoc', debug=True, verbosity=1, test_preserve_dirs=False,
-        processes=processes, test_name=test_name, toolpath=[],
+        toolname='dtoc', debug=True, verbosity=1, no_capture=False,
+        test_preserve_dirs=False, processes=processes, test_name=test_name,
+        toolpath=[],
         class_and_module_list=[test_dtoc.TestDtoc,test_src_scan.TestSrcScan])
 
     return (0 if result.wasSuccessful() else 1)
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py
index 0b01518f3a5..a0bed4e18bb 100755
--- a/tools/dtoc/test_fdt.py
+++ b/tools/dtoc/test_fdt.py
@@ -969,7 +969,7 @@ def run_tests(names, processes):
     """
     test_name = names[0] if names else None
     result = test_util.run_test_suites(
-        'test_fdt', False, False, False, processes, test_name, None,
+        'test_fdt', False, False, False, False, processes, test_name, None,
         [TestFdt, TestNode, TestProp, TestFdtUtil])
 
     return (0 if result.wasSuccessful() else 1)
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py
index 0d08a53cbab..db78ea603c2 100755
--- a/tools/patman/__main__.py
+++ b/tools/patman/__main__.py
@@ -38,7 +38,7 @@ def run_patman():
         from patman import test_checkpatch
 
         result = test_util.run_test_suites(
-            'patman', False, False, False, None, None, None,
+            'patman', False, False, False, False, None, None, None,
             [test_checkpatch.TestPatch, func_test.TestFunctional,
              'settings'])
 
diff --git a/tools/u_boot_pylib/__main__.py b/tools/u_boot_pylib/__main__.py
index c0762bca733..d86b9d7dce0 100755
--- a/tools/u_boot_pylib/__main__.py
+++ b/tools/u_boot_pylib/__main__.py
@@ -16,7 +16,7 @@ if __name__ == "__main__":
     from u_boot_pylib import test_util
 
     result = test_util.run_test_suites(
-        'u_boot_pylib', False, False, False, None, None, None,
+        'u_boot_pylib', False, False, False, False, None, None, None,
         ['terminal'])
 
     sys.exit(0 if result.wasSuccessful() else 1)
diff --git a/tools/u_boot_pylib/test_util.py b/tools/u_boot_pylib/test_util.py
index 119ae60af33..3f7e5ece4e9 100644
--- a/tools/u_boot_pylib/test_util.py
+++ b/tools/u_boot_pylib/test_util.py
@@ -12,6 +12,7 @@ import sys
 import unittest
 
 from u_boot_pylib import command
+from u_boot_pylib import terminal
 
 use_concurrent = True
 try:
@@ -155,8 +156,8 @@ class FullTextTestResult(unittest.TextTestResult):
         super().addSkip(test, reason)
 
 
-def run_test_suites(toolname, debug, verbosity, test_preserve_dirs, processes,
-                    test_name, toolpath, class_and_module_list):
+def run_test_suites(toolname, debug, verbosity, no_capture, test_preserve_dirs,
+                    processes, test_name, toolpath, class_and_module_list):
     """Run a series of test suites and collect the results
 
     Args:
@@ -179,6 +180,9 @@ def run_test_suites(toolname, debug, verbosity, 
test_preserve_dirs, processes,
         sys.argv.append('-D')
     if verbosity:
         sys.argv.append('-v%d' % verbosity)
+    if no_capture:
+        sys.argv.append('-N')
+        terminal.USE_CAPTURE = False
     if toolpath:
         for path in toolpath:
             sys.argv += ['--toolpath', path]
@@ -207,7 +211,7 @@ def run_test_suites(toolname, debug, verbosity, 
test_preserve_dirs, processes,
             setup_test_args = getattr(module, 'setup_test_args')
             setup_test_args(preserve_indir=test_preserve_dirs,
                 preserve_outdirs=test_preserve_dirs and test_name is not None,
-                toolpath=toolpath, verbosity=verbosity)
+                toolpath=toolpath, verbosity=verbosity, no_capture=no_capture)
         if test_name:
             # Since Python v3.5 If an ImportError or AttributeError occurs
             # while traversing a name then a synthetic test that raises that
-- 
2.43.0

Reply via email to