mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 02:02:52 +00:00
tools: Add crosvm-direct support for run_tests
BUG=b:220292205 TEST=./tools/run_tests --target=host --crosvm-direct Change-Id: Ife25129d405cd1e514bf812cc31621313f2007b5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3708759 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com> Reviewed-by: Dennis Kempin <denniskempin@google.com> Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
This commit is contained in:
parent
7bba2599cf
commit
eb8cfb4b18
4 changed files with 32 additions and 10 deletions
|
@ -5,8 +5,12 @@ authors = ["The Chromium OS Authors"]
|
|||
edition = "2021"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
anyhow = "*"
|
||||
arch = { path = "../arch" }
|
||||
base = "*"
|
||||
cfg-if = "*"
|
||||
libc = "0.2.65"
|
||||
anyhow = "*"
|
||||
tempfile = "3"
|
||||
|
||||
[features]
|
||||
direct = []
|
||||
|
|
|
@ -7,5 +7,5 @@
|
|||
# There is an RFC for cargo to allow for this kind of dependency:
|
||||
# https://github.com/rust-lang/cargo/issues/9096
|
||||
cd $(dirname $0)
|
||||
(cd .. && cargo build $@)
|
||||
(cd .. && cargo build $@ && cargo build --features=direct --bin crosvm-direct)
|
||||
cargo test $@
|
||||
|
|
|
@ -80,18 +80,29 @@ fn rootfs_path() -> PathBuf {
|
|||
|
||||
/// The crosvm binary is expected to be alongside to the integration tests
|
||||
/// binary. Alternatively in the parent directory (cargo will put the
|
||||
/// test binary in target/debug/deps/ but the crosvm binary in target/debug).
|
||||
/// test binary in target/debug/deps/ but the crosvm binary in target/debug)
|
||||
fn find_crosvm_binary() -> PathBuf {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(features="direct")] {
|
||||
let binary_name = "crosvm-direct";
|
||||
} else {
|
||||
let binary_name = "crosvm";
|
||||
}
|
||||
}
|
||||
|
||||
let exe_dir = env::current_exe().unwrap().parent().unwrap().to_path_buf();
|
||||
let first = exe_dir.join("crosvm");
|
||||
let first = exe_dir.join(binary_name);
|
||||
if first.exists() {
|
||||
return first;
|
||||
}
|
||||
let second = exe_dir.parent().unwrap().join("crosvm");
|
||||
let second = exe_dir.parent().unwrap().join(binary_name);
|
||||
if second.exists() {
|
||||
return second;
|
||||
}
|
||||
panic!("Cannot find ./crosvm or ../crosvm alongside test binary.");
|
||||
panic!(
|
||||
"Cannot find {} in ./ or ../ alongside test binary.",
|
||||
binary_name
|
||||
);
|
||||
}
|
||||
|
||||
/// Safe wrapper for libc::mkfifo
|
||||
|
|
|
@ -226,15 +226,18 @@ def build_common_crate(build_env: dict[str, str], build_arch: Arch, crate: Crate
|
|||
return list(cargo_build_executables([], build_arch, env=build_env, cwd=crate.path))
|
||||
|
||||
|
||||
def build_all_binaries(target: TestTarget, build_arch: Arch):
|
||||
def build_all_binaries(target: TestTarget, build_arch: Arch, crosvm_direct: bool):
|
||||
"""Discover all crates and build them."""
|
||||
build_env = os.environ.copy()
|
||||
build_env.update(test_target.get_cargo_env(target, build_arch))
|
||||
|
||||
print("Building crosvm workspace")
|
||||
features = BUILD_FEATURES[build_arch]
|
||||
if crosvm_direct:
|
||||
features += ",direct"
|
||||
yield from cargo_build_executables(
|
||||
[
|
||||
"--features=" + BUILD_FEATURES[build_arch],
|
||||
"--features=" + features,
|
||||
"--verbose",
|
||||
"--workspace",
|
||||
*[f"--exclude={crate}" for crate in get_workspace_excludes(build_arch)],
|
||||
|
@ -379,6 +382,10 @@ def main():
|
|||
"--build-only",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--crosvm-direct",
|
||||
action="store_true",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--repeat",
|
||||
type=int,
|
||||
|
@ -406,7 +413,7 @@ def main():
|
|||
testvm.build_if_needed(target.vm)
|
||||
testvm.up(target.vm)
|
||||
|
||||
executables = list(build_all_binaries(target, build_arch))
|
||||
executables = list(build_all_binaries(target, build_arch, args.crosvm_direct))
|
||||
|
||||
if args.build_only:
|
||||
print("Not running tests as requested.")
|
||||
|
|
Loading…
Reference in a new issue