summaryrefslogtreecommitdiff
path: root/zephyr/firmware_builder.py
diff options
context:
space:
mode:
authorJeremy Bettis <jbettis@google.com>2022-02-17 09:22:23 -0700
committerCommit Bot <commit-bot@chromium.org>2022-02-23 03:13:00 +0000
commitb9706f570201ea3fc5d55392f80dc5787122ca33 (patch)
treeae6f6e4666c85fdb8692a58b2dea6a07decb3f9a /zephyr/firmware_builder.py
parente328bf3ec4768ac170a4b6d5c489f93ab1510074 (diff)
downloadchrome-ec-b9706f570201ea3fc5d55392f80dc5787122ca33.tar.gz
zmake: Implement zmake test v2
As described in go/zmake-cli-v2 Change zmake test to call zmake configure --test, unless the --no-rebuild flag is used, in which case just run tests on existing binaries. It is an error to use --no-rebuild, if you never did a zmake build. BRANCH=None BUG=b:217788621 TEST=make clobber zmake -j8 build herobrine test-drivers zmake -j8 test --no-rebuild herobrine zmake -j8 test --no-rebuild herobrine test-drivers zmake -j8 test --no-rebuild herobrine test-drivers test-tasks zmake -j8 build test-tasks zmake -j8 test --no-rebuild herobrine test-drivers test-tasks make clobber zmake -j8 build --coverage herobrine test-drivers zmake -j8 test --coverage --no-rebuild herobrine zmake -j8 test --coverage --no-rebuild herobrine test-drivers zmake -j8 test --coverage --no-rebuild herobrine test-drivers test-tasks zmake -j8 build --coverage test-tasks zmake -j8 test --coverage --no-rebuild herobrine test-drivers test-tasks zmake -j8 test --coverage herobrine brya zmake -j8 test --coverage --no-rebuild herobrine brya zmake -j8 testall zmake -j8 test --all zmake -j8 test --all --no-rebuild zmake -j8 test --host-tests-only zmake -j8 test --host-tests-only --no-rebuild zmake -j8 test --host-tests-only --coverage zmake -j8 test --host-tests-only --coverage Signed-off-by: Jeremy Bettis <jbettis@google.com> Change-Id: I90f23cd0061d97e42359e1d49f2331b71554e3a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3472683 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Tested-by: Jeremy Bettis <jbettis@chromium.org> Commit-Queue: Jeremy Bettis <jbettis@chromium.org>
Diffstat (limited to 'zephyr/firmware_builder.py')
-rwxr-xr-xzephyr/firmware_builder.py62
1 files changed, 28 insertions, 34 deletions
diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py
index ae19b82c81..2b138357f3 100755
--- a/zephyr/firmware_builder.py
+++ b/zephyr/firmware_builder.py
@@ -31,10 +31,10 @@ def build(opts):
with open(opts.metrics, 'w') as f:
f.write(json_format.MessageToJson(metrics))
- # Nothing to do, as the test phase actually does the builds.
- # TODO(b/217788621): Do a build-only here once we can separate build
- # and test phases on zmake CLI.
- return 0
+ cmd = ['zmake', '-D', 'build', '-a']
+ if opts.code_coverage:
+ cmd.append('--coverage')
+ return subprocess.run(cmd, cwd=pathlib.Path(__file__).parent).returncode
def bundle(opts):
@@ -71,27 +71,7 @@ def bundle_coverage(opts):
bundle_dir = get_bundle_dir(opts)
zephyr_dir = pathlib.Path(__file__).parent
platform_ec = zephyr_dir.resolve().parent
- # Find the zephyr.info for every project and merge them
- all_lcov_files = [platform_ec / 'build' / 'zephyr-coverage' / 'lcov.info']
- for project in zmake.project.find_projects(zephyr_dir).values():
- if not project.config.is_test:
- build_dir = platform_ec / "build" / "zephyr" / project.config.project_name
- artifacts_dir = build_dir / 'output'
- all_lcov_files.append(artifacts_dir / 'zephyr.info')
- build_dir = platform_ec / "build"
- print("all_lcov_files = %s" % all_lcov_files)
- cmd = [
- "/usr/bin/lcov",
- "-o",
- build_dir / "lcov.info",
- "--rc",
- "lcov_branch_coverage=1",
- ]
- for lcov_file in all_lcov_files:
- cmd += ["-a", lcov_file]
- rv = subprocess.run(cmd, cwd=pathlib.Path(__file__).parent).returncode
- if rv != 0:
- return rv
+ build_dir = platform_ec / "build" / "zephyr"
tarball_name = 'coverage.tbz2'
tarball_path = bundle_dir / tarball_name
cmd = ['tar', 'cvfj', tarball_path, 'lcov.info']
@@ -112,12 +92,10 @@ def bundle_firmware(opts):
zephyr_dir = pathlib.Path(__file__).parent
platform_ec = zephyr_dir.resolve().parent
for project in zmake.project.find_projects(zephyr_dir).values():
+ if project.config.is_test:
+ continue
build_dir = platform_ec / "build" / "zephyr" / project.config.project_name
artifacts_dir = build_dir / 'output'
- # TODO(kmshelton): Remove once the build command does not rely
- # on a pre-defined list of targets.
- if not artifacts_dir.is_dir():
- continue
tarball_name = '{}.firmware.tbz2'.format(project.config.project_name)
tarball_path = bundle_dir.joinpath(tarball_name)
cmd = ['tar', 'cvfj', tarball_path, '.']
@@ -149,13 +127,29 @@ def test(opts):
config_files = zephyr_dir.rglob("**/BUILD.py")
subprocess.run(["black", "--diff", "--check", *config_files], check=True)
+ cmd = ['zmake', '-D', 'test', '-a', '--no-rebuild']
+ if opts.code_coverage:
+ cmd.append('--coverage')
+ rv = subprocess.run(cmd, check=True).returncode
+ if rv:
+ return rv
if opts.code_coverage:
platform_ec = zephyr_dir.parent
- build_dir = platform_ec / 'build/zephyr-coverage'
- return subprocess.run(
- ['zmake', '-D', 'coverage', build_dir], cwd=platform_ec).returncode
- else:
- return subprocess.run(['zmake', '-D', 'testall'], check=True).returncode
+ build_dir = platform_ec / "build" / "zephyr"
+ # Merge lcov files here because bundle failures are "infra" failures.
+ cmd = [
+ "/usr/bin/lcov",
+ "-o",
+ build_dir / "lcov.info",
+ "--rc",
+ "lcov_branch_coverage=1",
+ "-a", build_dir / 'all_tests.info',
+ "-a", build_dir / 'all_builds.info',
+ ]
+ rv = subprocess.run(cmd, cwd=pathlib.Path(__file__).parent).returncode
+ if rv != 0:
+ return rv
+ return 0
def main(args):