Harden and re-enable DualMode socket tests (#80715)
authorAnton Firszov <antonfir@gmail.com>
Tue, 7 Feb 2023 17:28:13 +0000 (18:28 +0100)
committerGitHub <noreply@github.com>
Tue, 7 Feb 2023 17:28:13 +0000 (18:28 +0100)
commit5b310646988ccd080897d314e61a3017cee5c8ad
tree939fc0e90ebcf61e6176fe8e4588cf51237dfb51
parentd7bf603064bbbf86e37f70b7ddf44d85f3c31b1d
Harden and re-enable DualMode socket tests (#80715)

- UDP tests are moved to a non-parallel collection, since there is no way to prevent parallel UDP tests from intercepting each other's packets. This only increases the execution time by ~2 seconds.
- TCP interferences are prevented by a utility PortBlocker, which creates and binds a "shadow" socket of the opposite address family to prevent sockets in parallel tests to bind to the same port.
- Accept and SendTo tests are refactored to use SocketTestHelperBase<T>, reducing duplicate code.
src/libraries/Common/tests/System/Net/Sockets/SocketTestExtensions.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/Connect.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/DualModeSocketTest.cs
src/libraries/System.Net.Sockets/tests/FunctionalTests/SendReceive/SendReceive.cs