Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(ipv6): Do not run IPv6 tests if the host doesn't support IPv6 #1059

Merged
merged 2 commits into from
Jun 2, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ jobs:
with:
submodules: recursive

- name: Install nightly
- name: Install Rust 1.67
# See /~https://github.com/cross-rs/cross/issues/1222
uses: dtolnay/rust-toolchain@1.67

Expand Down
3 changes: 3 additions & 0 deletions src/hp/magicsock/rebinding_conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ mod tests {

#[tokio::test]
async fn test_rebinding_conn_send_recv_ipv6() -> Result<()> {
if !crate::hp::netcheck::os_has_ipv6().await {
return Ok(());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a eprintln that this is being skipped? I wish there was a clearer way to communicate this..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an eprinln is also captured by default though, so you won't see this unless the test fails (which won't happen) or you use --nocapture. it's not much of an improvement.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure? asfaik stderr is printed in tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I tested it again. both stdout and stderr are captured in tests and not displayed unless the test fails.

I also wish we had a decent way to write a better test harness in rust, the reporting options are just not enough.

}
rebinding_conn_send_recv(Network::Ipv6).await
}

Expand Down
2 changes: 1 addition & 1 deletion src/hp/netcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ async fn recv_stun_once(sock: &UdpSocket, buf: &mut [u8], actor_addr: &ActorAddr
}

/// Test if IPv6 works at all, or if it's been hard disabled at the OS level.
async fn os_has_ipv6() -> bool {
pub(crate) async fn os_has_ipv6() -> bool {
// TODO: use socket2 to specify binding to ipv6
let udp = UdpSocket::bind("[::1]:0").await;
udp.is_ok()
Expand Down