OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #elif defined(OS_POSIX) | 9 #elif defined(OS_POSIX) |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 #endif | 12 #endif |
13 | 13 |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 #include <string> | 15 #include <string> |
| 16 #include <utility> |
16 | 17 |
17 #include "ipc/ipc_tests.h" | 18 #include "ipc/ipc_tests.h" |
18 | 19 |
19 #include "base/at_exit.h" | 20 #include "base/at_exit.h" |
20 #include "base/base_switches.h" | 21 #include "base/base_switches.h" |
21 #include "base/command_line.h" | 22 #include "base/command_line.h" |
22 #include "base/debug_on_start.h" | 23 #include "base/debug_on_start.h" |
23 #if defined(OS_POSIX) | |
24 #include "base/at_exit.h" | |
25 #include "base/global_descriptors_posix.h" | |
26 #endif | |
27 #include "base/perftimer.h" | 24 #include "base/perftimer.h" |
28 #include "base/test/perf_test_suite.h" | 25 #include "base/test/perf_test_suite.h" |
29 #include "base/test/test_suite.h" | 26 #include "base/test/test_suite.h" |
30 #include "base/thread.h" | 27 #include "base/thread.h" |
31 #include "ipc/ipc_descriptors.h" | 28 #include "ipc/ipc_descriptors.h" |
32 #include "ipc/ipc_channel.h" | 29 #include "ipc/ipc_channel.h" |
33 #include "ipc/ipc_channel_proxy.h" | 30 #include "ipc/ipc_channel_proxy.h" |
34 #include "ipc/ipc_message_utils.h" | 31 #include "ipc/ipc_message_utils.h" |
35 #include "ipc/ipc_switches.h" | 32 #include "ipc/ipc_switches.h" |
36 #include "testing/multiprocess_func_list.h" | 33 #include "testing/multiprocess_func_list.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 #elif defined(OS_POSIX) | 86 #elif defined(OS_POSIX) |
90 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type, | 87 base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type, |
91 IPC::Channel *channel) { | 88 IPC::Channel *channel) { |
92 // kDebugChildren support. | 89 // kDebugChildren support. |
93 bool debug_on_start = | 90 bool debug_on_start = |
94 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren); | 91 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren); |
95 | 92 |
96 base::file_handle_mapping_vector fds_to_map; | 93 base::file_handle_mapping_vector fds_to_map; |
97 const int ipcfd = channel->GetClientFileDescriptor(); | 94 const int ipcfd = channel->GetClientFileDescriptor(); |
98 if (ipcfd > -1) { | 95 if (ipcfd > -1) { |
99 fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3)); | 96 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); |
100 } | 97 } |
101 | 98 |
102 base::ProcessHandle ret = NULL; | 99 base::ProcessHandle ret = NULL; |
103 switch (child_type) { | 100 switch (child_type) { |
104 case TEST_CLIENT: | 101 case TEST_CLIENT: |
105 ret = MultiProcessTest::SpawnChild(L"RunTestClient", | 102 ret = MultiProcessTest::SpawnChild(L"RunTestClient", |
106 fds_to_map, | 103 fds_to_map, |
107 debug_on_start); | 104 debug_on_start); |
108 break; | 105 break; |
109 case TEST_DESCRIPTOR_CLIENT: | 106 case TEST_DESCRIPTOR_CLIENT: |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 channel_listener.Init(&chan); | 261 channel_listener.Init(&chan); |
265 | 262 |
266 #if defined(OS_WIN) | 263 #if defined(OS_WIN) |
267 base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL); | 264 base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, NULL); |
268 #elif defined(OS_POSIX) | 265 #elif defined(OS_POSIX) |
269 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( | 266 bool debug_on_start = CommandLine::ForCurrentProcess()->HasSwitch( |
270 switches::kDebugChildren); | 267 switches::kDebugChildren); |
271 base::file_handle_mapping_vector fds_to_map; | 268 base::file_handle_mapping_vector fds_to_map; |
272 const int ipcfd = chan.GetClientFileDescriptor(); | 269 const int ipcfd = chan.GetClientFileDescriptor(); |
273 if (ipcfd > -1) { | 270 if (ipcfd > -1) { |
274 fds_to_map.push_back(std::pair<int,int>(ipcfd, kPrimaryIPCChannel + 3)); | 271 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); |
275 } | 272 } |
276 | 273 |
277 base::ProcessHandle process_handle = MultiProcessTest::SpawnChild( | 274 base::ProcessHandle process_handle = MultiProcessTest::SpawnChild( |
278 L"RunTestClient", | 275 L"RunTestClient", |
279 fds_to_map, | 276 fds_to_map, |
280 debug_on_start); | 277 debug_on_start); |
281 #endif // defined(OS_POSIX) | 278 #endif // defined(OS_POSIX) |
282 | 279 |
283 ASSERT_TRUE(process_handle); | 280 ASSERT_TRUE(process_handle); |
284 | 281 |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 #endif // PERFORMANCE_TEST | 539 #endif // PERFORMANCE_TEST |
543 | 540 |
544 int main(int argc, char** argv) { | 541 int main(int argc, char** argv) { |
545 #ifdef PERFORMANCE_TEST | 542 #ifdef PERFORMANCE_TEST |
546 int retval = PerfTestSuite(argc, argv).Run(); | 543 int retval = PerfTestSuite(argc, argv).Run(); |
547 #else | 544 #else |
548 int retval = TestSuite(argc, argv).Run(); | 545 int retval = TestSuite(argc, argv).Run(); |
549 #endif | 546 #endif |
550 return retval; | 547 return retval; |
551 } | 548 } |
OLD | NEW |