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

Ensure tcp test case passes when disconnected from network #44647

Merged
merged 1 commit into from
Sep 17, 2017

Conversation

tmerr
Copy link
Contributor

@tmerr tmerr commented Sep 17, 2017

net::tcp::tests::connect_timeout_unroutable fails when the network
is unreachable, like on a laptop disconnected from wifi. Check for
this error and allow the test to pass.

Closes #44645

net::tcp::tests::connect_timeout_unroutable fails when the network
is unreachable, like on a laptop disconnected from wifi. Check for
this error and allow the test to pass.

Closes rust-lang#44645
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks! Is there any way to tell that the Other case corresponds to the network being unreachable? Is there a consistent error message across platforms or anything else we could check here?

@tmerr
Copy link
Contributor Author

tmerr commented Sep 17, 2017

A few ideas

  • Make the test include a platform-dependent comparison against error.raw_os_error(). Check for libc::ENETUNREACH on POSIX and I guess a hard coded 10051 representing WSAENETUNREACH on Windows.
  • Compare error.description() == "Network is unreachable". But can this be relied on?
  • Add an ErrorKind::NetworkUnreachable for this error

The first 2 ideas seem a little sketchy to me, and I am guessing the 3rd would need an RFC, but I am out of my depth here so any advice is appreciated!

@dtolnay
Copy link
Member

dtolnay commented Sep 17, 2017

Let's go ahead with your fix -- requiring network access for the test suite to succeed seems like an oversight.

The risk here is that at some point we mess up connect_timeout so that it always returns some wrong Other error code instead of timing out, and we fail to notice. That seems unlikely and minor enough that merging your fix is more important.

If you do want to follow up with another PR to improve the test, any of your 3 ideas sounds good to me. I believe we could do the 3rd one without a formal RFC. The variant would have an #[unstable] attribute when it is added, be unstable for a couple releases, and the libs team would discuss before eventually stabilizing it. The first 2 ideas are fine too and it wouldn't need to be super thorough. Just two different asserts for #[cfg(unix)] and #[cfg(not(unix))] would be decent, where unix looks for ENETUNREACH and not-unix just accepts any Other error like in the current code.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 17, 2017

📌 Commit fcdd46e has been approved by dtolnay

TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
Ensure tcp test case passes when disconnected from network

net::tcp::tests::connect_timeout_unroutable fails when the network
is unreachable, like on a laptop disconnected from wifi. Check for
this error and allow the test to pass.

Closes rust-lang#44645
TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
Ensure tcp test case passes when disconnected from network

net::tcp::tests::connect_timeout_unroutable fails when the network
is unreachable, like on a laptop disconnected from wifi. Check for
this error and allow the test to pass.

Closes rust-lang#44645
TimNN added a commit to TimNN/rust that referenced this pull request Sep 17, 2017
Ensure tcp test case passes when disconnected from network

net::tcp::tests::connect_timeout_unroutable fails when the network
is unreachable, like on a laptop disconnected from wifi. Check for
this error and allow the test to pass.

Closes rust-lang#44645
bors added a commit that referenced this pull request Sep 17, 2017
Rollup of 17 pull requests

- Successful merges: #44073, #44088, #44381, #44397, #44509, #44533, #44549, #44553, #44562, #44567, #44595, #44604, #44617, #44622, #44630, #44639, #44647
- Failed merges:
@bors bors merged commit fcdd46e into rust-lang:master Sep 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants