mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
b157bda3ee
Testing tap functionality requires root privileges. The crosvmdev user of our dev_container is set up for passwordless sudo, so we can seamlessly execute these tests via sudo. For running on the developer workstation directly, this will prompt for a password, which is disruptive to workflows. The --no-root option can be used to prevent this and skip the tests in question. BUG=None TEST=tools/run_tests [--no-root] Change-Id: I731887837affceb76152466f0006c4ee51a19234 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4063237 Reviewed-by: Zihan Chen <zihanchen@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
37 lines
904 B
Rust
37 lines
904 B
Rust
// Copyright 2022 The ChromiumOS Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#![cfg(unix)]
|
|
|
|
use std::net;
|
|
|
|
use net_util::sys::unix::Tap;
|
|
use net_util::MacAddress;
|
|
use net_util::TapTCommon;
|
|
|
|
#[test]
|
|
fn tap_create() {
|
|
Tap::new(true, false).unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn tap_configure() {
|
|
let tap = Tap::new(true, false).unwrap();
|
|
let ip_addr: net::Ipv4Addr = "100.115.92.5".parse().unwrap();
|
|
let netmask: net::Ipv4Addr = "255.255.255.252".parse().unwrap();
|
|
let mac_addr: MacAddress = "a2:06:b9:3d:68:4d".parse().unwrap();
|
|
|
|
tap.set_ip_addr(ip_addr).unwrap();
|
|
tap.set_netmask(netmask).unwrap();
|
|
tap.set_mac_address(mac_addr).unwrap();
|
|
tap.set_vnet_hdr_size(16).unwrap();
|
|
tap.set_offload(0).unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn tap_enable() {
|
|
let tap = Tap::new(true, false).unwrap();
|
|
|
|
tap.enable().unwrap();
|
|
}
|