Skip to contentSkip to conversation

buildman: Fix verboose typo and add comment

PATCH New Simon Glass 1 participant 2 messages Jun 22, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 buildman: Fix verboose typo and add comment

Fix the typo in the RunTests() function, adding comments while we are here.

---

 tools/buildman/main.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tools/buildman/main.py +9 -2
index 5e1f68d82358..a2ffbc9073e7 100755
@@ -28,7 +28,14 @@ from patman import gitutil
 from u_boot_pylib import terminal
 from u_boot_pylib import test_util
 
-def RunTests(skip_net_tests, verboose, args):
+def RunTests(skip_net_tests, verbose, args):
+    """Run the buildman tests
+
+    Args:
+        skip_net_tests (bool): True to skip tests which need the network
+        verbosity (int): Verbosity level to use (0-4)
+        args (list of str): List of tests to run, empty to run all
+    """
     from buildman import func_test
     from buildman import test
     import doctest
@@ -40,7 +47,7 @@ def RunTests(skip_net_tests, verboose, 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', False, verboose, False, None, test_name, [],
+        'buildman', False, verbose, False, None, test_name, [],
         [test.TestBuild, func_test.TestFunctional,
          'buildman.toolchain', 'patman.gitutil'])
 
Signature · 1 line
2.41.0.162.gfafddb0af9-goog
#1 lore raw

PATCH 2/2 buildman: Provide an argument to the -R option

Allow writing the file to a selected location, since otherwise this is controlled by the buildman configuration, so cannot be determined by the caller.

---

 .azure-pipelines.yml        |  2 +-
 .gitlab-ci.yml              |  2 +-
 tools/buildman/buildman.rst |  7 ++++---
 tools/buildman/cmdline.py   |  2 +-
 tools/buildman/control.py   |  2 ++
 tools/buildman/func_test.py | 24 ++++++++++++++++++------
 6 files changed, 27 insertions(+), 12 deletions(-)
.azure-pipelines.yml +1 -1
index 3c1846a5bc3d..4d3c588ee020 100644
@@ -123,7 +123,7 @@ stages:
       options: $(container_option)
     steps:
       - script: |
-          ./tools/buildman/buildman -R
+          ./tools/buildman/buildman -R -
 
   - job: tools_only
     displayName: 'Ensure host tools build'
.gitlab-ci.yml +1 -1
index e6c6ab3586e1..336db7a7448f 100644
@@ -184,7 +184,7 @@ sloccount:
 Check for configs without MAINTAINERS entry:
   stage: testsuites
   script:
-    - ./tools/buildman/buildman -R
+    - ./tools/buildman/buildman -R -
 
 # Ensure host tools build
 Build tools-only:
tools/buildman/buildman.rst +4 -3
index c8b0db3d8b9c..b28aea477dfe 100644
@@ -1307,9 +1307,10 @@ Using boards.cfg
 
 This file is no-longer needed by buildman but it is still generated in the
 working directory. This helps avoid a delay on every build, since scanning all
-the Kconfig files takes a few seconds. Use the -R flag to force regeneration
-of the file - in that case buildman exits after writing the file. with exit code
-2 if there was an error in the maintainer files.
+the Kconfig files takes a few seconds. Use the `-R <filename>` flag to force
+regeneration of the file - in that case buildman exits after writing the file
+with exit code 2 if there was an error in the maintainer files. To use the
+default filename, use a hyphen, i.e. `-R -`.
 
 You should use 'buildman -nv <criteria>' instead of greoing the boards.cfg file,
 since it may be dropped altogether in future.
tools/buildman/cmdline.py +1 -1
index a9cda2495727..ea43685e394d 100644
@@ -104,7 +104,7 @@ def ParseArgs():
           default=False, help="Use an O= (output) directory per board rather than per thread")
     parser.add_option('-r', '--reproducible-builds', action='store_true',
           help='Set SOURCE_DATE_EPOCH=0 to suuport a reproducible build')
-    parser.add_option('-R', '--regen-board-list', action='store_true',
+    parser.add_option('-R', '--regen-board-list', type='string',
           help='Force regeneration of the list of boards, like the old boards.cfg file')
     parser.add_option('-s', '--summary', action='store_true',
           default=False, help='Show a build summary')
tools/buildman/control.py +2 -0
index 09a11f25b3f3..b8286e185411 100644
@@ -207,6 +207,8 @@ def DoBuildman(options, args, toolchains=None, make_func=None, brds=None,
         if not os.path.exists(options.output_dir):
             os.makedirs(options.output_dir)
         board_file = os.path.join(options.output_dir, 'boards.cfg')
+        if options.regen_board_list and options.regen_board_list != '-':
+            board_file = options.regen_board_list
 
         brds = boards.Boards()
         ok = brds.ensure_board_list(board_file,
tools/buildman/func_test.py +18 -6
index ebd78f225e1a..08b2714b7be2 100644
@@ -225,29 +225,33 @@ class TestFunctional(unittest.TestCase):
         return command.run_pipe([[self._buildman_pathname] + list(args)],
                 capture=True, capture_stderr=True)
 
-    def _RunControl(self, *args, brds=None, clean_dir=False,
-                    test_thread_exceptions=False):
+    def _RunControl(self, *args, brds=False, clean_dir=False,
+                    test_thread_exceptions=False, get_builder=True):
         """Run buildman
 
         Args:
             args: List of arguments to pass
-            brds: Boards object
+            brds: Boards object, or False to pass self._boards, or None to pass
+                None
             clean_dir: Used for tests only, indicates that the existing output_dir
                 should be removed before starting the build
             test_thread_exceptions: Uses for tests only, True to make the threads
                 raise an exception instead of reporting their result. This simulates
                 a failure in the code somewhere
+            get_builder (bool): Set self._builder to the resulting builder
 
         Returns:
             result code from buildman
         """
         sys.argv = [sys.argv[0]] + list(args)
         options, args = cmdline.ParseArgs()
+        if brds == False:
+            brds = self._boards
         result = control.DoBuildman(options, args, toolchains=self._toolchains,
-                make_func=self._HandleMake, brds=brds or self._boards,
-                clean_dir=clean_dir,
+                make_func=self._HandleMake, brds=brds, clean_dir=clean_dir,
                 test_thread_exceptions=test_thread_exceptions)
-        self._builder = control.builder
+        if get_builder:
+            self._builder = control.builder
         return result
 
     def testFullHelp(self):
@@ -779,3 +783,11 @@ Some images are invalid'''
 CONFIG_LOCALVERSION=y
 ''', cfg_data)
         self.assertIn('Not dropping LOCALVERSION_AUTO', stdout.getvalue())
+
+    def testRegenBoards(self):
+        """Test that we can regenerate the boards.cfg file"""
+        outfile = os.path.join(self._output_dir, 'test-boards.cfg')
+        if os.path.exists(outfile):
+            os.remove(outfile)
+        result = self._RunControl('-R', outfile, brds=None, get_builder=False)
+        self.assertTrue(os.path.exists(outfile))
Signature · 1 line
2.41.0.162.gfafddb0af9-goog