OLD | NEW |
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:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 asyncEnd(); | 166 asyncEnd(); |
167 }); | 167 }); |
168 | 168 |
169 Socket client = await Socket.connect(host, socket2.port); | 169 Socket client = await Socket.connect(host, socket2.port); |
170 await client.close(); | 170 await client.close(); |
171 await client.drain(); | 171 await client.drain(); |
172 | 172 |
173 asyncEnd(); | 173 asyncEnd(); |
174 } | 174 } |
175 | 175 |
176 void main() { | 176 testBindSharedUds(String name) async { |
| 177 var address = new UnixDomainAddress(name); |
| 178 var socket = await ServerSocket.bind(address, 0, shared: true); |
| 179 //Expect.isTrue(socket.port == 0); |
| 180 var socket2 = await ServerSocket.bind(address, 0, shared: true); |
| 181 Expect.equals(socket.address.path, socket2.address.path); |
| 182 //Expect.equals(socket.port, socket2.port); |
| 183 await socket.close(); |
| 184 await socket2.close(); |
| 185 } |
| 186 |
| 187 |
| 188 Future withTempDir(String prefix, void test(Directory dir)) async { |
| 189 var tempDir = Directory.systemTemp.createTempSync(prefix); |
| 190 try { |
| 191 await test(tempDir); |
| 192 } finally { |
| 193 tempDir.deleteSync(recursive: true); |
| 194 } |
| 195 } |
| 196 |
| 197 void main() async { |
177 for (var host in ['127.0.0.1', '::1']) { | 198 for (var host in ['127.0.0.1', '::1']) { |
178 testBindShared(host, false); | 199 testBindShared(host, false); |
179 testBindShared(host, true); | 200 testBindShared(host, true); |
180 | 201 |
181 negTestBindSharedMismatch(host, false); | 202 negTestBindSharedMismatch(host, false); |
182 negTestBindSharedMismatch(host, true); | 203 negTestBindSharedMismatch(host, true); |
183 | 204 |
184 negTestBindV6OnlyMismatch(host, true); | 205 negTestBindV6OnlyMismatch(host, true); |
185 negTestBindV6OnlyMismatch(host, false); | 206 negTestBindV6OnlyMismatch(host, false); |
186 | 207 |
187 testSocketReferenceInteroperability(host); | 208 testSocketReferenceInteroperability(host); |
188 | 209 |
189 testListenCloseListenClose(host); | 210 testListenCloseListenClose(host); |
190 } | 211 } |
191 | 212 |
192 asyncStart(); | 213 asyncStart(); |
193 testBindDifferentAddresses(InternetAddress.ANY_IP_V6, | 214 testBindDifferentAddresses(InternetAddress.ANY_IP_V6, |
194 InternetAddress.ANY_IP_V4, | 215 InternetAddress.ANY_IP_V4, |
195 true, | 216 true, |
196 false).then((_) { | 217 false).then((_) { |
197 testBindDifferentAddresses(InternetAddress.ANY_IP_V4, | 218 testBindDifferentAddresses(InternetAddress.ANY_IP_V4, |
198 InternetAddress.ANY_IP_V6, | 219 InternetAddress.ANY_IP_V6, |
199 false, | 220 false, |
200 true); | 221 true); |
201 asyncEnd(); | 222 asyncEnd(); |
202 }); | 223 }); |
| 224 |
| 225 // Don't run the Unix domain socket tests on Windows. |
| 226 if (!Platform.isWindows) { |
| 227 asyncStart(); |
| 228 await withTempDir('socket_bind_test', (Directory dir) async { |
| 229 await testBindSharedUds('${dir.path}/xxx'); |
| 230 }); |
| 231 asyncEnd(); |
| 232 } |
203 } | 233 } |
OLD | NEW |