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

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

Issue 2546733002: Attempt to reduce flakiness rate of io test (Closed)
Patch Set: Created 4 years 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 | « tests/standalone/io/socket_bind_test.dart ('k') | tests/standalone/io/test_utils.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/socket_source_address_test.dart
diff --git a/tests/standalone/io/socket_source_address_test.dart b/tests/standalone/io/socket_source_address_test.dart
index 64dc490bde9ae3a1cf28aca43dc96927559dd90a..4ca8f9d5f98b54b873bf11cba432675352ea77f2 100644
--- a/tests/standalone/io/socket_source_address_test.dart
+++ b/tests/standalone/io/socket_source_address_test.dart
@@ -9,6 +9,8 @@ import "dart:io";
import "package:async_helper/async_helper.dart";
import "package:expect/expect.dart";
+import 'test_utils.dart' show freeIPv4AndIPv6Port;
+
Future throws(Function f, Function check) async {
try {
await f();
@@ -23,9 +25,12 @@ Future throws(Function f, Function check) async {
}
Future testArguments(connectFunction) async {
+ int freePort = await freeIPv4AndIPv6Port();
+
var sourceAddress;
asyncStart();
- var server = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4, 0);
+ var server = await ServerSocket.bind(InternetAddress.LOOPBACK_IP_V4,
+ freePort);
server.listen((_) {
throw 'Unexpected connection from address $sourceAddress';
}, onDone: () => asyncEnd());
@@ -73,6 +78,8 @@ Future testConnect(InternetAddress bindAddress,
bool v6Only,
Function connectFunction,
Function closeDestroyFunction) async {
+ int freePort = await freeIPv4AndIPv6Port();
+
var successCount = 0;
if (!v6Only) successCount += ipV4SourceAddresses.length;
if (bindAddress.type == InternetAddressType.IP_V6) {
@@ -83,7 +90,7 @@ Future testConnect(InternetAddress bindAddress,
if (successCount == 0) allConnected.complete();
asyncStart();
- var server = await ServerSocket.bind(bindAddress, 0, v6Only: v6Only);
+ var server = await ServerSocket.bind(bindAddress, freePort, v6Only: v6Only);
server.listen((s) {
s.destroy();
count++;
« no previous file with comments | « tests/standalone/io/socket_bind_test.dart ('k') | tests/standalone/io/test_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698