crosvm/tools/clippy
Dennis Kempin 767e094fb8 tools/run_tests: Use triples for arch
Updates run_tests to use cargo style target triples for specifying
build targets. A simple 'aarch64' or 'armhf' was nice while we just
had linux builds. We now are looking at windows and possibly
different toolchain options (e.g. msvc vs gnu), so our old system
was getting confusing and inconsistent.

We used to have some special handling for adding wrappers to test
runs for emulation (e.g. wine, qemu). That logic has been moved
into TestTarget which now contains not just where to run the test
but also how.

Supported are armhf/aarch64 qemu as well as wine64.

The CLI has been updated to match and now uses the build-target
argument instead of arch.

The following combinations have been tested (though not all
combinations actually pass all tests, which is a separate issue).

./tools/run_tests
./tools/run_tests --target=host --build-target=x86_64-unknown-linux-gnu
./tools/run_tests --target=host --build-target=armhf
./tools/run_tests --target=host --build-target=aarch64
./tools/run_tests --target=host --build-target=mingw64
./tools/run_tests --target=vm:aarch64
./tools/run_tests --target=vm:aarch64 --build-target=armhf

BUG=b:233914170
TEST=See above

Change-Id: Ic6dbb5b39788e2573714606d3bb0e7c712032d91
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739240
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 19:16:59 +00:00

67 lines
1.9 KiB
Python
Executable file

#!/usr/bin/env python3
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# To check for violations:
# $ ./tools/clippy
#
# To fix violations where possible:
# $ ./tools/clippy --fix
import os
from impl.common import CROSVM_ROOT, cwd, run_main, cmd, chdir
from impl.test_runner import get_workspace_excludes
from impl.test_target import Triple
clippy = cmd("cargo clippy")
excluded_crates: list[str] = []
features: str = ""
if os.name == "posix":
features = "--features=all-linux"
elif os.name == "nt":
excluded_crates = list(get_workspace_excludes(Triple.from_str("x86_64-pc-windows-msvc")))
else:
raise Exception(f"Unsupported build target: {os.name}")
def is_crate_excluded(crate: str) -> bool:
return crate in excluded_crates
def main(fix: bool = False, json: bool = False):
chdir(CROSVM_ROOT)
# Note: Clippy checks are configured in .cargo/config.toml
common_args = [
"--fix" if fix else None,
"--message-format=json" if json else None,
"--all-targets",
"--",
"-Dwarnings",
]
print("Clippy crosvm workspace")
clippy(
"--workspace",
features,
*[f"--exclude={crate}" for crate in excluded_crates],
*common_args,
).fg()
for crate in CROSVM_ROOT.glob("common/*/Cargo.toml"):
# TODO(b/213147081): remove the cros_async exclude this once
# common/cros_async is gone.
if is_crate_excluded(crate.parent.name) or (
os.name == "nt" and crate.parent.name == "cros_async"
):
print("Skipping crate", crate.parent.relative_to(CROSVM_ROOT))
else:
print("Clippy", crate.parent.relative_to(CROSVM_ROOT))
with cwd(crate.parent):
clippy("--all-features", *common_args).fg()
if __name__ == "__main__":
run_main(main)