summaryrefslogtreecommitdiff
path: root/util/run_host_test
diff options
context:
space:
mode:
authorPaul Fagerburg <pfagerburg@google.com>2020-06-11 10:51:19 -0600
committerCommit Bot <commit-bot@chromium.org>2020-06-12 21:20:29 +0000
commit776fe3f999e637f6ae00a52aba88d4c2df0f25dc (patch)
tree61377ee064eaeb6faf8c98a3585d0a61981cb5c3 /util/run_host_test
parentabf6b6e1d502101ccae25b500811d87925feaa2c (diff)
downloadchrome-ec-776fe3f999e637f6ae00a52aba88d4c2df0f25dc.tar.gz
makefile: use separate directory for code coverage
When building host-based unit tests for code coverage, put the build outputs in a different directory. Because the code coverage build has calls into gcov library functions, a partial rebuild without code coverage will result in undefined linker errors. The previous solution was an inefficient cycle of `make clobber` and full rebuild when switching between building with and without code coverage. BUG=b:157091606 BRANCH=None TEST=`make buildall -j ; make coverage -j` Verify that build/host and build/coverage both exist, and that code coverage data (*.gcno, *.gcda, *.info) is only in build/coverage. Signed-off-by: Paul Fagerburg <pfagerburg@google.com> Change-Id: Iac0b18068082d34546aa15b174f86efb6a7f41a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242351 Tested-by: Paul Fagerburg <pfagerburg@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'util/run_host_test')
-rwxr-xr-xutil/run_host_test22
1 files changed, 13 insertions, 9 deletions
diff --git a/util/run_host_test b/util/run_host_test
index 57b197b6e7..ce33722c3a 100755
--- a/util/run_host_test
+++ b/util/run_host_test
@@ -91,26 +91,30 @@ def run_test(path, timeout=10):
proc.kill()
-def host_test(test_name):
- exec_path = pathlib.Path('build', 'host', test_name, f'{test_name}.exe')
- if not exec_path.is_file():
- raise argparse.ArgumentTypeError(f'No test named {test_name} exists!')
- return exec_path
-
-
def parse_options(argv):
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--timeout', type=float, default=60,
help='Timeout to kill test after.')
- parser.add_argument('test_name', type=host_test)
+ parser.add_argument('--coverage', action='store_const', const='coverage',
+ default='host', dest='test_target',
+ help='Flag if this is a code coverage test.')
+ parser.add_argument('test_name', type=str)
return parser.parse_args(argv)
def main(argv):
opts = parse_options(argv)
+ # Tests will be located in build/host, unless the --coverage flag was
+ # provided, in which case they will be in build/coverage.
+ exec_path = pathlib.Path('build', opts.test_target, opts.test_name,
+ f'{opts.test_name}.exe')
+ if not exec_path.is_file():
+ print(f'No test named {opts.test_name} exists!')
+ return 1
+
start_time = time.monotonic()
- result, output = run_test(opts.test_name, timeout=opts.timeout)
+ result, output = run_test(exec_path, timeout=opts.timeout)
elapsed_time = time.monotonic() - start_time
print('{} {}! ({:.3f} seconds)'.format(