diff --git a/uefi-test-runner/src/proto/network/snp.rs b/uefi-test-runner/src/proto/network/snp.rs index 5229ce833..1bdaab20e 100644 --- a/uefi-test-runner/src/proto/network/snp.rs +++ b/uefi-test-runner/src/proto/network/snp.rs @@ -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 @@ -36,7 +34,10 @@ 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(); @@ -44,7 +45,7 @@ pub fn test() { // Set receive filters simple_network .receive_filters( - ReceiveFlags::UNICAST | ReceiveFlags::MULTICAST | ReceiveFlags::BROADCAST, + ReceiveFlags::UNICAST | ReceiveFlags::BROADCAST, ReceiveFlags::empty(), false, None, @@ -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}"); + } + } + } } } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c98dec829..89f61a285 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -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); } diff --git a/xtask/src/qemu.rs b/xtask/src/qemu.rs index ec658a565..d233dd35b 100644 --- a/xtask/src/qemu.rs +++ b/xtask/src/qemu.rs @@ -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 {