OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // These tests are POSIX only. | 5 // These tests are POSIX only. |
6 | 6 |
7 #include "ipc/ipc_channel_posix.h" | 7 #include "ipc/ipc_channel_posix.h" |
8 | 8 |
9 #include <fcntl.h> | 9 #include <fcntl.h> |
10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 DCHECK_EQ(static_cast<int>(name.length()), path_len); | 152 DCHECK_EQ(static_cast<int>(name.length()), path_len); |
153 size_t server_address_len = offsetof(struct sockaddr_un, | 153 size_t server_address_len = offsetof(struct sockaddr_un, |
154 sun_path) + path_len + 1; | 154 sun_path) + path_len + 1; |
155 | 155 |
156 if (mode == IPC::Channel::MODE_NAMED_SERVER) { | 156 if (mode == IPC::Channel::MODE_NAMED_SERVER) { |
157 // Only one server at a time. Cleanup garbage if it exists. | 157 // Only one server at a time. Cleanup garbage if it exists. |
158 unlink(name.c_str()); | 158 unlink(name.c_str()); |
159 // Make sure the path we need exists. | 159 // Make sure the path we need exists. |
160 base::FilePath path(name); | 160 base::FilePath path(name); |
161 base::FilePath dir_path = path.DirName(); | 161 base::FilePath dir_path = path.DirName(); |
162 ASSERT_TRUE(file_util::CreateDirectory(dir_path)); | 162 ASSERT_TRUE(base::CreateDirectory(dir_path)); |
163 ASSERT_GE(bind(socket_fd, | 163 ASSERT_GE(bind(socket_fd, |
164 reinterpret_cast<struct sockaddr *>(&server_address), | 164 reinterpret_cast<struct sockaddr *>(&server_address), |
165 server_address_len), 0) << server_address.sun_path | 165 server_address_len), 0) << server_address.sun_path |
166 << ": " << strerror(errno) | 166 << ": " << strerror(errno) |
167 << "(" << errno << ")"; | 167 << "(" << errno << ")"; |
168 ASSERT_GE(listen(socket_fd, SOMAXCONN), 0) << server_address.sun_path | 168 ASSERT_GE(listen(socket_fd, SOMAXCONN), 0) << server_address.sun_path |
169 << ": " << strerror(errno) | 169 << ": " << strerror(errno) |
170 << "(" << errno << ")"; | 170 << "(" << errno << ")"; |
171 } else if (mode == IPC::Channel::MODE_NAMED_CLIENT) { | 171 } else if (mode == IPC::Channel::MODE_NAMED_CLIENT) { |
172 ASSERT_GE(connect(socket_fd, | 172 ASSERT_GE(connect(socket_fd, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 if (connected) { | 417 if (connected) { |
418 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout()); | 418 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout()); |
419 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); | 419 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); |
420 } else { | 420 } else { |
421 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); | 421 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); |
422 } | 422 } |
423 return 0; | 423 return 0; |
424 } | 424 } |
425 | 425 |
426 } // namespace | 426 } // namespace |
OLD | NEW |