[System.Net.Sockets.Tests] Make UDP SendTo implicit-bind and AccessDenied tests deterministic on mobile/restricted environments #122556
+29
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #120526
Description
This PR addresses failing UDP
SendTotests on Android arm/arm64 and other restricted environments where missing default routes causeNetworkUnreachableerrors, preventing implicit binds.Changes:
Datagram_UDP_ShouldImplicitlyBindLocalEndpoint: Updated to use a loopback UDP endpoint (via new helperCreateLoopbackUdpEndpoint). This ensures the test is self-contained and deterministic, avoiding dependency on external routing.Datagram_UDP_AccessDenied_Throws_DoesNotBind: Updated to acceptSocketError.NetworkUnreachableorSocketError.HostUnreachableon Android, iOS, tvOS, and MacCatalyst. These platforms may fail with unreachable errors beforeAccessDeniedwhen the network is restricted, while still satisfying the test's core requirement that the socket remains unbound.Verification