diff mbox series

[v2,06/49] binman: Specify the toolpath when running test coverage

Message ID 20200613205717.v2.6.Ic20e5ff36dd31f774d752a95f394e7a20b84cf4a@changeid
State Accepted
Commit 92dee5fcc53186eb06a22c347ad8323618ca683b
Headers show
Series rockchip: x86: Support building ROM files automatically with binman | expand

Commit Message

Simon Glass June 14, 2020, 2:56 a.m. UTC
At present binman's test coverage runs without a toolpath set. This means
that the system tools will be used. That may not be correct if they are
out of date or missing and this can result in a reduction in test coverage
below 100%.

Provide the toolpath to binman in this case.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 tools/binman/main.py      | 10 +++++++---
 tools/patman/test_util.py |  9 ++++++---
 2 files changed, 13 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/tools/binman/main.py b/tools/binman/main.py
index 6f5a9d1ca2..a5793d5d23 100755
--- a/tools/binman/main.py
+++ b/tools/binman/main.py
@@ -89,14 +89,18 @@  def GetEntryModules(include_testing=True):
                 for item in glob_list
                 if include_testing or '_testing' not in item])
 
-def RunTestCoverage():
+def RunTestCoverage(toolpath):
     """Run the tests and check that we get 100% coverage"""
     glob_list = GetEntryModules(False)
     all_set = set([os.path.splitext(os.path.basename(item))[0]
                    for item in glob_list if '_testing' not in item])
+    extra_args = ''
+    if toolpath:
+        for path in toolpath:
+            extra_args += ' --toolpath %s' % path
     test_util.RunTestCoverage('tools/binman/binman', None,
             ['*test*', '*main.py', 'tools/patman/*', 'tools/dtoc/*'],
-            args.build_dir, all_set)
+            args.build_dir, all_set, extra_args or None)
 
 def RunBinman(args):
     """Main entry point to binman once arguments are parsed
@@ -111,7 +115,7 @@  def RunBinman(args):
 
     if args.cmd == 'test':
         if args.test_coverage:
-            RunTestCoverage()
+            RunTestCoverage(args.toolpath)
         else:
             ret_code = RunTests(args.debug, args.verbosity, args.processes,
                                 args.test_preserve_dirs, args.tests,
diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py
index 4d28d9fc92..467797e380 100644
--- a/tools/patman/test_util.py
+++ b/tools/patman/test_util.py
@@ -22,7 +22,8 @@  except:
     use_concurrent = False
 
 
-def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
+def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None,
+                    extra_args=None):
     """Run tests and check that we get 100% coverage
 
     Args:
@@ -35,6 +36,8 @@  def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
             calculation
         build_dir: Build directory, used to locate libfdt.py
         required: List of modules which must be in the coverage report
+        extra_args (str): Extra arguments to pass to the tool before the -t/test
+            arg
 
     Raises:
         ValueError if the code coverage is not 100%
@@ -53,8 +56,8 @@  def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None):
     if build_dir:
         prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir
     cmd = ('%spython3-coverage run '
-           '--omit "%s" %s %s -P1' % (prefix, ','.join(glob_list),
-                                      prog, test_cmd))
+           '--omit "%s" %s %s %s -P1' % (prefix, ','.join(glob_list),
+                                         prog, extra_args or '', test_cmd))
     os.system(cmd)
     stdout = command.Output('python3-coverage', 'report')
     lines = stdout.splitlines()