Chromium Code Reviews

Unified Diff: net/socket/unix_domain_socket_posix_unittest.cc

Issue 16093005: [Android] Use a "unique" remote debugging socket name on bind failure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « net/socket/unix_domain_socket_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/unix_domain_socket_posix_unittest.cc
diff --git a/net/socket/unix_domain_socket_posix_unittest.cc b/net/socket/unix_domain_socket_posix_unittest.cc
index ed0b01891833090031f3ee7fcc827cd71df335ea..6ee1154d836e9001d56877a6b072b9e317afb0fa 100644
--- a/net/socket/unix_domain_socket_posix_unittest.cc
+++ b/net/socket/unix_domain_socket_posix_unittest.cc
@@ -39,6 +39,7 @@ namespace net {
namespace {
const char kSocketFilename[] = "unix_domain_socket_for_testing";
+const char kFallbackSocketName[] = "unix_domain_socket_for_testing_2";
const char kInvalidSocketPath[] = "/invalid/path";
const char kMsg[] = "hello";
@@ -254,9 +255,29 @@ TEST_F(UnixDomainSocketTestWithInvalidPath, CreateAndListenWithInvalidPath) {
TEST_F(UnixDomainSocketTestWithInvalidPath,
CreateAndListenWithAbstractNamespace) {
socket_ = UnixDomainSocket::CreateAndListenWithAbstractNamespace(
- file_path_.value(), socket_delegate_.get(), MakeAuthCallback());
+ file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
EXPECT_FALSE(socket_.get() == NULL);
}
+
+TEST_F(UnixDomainSocketTest, TestFallbackName) {
+ scoped_refptr<UnixDomainSocket> existing_socket =
+ UnixDomainSocket::CreateAndListenWithAbstractNamespace(
+ kSocketFilename, "", socket_delegate_.get(), MakeAuthCallback());
szym 2013/05/29 18:49:04 Do not use kSocketFilename alone. Use MakeSocketPa
mnaganov (inactive) 2013/05/29 20:11:11 But that's for abstract namespace names only. Is f
szym 2013/05/29 20:13:53 The concern is interference with other tests runni
mnaganov (inactive) 2013/05/29 20:37:11 Makes sense. Fixed!
+ EXPECT_FALSE(existing_socket.get() == NULL);
+ // First, try to bind socket with the same name with no fallback name.
+ socket_ =
+ UnixDomainSocket::CreateAndListenWithAbstractNamespace(
+ kSocketFilename, "", socket_delegate_.get(), MakeAuthCallback());
+ EXPECT_TRUE(socket_.get() == NULL);
+ // Now with a fallback name.
+ socket_ = UnixDomainSocket::CreateAndListenWithAbstractNamespace(
+ kSocketFilename,
+ kFallbackSocketName,
+ socket_delegate_.get(),
+ MakeAuthCallback());
+ EXPECT_FALSE(socket_.get() == NULL);
+ existing_socket = NULL;
+}
#endif
TEST_F(UnixDomainSocketTest, TestWithClient) {
« no previous file with comments | « net/socket/unix_domain_socket_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine