Index: tests/standalone/io/socket_bind_test.dart |
diff --git a/tests/standalone/io/socket_bind_test.dart b/tests/standalone/io/socket_bind_test.dart |
index 9c4e1ed284e29db1cf177d5679a1a772e96c1210..c764f6ec40ce42b41d7d2017a7f7feaf061f1ac8 100644 |
--- a/tests/standalone/io/socket_bind_test.dart |
+++ b/tests/standalone/io/socket_bind_test.dart |
@@ -63,15 +63,17 @@ negTestBindV6OnlyMismatch(String host, bool v6Only) { |
Future testBindDifferentAddresses(InternetAddress addr1, |
InternetAddress addr2, |
bool addr1V6Only, |
- bool addr2V6Only) { |
+ bool addr2V6Only) async { |
+ int freePort = await freeIPv4AndIPv6Port(); |
+ |
asyncStart(); |
return ServerSocket.bind( |
- addr1, 0, v6Only: addr1V6Only, shared: false).then((socket) { |
+ addr1, freePort, v6Only: addr1V6Only, shared: false).then((socket) { |
Expect.isTrue(socket.port > 0); |
asyncStart(); |
return ServerSocket.bind( |
- addr2, socket.port, v6Only: addr2V6Only, shared: false).then((socket2) { |
+ addr2, freePort, v6Only: addr2V6Only, shared: false).then((socket2) { |
Expect.equals(socket.port, socket2.port); |
return Future.wait([ |
@@ -110,7 +112,24 @@ testListenCloseListenClose(String host) async { |
asyncEnd(); |
} |
-void main() { |
+Future<int> freeIPv4AndIPv6Port() async { |
+ var socket = await ServerSocket.bind(InternetAddress.ANY_IP_V6, 0, v6Only: false); |
kustermann
2016/05/26 16:56:27
long line
|
+ int port = socket.port; |
+ await socket.close(); |
+ return port; |
+} |
+ |
+void main() async { |
+ asyncStart(); |
+ await testBindDifferentAddresses(InternetAddress.ANY_IP_V6, |
+ InternetAddress.ANY_IP_V4, |
+ true, |
+ false); |
+ await testBindDifferentAddresses(InternetAddress.ANY_IP_V4, |
+ InternetAddress.ANY_IP_V6, |
+ false, |
+ true); |
+ |
for (var host in ['127.0.0.1', '::1']) { |
testBindShared(host, false); |
testBindShared(host, true); |
@@ -123,16 +142,5 @@ void main() { |
testListenCloseListenClose(host); |
} |
- |
- asyncStart(); |
- testBindDifferentAddresses(InternetAddress.ANY_IP_V6, |
- InternetAddress.ANY_IP_V4, |
- true, |
- false).then((_) { |
- testBindDifferentAddresses(InternetAddress.ANY_IP_V4, |
- InternetAddress.ANY_IP_V6, |
- false, |
- true); |
- asyncEnd(); |
- }); |
+ asyncEnd(); |
} |