@@ -10,7 +10,7 @@ import "dart:io";
10
10
11
11
import 'test_utils.dart' show retry, throws, withTempDir;
12
12
13
- Future testArguments (connectFunction, String socketDir ) async {
13
+ Future testArguments (connectFunction) async {
14
14
var sourceAddress;
15
15
final serverIPv4 = await ServerSocket .bind (InternetAddress .loopbackIPv4, 0 );
16
16
serverIPv4.listen ((_) {
@@ -22,12 +22,6 @@ Future testArguments(connectFunction, String socketDir) async {
22
22
throw 'Unexpected connection from address $sourceAddress ' ;
23
23
});
24
24
25
- ServerSocket serverUnix = await ServerSocket .bind (
26
- InternetAddress ('$socketDir /sock' , type: InternetAddressType .unix), 0 );
27
- serverUnix.listen ((_) {
28
- throw 'Unexpected connection from address $sourceAddress ' ;
29
- });
30
-
31
25
// Illegal type for sourceAddress.
32
26
for (sourceAddress in ['www.google.com' , 'abc' ]) {
33
27
await throws (
@@ -48,7 +42,7 @@ Future testArguments(connectFunction, String socketDir) async {
48
42
for (sourceAddress in [
49
43
'::1' ,
50
44
InternetAddress .loopbackIPv6,
51
- InternetAddress ('$ socketDir / sock' , type: InternetAddressType .unix)
45
+ InternetAddress ('sock' , type: InternetAddressType .unix)
52
46
]) {
53
47
await throws (
54
48
() => connectFunction ('127.0.0.1' , serverIPv4.port,
@@ -59,13 +53,26 @@ Future testArguments(connectFunction, String socketDir) async {
59
53
for (sourceAddress in [
60
54
'127.0.0.1' ,
61
55
InternetAddress .loopbackIPv4,
62
- InternetAddress ('$ socketDir / sock' , type: InternetAddressType .unix)
56
+ InternetAddress ('sock' , type: InternetAddressType .unix)
63
57
]) {
64
58
await throws (
65
59
() => connectFunction ('::1' , serverIPv6.port,
66
60
sourceAddress: sourceAddress),
67
61
(e) => e is SocketException );
68
62
}
63
+
64
+ await serverIPv4.close ();
65
+ await serverIPv6.close ();
66
+ }
67
+
68
+ Future testUnixDomainArguments (connectFunction, String socketDir) async {
69
+ var sourceAddress;
70
+ final serverUnix = await ServerSocket .bind (
71
+ InternetAddress ('$socketDir /sock' , type: InternetAddressType .unix), 0 );
72
+ serverUnix.listen ((_) {
73
+ throw 'Unexpected connection from address $sourceAddress ' ;
74
+ });
75
+
69
76
// Address family mismatch for Unix domain sockets.
70
77
for (sourceAddress in [
71
78
'127.0.0.1' ,
@@ -82,8 +89,6 @@ Future testArguments(connectFunction, String socketDir) async {
82
89
e is SocketException &&
83
90
e.toString ().contains ('Address family not supported' ));
84
91
}
85
- await serverIPv4.close ();
86
- await serverIPv6.close ();
87
92
await serverUnix.close ();
88
93
}
89
94
@@ -158,16 +163,24 @@ Future testConnect(InternetAddress bindAddress, bool v6Only,
158
163
159
164
main () async {
160
165
await retry (() async {
161
- await withTempDir ('unix_socket_test' , (Directory dir) async {
162
- await testArguments (RawSocket .connect, "${dir .path }" );
163
- });
166
+ await testArguments (RawSocket .connect);
164
167
});
165
168
await retry (() async {
166
- await withTempDir ('unix_socket_test' , (Directory dir) async {
167
- await testArguments (Socket .connect, "${dir .path }" );
168
- });
169
+ await testArguments (Socket .connect);
169
170
});
170
171
172
+ if (Platform .isMacOS || Platform .isLinux || Platform .isAndroid) {
173
+ await retry (() async {
174
+ await withTempDir ('unix_socket_test' , (Directory dir) async {
175
+ await testUnixDomainArguments (RawSocket .connect, "${dir .path }" );
176
+ });
177
+ });
178
+ await retry (() async {
179
+ await withTempDir ('unix_socket_test' , (Directory dir) async {
180
+ await testUnixDomainArguments (Socket .connect, "${dir .path }" );
181
+ });
182
+ });
183
+ }
171
184
await retry (() async {
172
185
await testConnect (
173
186
InternetAddress .anyIPv4, false , RawSocket .connect, (s) => s.close ());
0 commit comments