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

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: Always use socket names from MakeSocketPath Created 7 years, 7 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 | « 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..f49e6830c557cedc1e950202e601fdc32c248fac 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";
@@ -51,10 +52,14 @@ enum EventType {
EVENT_READ,
};
-string MakeSocketPath() {
+string MakeSocketPath(const string& socket_file_name) {
base::FilePath temp_dir;
file_util::GetTempDir(&temp_dir);
- return temp_dir.Append(kSocketFilename).value();
+ return temp_dir.Append(socket_file_name).value();
+}
+
+string MakeSocketPath() {
+ return MakeSocketPath(kSocketFilename);
}
class EventManager : public base::RefCounted<EventManager> {
@@ -254,8 +259,28 @@ 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(
+ file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
+ EXPECT_FALSE(existing_socket.get() == NULL);
+ // First, try to bind socket with the same name with no fallback name.
+ socket_ =
+ UnixDomainSocket::CreateAndListenWithAbstractNamespace(
+ file_path_.value(), "", socket_delegate_.get(), MakeAuthCallback());
+ EXPECT_TRUE(socket_.get() == NULL);
+ // Now with a fallback name.
+ socket_ = UnixDomainSocket::CreateAndListenWithAbstractNamespace(
+ file_path_.value(),
+ MakeSocketPath(kFallbackSocketName),
+ socket_delegate_.get(),
+ MakeAuthCallback());
EXPECT_FALSE(socket_.get() == NULL);
+ existing_socket = NULL;
}
#endif
« 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
This is Rietveld 408576698