Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1279)

Unified Diff: tests/standalone/io/socket_bind_test.dart

Issue 2014893002: Fix a flaky failure in socket_bind_test. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698