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

Side by Side Diff: tests/standalone/io/socket_ipv6_test.dart

Issue 2566273007: Fix flaky timeouts of socket_ipv6_test. (Closed)
Patch Set: fix multi-test numbering 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 unified diff | Download patch
« no previous file with comments | « no previous file | tests/standalone/io/test_utils.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:io'; 5 import 'dart:io';
6 6
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import "package:expect/expect.dart"; 8 import "package:expect/expect.dart";
9 import "test_utils.dart" show retrySync;
9 10
10 const ANY = InternetAddressType.ANY; 11 const ANY = InternetAddressType.ANY;
11 12
12 void testIPv6toIPv6() { 13 void testIPv6toIPv6() {
13 asyncStart(); 14 asyncStart();
14 InternetAddress.lookup("::0", type: ANY).then((serverAddr) { 15 InternetAddress.lookup("::0", type: ANY).then((serverAddr) {
15 InternetAddress.lookup("::1", type: ANY).then((clientAddr) { 16 InternetAddress.lookup("::1", type: ANY).then((clientAddr) {
16 ServerSocket.bind(serverAddr.first, 0).then((server) { 17 ServerSocket.bind(serverAddr.first, 0).then((server) {
17 Expect.equals('::0', server.address.host); 18 Expect.equals('::0', server.address.host);
18 Expect.equals('::', server.address.address); 19 Expect.equals('::', server.address.address);
19 server.listen((socket) { 20 server.listen((socket) {
20 socket.destroy(); 21 socket.destroy();
21 server.close(); 22 server.close();
22 asyncEnd(); 23 asyncEnd();
23 }); 24 });
24 Socket.connect(clientAddr.first, server.port).then((socket) { 25 Socket.connect(clientAddr.first, server.port).then((socket) {
25 socket.destroy(); 26 socket.destroy();
26 }); 27 });
27 }); 28 });
28 }); 29 });
29 }); 30 });
30 } 31 }
31 32
32 void testIPv4toIPv6() { 33 void testIPv4toIPv6() {
33 asyncStart(); 34 asyncStart();
34 InternetAddress.lookup("::0", type: ANY).then((serverAddr) { 35 InternetAddress.lookup("::0", type: ANY).then((serverAddr) {
35 ServerSocket.bind(serverAddr.first, 0).then((server) { 36 ServerSocket.bind(serverAddr.first, 0).then((server) {
36 Expect.equals('::0', server.address.host); 37 Expect.equals('::0', server.address.host);
37 Expect.equals('::', server.address.address); 38 Expect.equals('::', server.address.address);
38 server.listen((socket) { 39 server.listen((socket) {
39 socket.destroy(); 40 socket.destroy();
40 server.close(); 41 server.close();
41 asyncEnd(); 42 asyncEnd();
42 }); 43 });
43 Socket.connect("127.0.0.1", server.port).then((socket) { 44 Socket.connect("127.0.0.1", server.port).then((socket) {
44 socket.destroy(); 45 socket.destroy();
45 }); 46 });
46 }); 47 });
47 }); 48 });
48 } 49 }
49 50
50 void testIPv6toIPv4() { 51 void testIPv6toIPv4() {
51 asyncStart(); 52 asyncStart();
52 InternetAddress.lookup("::1", type: ANY).then((clientAddr) { 53 InternetAddress.lookup("::1", type: ANY).then((clientAddr) {
53 ServerSocket.bind("127.0.0.1", 0).then((server) { 54 ServerSocket.bind("127.0.0.1", 0).then((server) {
54 Expect.equals('127.0.0.1', server.address.host); 55 Expect.equals('127.0.0.1', server.address.host);
55 Expect.equals('127.0.0.1', server.address.address); 56 Expect.equals('127.0.0.1', server.address.address);
56 server.listen((socket) { 57 server.listen((socket) {
57 throw "Unexpected socket"; 58 throw "Unexpected socket";
58 }); 59 });
59 Socket.connect(clientAddr.first, server.port).catchError((e) { 60 Socket.connect(clientAddr.first, server.port).then((socket) {
61 socket.destroy();
62 server.close();
63 asyncEnd();
64 throw "Unexpected connect";
kustermann 2016/12/13 21:04:30 This throw will be caught by the next line and sil
Florian Schneider 2016/12/13 22:12:33 Thanks! Does Socket.connect ever throw a String?
kustermann 2016/12/13 22:55:29 I don't think so. It's mostly some [SocketExceptio
65 }).catchError((e) {
60 server.close(); 66 server.close();
61 asyncEnd(); 67 asyncEnd();
62 }); 68 });
63 }); 69 });
64 }); 70 });
65 } 71 }
66 72
67 void testIPv4toIPv4() { 73 void testIPv4toIPv4() {
68 asyncStart(); 74 asyncStart();
69 ServerSocket.bind("127.0.0.1", 0).then((server) { 75 ServerSocket.bind("127.0.0.1", 0).then((server) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 114
109 void testIPv4toIPv6_IPV6Only() { 115 void testIPv4toIPv6_IPV6Only() {
110 asyncStart(); 116 asyncStart();
111 InternetAddress.lookup("::0", type: ANY) 117 InternetAddress.lookup("::0", type: ANY)
112 .then((serverAddr) { 118 .then((serverAddr) {
113 ServerSocket.bind(serverAddr.first, 0, v6Only: true) 119 ServerSocket.bind(serverAddr.first, 0, v6Only: true)
114 .then((server) { 120 .then((server) {
115 server.listen((socket) { 121 server.listen((socket) {
116 throw "Unexpected socket"; 122 throw "Unexpected socket";
117 }); 123 });
118 Socket.connect("127.0.0.1", server.port).catchError((error) { 124 Socket.connect("127.0.0.1", server.port)
119 server.close(); 125 .then((socket) {
120 asyncEnd(); 126 socket.destroy();
121 }); 127 server.close();
128 asyncEnd();
129 throw "Unexpected connect";
130 })
131 .catchError((error) {
132 server.close();
133 asyncEnd();
134 });
kustermann 2016/12/13 21:04:30 same here.
Florian Schneider 2016/12/13 22:12:33 Done. Reformatted here as well to match the other
122 }); 135 });
123 }); 136 });
124 } 137 }
125 138
126 void main() { 139 void main() {
127 testIPv6toIPv6(); /// none: ok 140 testIPv6toIPv6(); /// 01: ok
128 testIPv4toIPv6(); /// 01: ok 141 testIPv4toIPv6(); /// 02: ok
129 testIPv6toIPv4(); /// 02: ok 142 testIPv4toIPv4(); /// 03: ok
130 testIPv4toIPv4(); /// 03: ok 143 testIPv6Lookup(); /// 04: ok
131 testIPv6Lookup(); /// 04: ok 144 testIPv4Lookup(); /// 05: ok
132 testIPv4Lookup(); /// 05: ok
133 145
134 testIPv4toIPv6_IPV6Only(); /// 06: ok 146 retrySync(testIPv6toIPv4); /// 06: ok
147 retrySync(testIPv4toIPv6_IPV6Only); /// 07: ok
kustermann 2016/12/13 21:04:30 You can't use retrySync, because these functions a
Florian Schneider 2016/12/13 22:12:33 Aaah. Async code. The void confusd me. Done. (Str
135 } 148 }
OLDNEW
« no previous file with comments | « no previous file | tests/standalone/io/test_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698