Skip to content

Commit 5440cc2

Browse files
authored
Merge pull request #1618 from kraxel/net-test
snp network test fixes
2 parents 8da2acf + 36a4935 commit 5440cc2

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

Diff for: uefi-test-runner/src/proto/network/snp.rs

+26-16
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ pub fn test() {
1717
let simple_network = simple_network.unwrap();
1818

1919
// Check shutdown
20-
simple_network
21-
.shutdown()
22-
.expect("Failed to shutdown Simple Network");
20+
let res = simple_network.shutdown();
21+
assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into()));
2322

2423
// Check stop
25-
simple_network
26-
.stop()
27-
.expect("Failed to stop Simple Network");
24+
let res = simple_network.stop();
25+
assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into()));
2826

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

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

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

4445
// Set receive filters
4546
simple_network
4647
.receive_filters(
47-
ReceiveFlags::UNICAST | ReceiveFlags::MULTICAST | ReceiveFlags::BROADCAST,
48+
ReceiveFlags::UNICAST | ReceiveFlags::BROADCAST,
4849
ReceiveFlags::empty(),
4950
false,
5051
None,
@@ -113,13 +114,22 @@ pub fn test() {
113114
assert_eq!(buffer[42..47], [4, 4, 3, 2, 1]);
114115

115116
// Get stats
116-
let stats = simple_network
117-
.collect_statistics()
118-
.expect("Failed to collect statistics");
119-
info!("Stats: {:?}", stats);
120-
121-
// One frame should have been transmitted and one received
122-
assert_eq!(stats.tx_total_frames().unwrap(), 1);
123-
assert_eq!(stats.rx_total_frames().unwrap(), 1);
117+
let res = simple_network.collect_statistics();
118+
match res {
119+
Ok(stats) => {
120+
info!("Stats: {:?}", stats);
121+
122+
// One frame should have been transmitted and one received
123+
assert_eq!(stats.tx_total_frames().unwrap(), 1);
124+
assert_eq!(stats.rx_total_frames().unwrap(), 1);
125+
}
126+
Err(e) => {
127+
if e == Status::UNSUPPORTED.into() {
128+
info!("Stats: unsupported.");
129+
} else {
130+
panic!("{e}");
131+
}
132+
}
133+
}
124134
}
125135
}

Diff for: xtask/src/main.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,8 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
153153
features.push(Feature::DebugSupport);
154154
}
155155

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

Diff for: xtask/src/qemu.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,10 @@ pub fn run_qemu(arch: UefiArch, opt: &QemuOpt) -> Result<()> {
503503
// examples since it slows down the boot some.
504504
let echo_service = if !opt.disable_network && opt.example.is_none() {
505505
cmd.args([
506-
"-nic",
507-
"user,model=e1000,net=192.168.17.0/24,tftp=uefi-test-runner/tftp/,bootfile=fake-boot-file",
506+
"-netdev",
507+
"user,id=net0,net=192.168.17.0/24,tftp=uefi-test-runner/tftp/,bootfile=fake-boot-file",
508+
"-device",
509+
"virtio-net-pci,netdev=net0",
508510
]);
509511
Some(net::EchoService::start())
510512
} else {

0 commit comments

Comments
 (0)