From 85d5655160ead40247e0ceb21d51ab7e8f656376 Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Wed, 27 Oct 2021 10:24:09 -0700 Subject: [PATCH] test_runner: Refer to crates by their names, not paths When looking up crate options from test_options.py we used their path relative to the crosvm root (e.g. common/p9). But when looking up options for binaries, the name is parsed from cargo output and just the crate name (e.g. p9). Fix this by just using the crate name. BUG=b:195126527 TEST=./tools/run_tests Change-Id: I09a3469daa071dc66295d777449dc101a6564162 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248127 Commit-Queue: Dennis Kempin Tested-by: Dennis Kempin Reviewed-by: Daniel Verkamp --- tools/impl/test_runner.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tools/impl/test_runner.py b/tools/impl/test_runner.py index a9067ec461..c7afff2e7c 100755 --- a/tools/impl/test_runner.py +++ b/tools/impl/test_runner.py @@ -56,6 +56,7 @@ TEST_TIMEOUT_SECS = 60 PARALLELISM = 4 CROSVM_ROOT = Path(__file__).parent.parent.parent.resolve() +COMMON_ROOT = CROSVM_ROOT / "common" class ExecutableResults(object): @@ -106,12 +107,12 @@ def should_run_executable(executable: Executable, target_arch: Arch): def list_main_crates(): yield "crosvm" for path in CROSVM_ROOT.glob("*/Cargo.toml"): - yield str(path.parent.relative_to(CROSVM_ROOT)) + yield path.parent.name -def list_extra_crates(): - for path in CROSVM_ROOT.glob("common/*/Cargo.toml"): - yield str(path.parent.relative_to(CROSVM_ROOT)) +def list_common_crates(): + for path in COMMON_ROOT.glob("*/Cargo.toml"): + yield path.parent.name def cargo( @@ -218,14 +219,14 @@ def build_all_binaries(target: TestTarget, target_arch: Arch): main_crates, env=build_env, features=set(["all-linux"]) ) - for crate_path in list_extra_crates(): - if not should_build_crate(crate_path, target_arch): + for crate in list_common_crates(): + if not should_build_crate(crate, target_arch): continue - print("Building tests for:", crate_path) + print(f"Building tests for: common/{crate}") yield from cargo_build_executables( [], env=build_env, - cwd=CROSVM_ROOT.joinpath(crate_path), + cwd=COMMON_ROOT / crate, ) @@ -389,7 +390,7 @@ def main(): def verify_crate_options(): """Verify that CRATE_OPTIONS are for existing crates.""" - all_crates = list(list_main_crates()) + list(list_extra_crates()) + all_crates = list(list_main_crates()) + list(list_common_crates()) for crate, _ in CRATE_OPTIONS.items(): if crate not in all_crates: raise Exception("No such crate: %s" % crate)