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

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

Issue 1293533002: DO NOT SUBMIT: Unix domain sockets. From CL 1061283003. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Added Mac OS fix Created 5 years, 4 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 | « tests/standalone/io/socket_bind_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/socket_info_test.dart
diff --git a/tests/standalone/io/socket_info_test.dart b/tests/standalone/io/socket_info_test.dart
index eb14246bc618a35db6cad794d2fe5c205bc553be..930ec94b0833b67757aa83f5e6fea9a5176e1805 100644
--- a/tests/standalone/io/socket_info_test.dart
+++ b/tests/standalone/io/socket_info_test.dart
@@ -2,10 +2,13 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import "package:expect/expect.dart";
import "dart:io";
+import 'package:async_helper/async_helper.dart';
+import "package:expect/expect.dart";
+
void testHostAndPort() {
+ asyncStart();
ServerSocket.bind("127.0.0.1", 0).then((server) {
Socket.connect("127.0.0.1", server.port).then((clientSocket) {
@@ -18,11 +21,44 @@ void testHostAndPort() {
socket.destroy();
clientSocket.destroy();
server.close();
+ asyncEnd();
});
});
});
}
+void withTempDir(String prefix, void test(Directory dir)) async {
+ var tempDir = Directory.systemTemp.createTempSync(prefix);
+ try {
+ await test(tempDir);
+ } finally {
+ tempDir.deleteSync(recursive: true);
+ }
+}
+
+Future testHostAndPortUds(Directory dir) async {
+ asyncStart();
+ var address = new UnixDomainAddress('${dir.path}/xxx');
+ var server = await ServerSocket.bind(address, 0);
+ var client = await Socket.connect(address, server.port);
+ server.listen((socket) {
+ Expect.equals(socket.port, 1);
+ Expect.equals(socket.port, server.port);
+ Expect.equals(client.port, socket.remotePort);
+ Expect.equals(client.remotePort, socket.port);
+ Expect.isTrue(socket.remoteAddress is UnixDomainAddress);
+ Expect.equals(socket.remoteAddress.path, '.');
+ Expect.equals(client.remoteAddress.path, address.path);
+ socket.destroy();
+ client.destroy();
+ server.close();
+ asyncEnd();
+ });
+}
+
void main() {
testHostAndPort();
+ if (!Platform.isWindows) {
+ withTempDir('socket_info_test', testHostAndPortUds);
+ }
}
« no previous file with comments | « tests/standalone/io/socket_bind_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698