Skip to content

Commit 85bb20c

Browse files
committed
uefi-test-runner: SNP: improve idempotence of test
snp::test() can now be called multiple times in a row
1 parent ada5df4 commit 85bb20c

File tree

1 file changed

+9
-8
lines changed
  • uefi-test-runner/src/proto/network

1 file changed

+9
-8
lines changed

uefi-test-runner/src/proto/network/snp.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use uefi::boot::ScopedProtocol;
66
use uefi::proto::network::MacAddress;
77
use uefi::proto::network::snp::{InterruptStatus, ReceiveFlags, SimpleNetwork};
88
use uefi::{Status, boot};
9+
use uefi_raw::protocol::network::snp::NetworkState;
910

1011
/// The MAC address configured for the interface.
1112
const EXPECTED_MAC: [u8; 6] = [0x52, 0x54, 0, 0, 0, 0x1];
@@ -63,15 +64,12 @@ pub fn test() {
6364
EXPECTED_MAC[5]
6465
));
6566

66-
// Check shutdown
67-
let res = simple_network.shutdown();
68-
assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into()));
69-
70-
// Check stop
71-
let res = simple_network.stop();
72-
assert!(res == Ok(()) || res == Err(Status::NOT_STARTED.into()));
67+
assert_eq!(
68+
simple_network.mode().state,
69+
NetworkState::STOPPED,
70+
"Should be in stopped state"
71+
);
7372

74-
// Check start
7573
simple_network
7674
.start()
7775
.expect("Failed to start Simple Network");
@@ -181,4 +179,7 @@ pub fn test() {
181179
}
182180
}
183181
}
182+
183+
simple_network.stop().unwrap();
184+
simple_network.shutdown().unwrap();
184185
}

0 commit comments

Comments
 (0)