]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
tools: Plumb in capture control
authorSimon Glass <sjg@chromium.org>
Tue, 29 Apr 2025 13:22:06 +0000 (07:22 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 27 May 2025 09:07:41 +0000 (10:07 +0100)
Add control of capturing output into u_boot_pylib and the tools which
use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/ftest.py
tools/binman/main.py
tools/buildman/main.py
tools/dtoc/main.py
tools/dtoc/test_fdt.py
tools/patman/__main__.py
tools/u_boot_pylib/__main__.py
tools/u_boot_pylib/test_util.py

index d3e6e6751045f4159337c0dd7a29c0d1f1148529..ffef213c0ffef6ebe359eec75d58d36311db306e 100644 (file)
@@ -274,7 +274,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:
@@ -289,6 +289,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():
index 326f5c93155be18d250ae05d03cd3d3bb1b68d43..fa5ad79ca0e8bf078889cc8d2dbac90bb9cdf5c7 100755 (executable)
@@ -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])
index 72571b226d9af29b3fd230898eeebbb6cf919d36..77b9bebed2769b9d5e174536e6bc335d6f830942 100755 (executable)
@@ -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)
index 6c91450410eee6f87818fa45a86d6e6b22724912..59b98b0fa9f8f2c3970caf9108bf68e490a4b7fc 100755 (executable)
@@ -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)
index 0b01518f3a5b8421f281c53a5aa86be3326b9a4f..a0bed4e18bb8fd9923a37921c92c972c0b9b8a04 100755 (executable)
@@ -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)
index 0d08a53cbabd3f9379810389453071c5d5d09147..db78ea603c2dbcacadab5c83ca5ba260fd656588 100755 (executable)
@@ -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'])
 
index c0762bca733957e9a299e0541fd4849bc7083c79..d86b9d7dce0d6a4043ffd94ac974d2af3d9d4133 100755 (executable)
@@ -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)
index fc441a78dc15415b2c239de3dca9d0dd8f9796d9..d258a1935c9416b76ffaa691ebc2b64886937ce3 100644 (file)
@@ -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