Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 26 additions & 16 deletions uefi-test-runner/src/proto/network/snp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ pub fn test() {
let simple_network = simple_network.unwrap();

// Check shutdown
simple_network
.shutdown()
.expect("Failed to shutdown Simple Network");
let res = simple_network.shutdown();
assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into()));

// Check stop
simple_network
.stop()
.expect("Failed to stop Simple Network");
let res = simple_network.stop();
assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into()));

// Check start
simple_network
Expand All @@ -36,15 +34,18 @@ pub fn test() {
.initialize(0, 0)
.expect("Failed to initialize Simple Network");

simple_network.reset_statistics().unwrap();
// edk2 virtio-net driver does not support statistics, so
// allow UNSUPPORTED (same for collect_statistics below).
let res = simple_network.reset_statistics();
assert!(res == Ok(()) || res == Err(Status::UNSUPPORTED.into()));

// Reading the interrupt status clears it
simple_network.get_interrupt_status().unwrap();

// Set receive filters
simple_network
.receive_filters(
ReceiveFlags::UNICAST | ReceiveFlags::MULTICAST | ReceiveFlags::BROADCAST,
ReceiveFlags::UNICAST | ReceiveFlags::BROADCAST,
ReceiveFlags::empty(),
false,
None,
Expand Down Expand Up @@ -113,13 +114,22 @@ pub fn test() {
assert_eq!(buffer[42..47], [4, 4, 3, 2, 1]);

// Get stats
let stats = simple_network
.collect_statistics()
.expect("Failed to collect statistics");
info!("Stats: {:?}", stats);

// One frame should have been transmitted and one received
assert_eq!(stats.tx_total_frames().unwrap(), 1);
assert_eq!(stats.rx_total_frames().unwrap(), 1);
let res = simple_network.collect_statistics();
match res {
Ok(stats) => {
info!("Stats: {:?}", stats);

// One frame should have been transmitted and one received
assert_eq!(stats.tx_total_frames().unwrap(), 1);
assert_eq!(stats.rx_total_frames().unwrap(), 1);
}
Err(e) => {
if e == Status::UNSUPPORTED.into() {
info!("Stats: unsupported.");
} else {
panic!("{e}");
}
}
}
}
}
5 changes: 2 additions & 3 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
features.push(Feature::DebugSupport);
}

// Enable the PXE test unless networking is disabled or the arch doesn't
// support it.
if *opt.target == UefiArch::X86_64 && !opt.disable_network {
// Enable the PXE test unless networking is disabled
if !opt.disable_network {
features.push(Feature::Pxe);
}

Expand Down
6 changes: 4 additions & 2 deletions xtask/src/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,10 @@ pub fn run_qemu(arch: UefiArch, opt: &QemuOpt) -> Result<()> {
// examples since it slows down the boot some.
let echo_service = if !opt.disable_network && opt.example.is_none() {
cmd.args([
"-nic",
"user,model=e1000,net=192.168.17.0/24,tftp=uefi-test-runner/tftp/,bootfile=fake-boot-file",
"-netdev",
"user,id=net0,net=192.168.17.0/24,tftp=uefi-test-runner/tftp/,bootfile=fake-boot-file",
"-device",
"virtio-net-pci,netdev=net0",
]);
Some(net::EchoService::start())
} else {
Expand Down