Index: net/socket/unix_domain_client_socket_posix_unittest.cc |
diff --git a/net/socket/unix_domain_client_socket_posix_unittest.cc b/net/socket/unix_domain_client_socket_posix_unittest.cc |
index ff15246d8e13f604197dbce5eda2b6be5303c5da..17ab220fe393ece02a5299ec178a30738cffea08 100644 |
--- a/net/socket/unix_domain_client_socket_posix_unittest.cc |
+++ b/net/socket/unix_domain_client_socket_posix_unittest.cc |
@@ -10,6 +10,7 @@ |
#include "base/files/file_path.h" |
#include "base/files/scoped_temp_dir.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/posix/eintr_wrapper.h" |
#include "net/base/io_buffer.h" |
#include "net/base/net_errors.h" |
#include "net/base/test_completion_callback.h" |
@@ -148,6 +149,38 @@ TEST_F(UnixDomainClientSocketTest, Connect) { |
EXPECT_TRUE(accepted_socket->IsConnected()); |
} |
+TEST_F(UnixDomainClientSocketTest, ConnectWithSocketDescriptor) { |
+ const bool kUseAbstractNamespace = false; |
+ |
+ UnixDomainServerSocket server_socket(CreateAuthCallback(true), |
+ kUseAbstractNamespace); |
+ EXPECT_EQ(OK, server_socket.ListenWithAddressAndPort(socket_path_, 0, 1)); |
+ |
+ SocketDescriptor accepted_socket_fd = kInvalidSocket; |
+ TestCompletionCallback accept_callback; |
+ EXPECT_EQ(ERR_IO_PENDING, |
+ server_socket.AcceptSocketDescriptor(&accepted_socket_fd, |
+ accept_callback.callback())); |
+ EXPECT_EQ(kInvalidSocket, accepted_socket_fd); |
+ |
+ UnixDomainClientSocket client_socket(socket_path_, kUseAbstractNamespace); |
+ EXPECT_FALSE(client_socket.IsConnected()); |
+ |
+ EXPECT_EQ(OK, ConnectSynchronously(&client_socket)); |
+ EXPECT_TRUE(client_socket.IsConnected()); |
+ // Server has not yet been notified of the connection. |
+ EXPECT_EQ(kInvalidSocket, accepted_socket_fd); |
+ |
+ EXPECT_EQ(OK, accept_callback.WaitForResult()); |
+ EXPECT_NE(kInvalidSocket, accepted_socket_fd); |
+ |
+ SocketDescriptor client_socket_fd = client_socket.ReleaseSocketDescriptor(); |
mmenke
2014/09/03 14:56:46
Can we wrap this in a UnixDomainClientSocket (And
Chris Masone
2014/09/03 15:03:40
TclClientSocketLibEvent? This is the wrong kind of
Chris Masone
2014/09/03 15:57:12
Ok, I've done a read() and made sure I got ERR_IO_
|
+ EXPECT_NE(kInvalidSocket, client_socket_fd); |
+ |
+ EXPECT_EQ(0, IGNORE_EINTR(close(accepted_socket_fd))); |
+ EXPECT_EQ(0, IGNORE_EINTR(close(client_socket_fd))); |
+} |
+ |
TEST_F(UnixDomainClientSocketTest, ConnectWithAbstractNamespace) { |
const bool kUseAbstractNamespace = true; |