OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "net/socket/unix_domain_client_socket_posix.h" | 5 #include "net/socket/unix_domain_client_socket_posix.h" |
6 | 6 |
7 #include <unistd.h> | 7 #include <unistd.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "net/base/io_buffer.h" | 13 #include "net/base/io_buffer.h" |
14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
15 #include "net/base/test_completion_callback.h" | 15 #include "net/base/test_completion_callback.h" |
16 #include "net/socket/unix_domain_server_socket_posix.h" | 16 #include "net/socket/unix_domain_server_socket_posix.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 namespace net { | 19 namespace net { |
20 namespace { | 20 namespace { |
21 | 21 |
22 const char kSocketFilename[] = "socket_for_testing"; | 22 const char kSocketFilename[] = "socket_for_testing"; |
23 | 23 |
24 bool UserCanConnectCallback(bool allow_user, uid_t uid, gid_t gid) { | 24 bool UserCanConnectCallback(bool allow_user, pid_t pid, uid_t uid, gid_t gid) { |
25 // Here peers are running in same process. | 25 // Here peers are running in same process. |
| 26 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 27 EXPECT_EQ(getpid(), pid); |
| 28 #else |
| 29 EXPECT_EQ(0, pid); |
| 30 #endif |
26 EXPECT_EQ(getuid(), uid); | 31 EXPECT_EQ(getuid(), uid); |
27 EXPECT_EQ(getgid(), gid); | 32 EXPECT_EQ(getgid(), gid); |
28 return allow_user; | 33 return allow_user; |
29 } | 34 } |
30 | 35 |
31 UnixDomainServerSocket::AuthCallback CreateAuthCallback(bool allow_user) { | 36 UnixDomainServerSocket::AuthCallback CreateAuthCallback(bool allow_user) { |
32 return base::Bind(&UserCanConnectCallback, allow_user); | 37 return base::Bind(&UserCanConnectCallback, allow_user); |
33 } | 38 } |
34 | 39 |
35 // Connects socket synchronously. | 40 // Connects socket synchronously. |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 0)); | 393 0)); |
389 | 394 |
390 // Disconnect from server side after read-write. | 395 // Disconnect from server side after read-write. |
391 accepted_socket->Disconnect(); | 396 accepted_socket->Disconnect(); |
392 EXPECT_FALSE(accepted_socket->IsConnected()); | 397 EXPECT_FALSE(accepted_socket->IsConnected()); |
393 EXPECT_FALSE(client_socket.IsConnected()); | 398 EXPECT_FALSE(client_socket.IsConnected()); |
394 } | 399 } |
395 | 400 |
396 } // namespace | 401 } // namespace |
397 } // namespace net | 402 } // namespace net |
OLD | NEW |