From 2e9a0cdfa8456636392f24dcc47e3270bd4818b7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:48 -0600 Subject: patman: Use test_util to show test results This handles skipped tests correctly, so use it instead of the existing code. Signed-off-by: Simon Glass --- tools/patman/test_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/patman/test_util.py') diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index aac58fb72f..0827488f33 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -123,12 +123,12 @@ def ReportResult(toolname:str, test_name: str, result: unittest.TestResult): for test, err in result.failures: print(err, result.failures) if result.skipped: - print('%d binman test%s SKIPPED:' % - (len(result.skipped), 's' if len(result.skipped) > 1 else '')) + print('%d %s test%s SKIPPED:' % (len(result.skipped), toolname, + 's' if len(result.skipped) > 1 else '')) for skip_info in result.skipped: print('%s: %s' % (skip_info[0], skip_info[1])) if result.errors or result.failures: - print('binman tests FAILED') + print('%s tests FAILED' % toolname) return 1 return 0 -- cgit From 57374b09ec956f557ae55939e74ba841d76e0bf2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 5 Jul 2020 21:41:55 -0600 Subject: patman: Add a 'test' subcommand At present we use --test to indicate that tests should be run. It is better to use a subcommand for list, like binman. Change it and adjust the existing code to fit under a 'send' subcommand, the default. Give this subcommand the same default arguments as the others. Signed-off-by: Simon Glass --- tools/patman/test_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/patman/test_util.py') diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index 0827488f33..a87d3cc8f3 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -47,7 +47,7 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None): glob_list = [] glob_list += exclude_list glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*'] - test_cmd = 'test' if 'binman' in prog else '-t' + test_cmd = 'test' if 'binman' in prog or 'patman' in prog else '-t' prefix = '' if build_dir: prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir -- cgit From 92dee5fcc53186eb06a22c347ad8323618ca683b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:29 -0600 Subject: binman: Specify the toolpath when running test coverage 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 --- tools/patman/test_util.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tools/patman/test_util.py') diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index a87d3cc8f3..20dc1e4924 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -21,7 +21,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: @@ -34,6 +35,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% @@ -52,8 +55,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() -- cgit From 0b9116e31a6807a442f3a2ec887927536ce3aee3 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 9 Jul 2020 18:39:34 -0600 Subject: binman: Re-enable concurrent tests With the change to absolute imports the concurrent tests feature unfortunately broke. Fix it. We cannot easy add a warning, since the output messes up tests which check the output. Signed-off-by: Simon Glass --- tools/patman/test_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tools/patman/test_util.py') diff --git a/tools/patman/test_util.py b/tools/patman/test_util.py index 20dc1e4924..4e261755dc 100644 --- a/tools/patman/test_util.py +++ b/tools/patman/test_util.py @@ -16,7 +16,8 @@ from io import StringIO use_concurrent = True try: - from concurrencytest import ConcurrentTestSuite, fork_for_tests + from concurrencytest.concurrencytest import ConcurrentTestSuite + from concurrencytest.concurrencytest import fork_for_tests except: use_concurrent = False @@ -50,6 +51,7 @@ def RunTestCoverage(prog, filter_fname, exclude_list, build_dir, required=None, glob_list = [] glob_list += exclude_list glob_list += ['*libfdt.py', '*site-packages*', '*dist-packages*'] + glob_list += ['*concurrencytest*'] test_cmd = 'test' if 'binman' in prog or 'patman' in prog else '-t' prefix = '' if build_dir: -- cgit