crosvm: skip creating tap device in plugins tests if not enough capabilities

BUG=none
TEST=presubmit

Change-Id: Icf3948941103b535ec138e68a05298c18d469485
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3574989
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
This commit is contained in:
Anton Romanov 2022-04-06 21:19:03 +00:00 committed by Chromeos LUCI
parent b3a094e820
commit f87295a8ce
2 changed files with 22 additions and 7 deletions

View file

@ -198,6 +198,7 @@ aarch64 = { path = "aarch64" }
[dev-dependencies]
base = "*"
lazy_static = "*"
[patch.crates-io]
assertions = { path = "common/assertions" }

View file

@ -17,6 +17,13 @@ use std::time::Duration;
use base::{ioctl, AsRawDescriptor};
use tempfile::tempfile;
lazy_static::lazy_static! {
static ref TAP_AVAILABLE: bool = {
use net_util::TapT;
net_util::Tap::new(true, false).is_ok()
};
}
struct RemovePath(PathBuf);
impl Drop for RemovePath {
fn drop(&mut self) {
@ -89,12 +96,6 @@ fn run_plugin(bin_path: &Path, with_sandbox: bool) {
"run",
"-c",
"1",
"--host_ip",
"100.115.92.5",
"--netmask",
"255.255.255.252",
"--mac",
"de:21:e8:47:6b:6a",
"--seccomp-policy-dir",
"tests",
"--plugin",
@ -104,6 +105,17 @@ fn run_plugin(bin_path: &Path, with_sandbox: bool) {
.canonicalize()
.expect("failed to canonicalize plugin path"),
);
if *TAP_AVAILABLE {
cmd.args(&[
"--host_ip",
"100.115.92.5",
"--netmask",
"255.255.255.252",
"--mac",
"de:21:e8:47:6b:6a",
]);
}
if !with_sandbox {
cmd.arg("--disable-sandbox");
}
@ -286,7 +298,9 @@ fn test_vcpu_pause() {
#[test]
fn test_net_config() {
test_plugin(include_str!("plugin_net_config.c"));
if *TAP_AVAILABLE {
test_plugin(include_str!("plugin_net_config.c"));
}
}
#[test]