Returns the workspace root directory. As we don't have packages in the workspace root, we walk up until we found the main Cargo.toml file.
()
| 410 | /// As we don't have packages in the workspace root, |
| 411 | /// we walk up until we found the main Cargo.toml file. |
| 412 | fn workspace_root() -> PathBuf { |
| 413 | // The directory of the current crate (integration test). |
| 414 | let mut dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); |
| 415 | |
| 416 | // Currently we have one level of nesting and we probably never change it. |
| 417 | let max_levels = 2; |
| 418 | |
| 419 | eprintln!( |
| 420 | "Looking for workspace root: starting with dir={}", |
| 421 | dir.to_str().unwrap() |
| 422 | ); |
| 423 | |
| 424 | // walk up |
| 425 | for _ in 0..max_levels { |
| 426 | dir = dir.parent().unwrap().to_path_buf(); |
| 427 | eprintln!("Checking parent dir: {}", dir.to_str().unwrap()); |
| 428 | let maybe_manifest_file = dir.join("Cargo.toml"); |
| 429 | if maybe_manifest_file.exists() { |
| 430 | let content = fs::read_to_string(&maybe_manifest_file).unwrap(); |
| 431 | if content.contains("[workspace]") && content.contains("Cloud Hypervisor Workspace") { |
| 432 | eprintln!("INFO: Found workspace root: {}", dir.to_str().unwrap()); |
| 433 | return dir; |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | panic!("Could not find workspace root"); |
| 439 | } |
| 440 | |
| 441 | impl DiskConfig for UbuntuDiskConfig { |
| 442 | fn prepare_cloudinit(&self, tmp_dir: &TempDir, network: &GuestNetworkConfig) -> String { |
no test coverage detected