| OLD | NEW |
| 1 // Copyright (c) 2010 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> |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // kDebugChildren support. | 83 // kDebugChildren support. |
| 84 bool debug_on_start = | 84 bool debug_on_start = |
| 85 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren); | 85 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren); |
| 86 | 86 |
| 87 base::file_handle_mapping_vector fds_to_map; | 87 base::file_handle_mapping_vector fds_to_map; |
| 88 const int ipcfd = channel->GetClientFileDescriptor(); | 88 const int ipcfd = channel->GetClientFileDescriptor(); |
| 89 if (ipcfd > -1) { | 89 if (ipcfd > -1) { |
| 90 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); | 90 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 base::ProcessHandle ret = NULL; | 93 base::ProcessHandle ret = base::kNullProcessHandle; |
| 94 switch (child_type) { | 94 switch (child_type) { |
| 95 case TEST_CLIENT: | 95 case TEST_CLIENT: |
| 96 ret = MultiProcessTest::SpawnChild("RunTestClient", | 96 ret = MultiProcessTest::SpawnChild("RunTestClient", |
| 97 fds_to_map, | 97 fds_to_map, |
| 98 debug_on_start); | 98 debug_on_start); |
| 99 break; | 99 break; |
| 100 case TEST_DESCRIPTOR_CLIENT: | 100 case TEST_DESCRIPTOR_CLIENT: |
| 101 ret = MultiProcessTest::SpawnChild("RunTestDescriptorClient", | 101 ret = MultiProcessTest::SpawnChild("RunTestDescriptorClient", |
| 102 fds_to_map, | 102 fds_to_map, |
| 103 debug_on_start); | 103 debug_on_start); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 116 ret = MultiProcessTest::SpawnChild("RunFuzzServer", | 116 ret = MultiProcessTest::SpawnChild("RunFuzzServer", |
| 117 fds_to_map, | 117 fds_to_map, |
| 118 debug_on_start); | 118 debug_on_start); |
| 119 break; | 119 break; |
| 120 case SYNC_SOCKET_SERVER: | 120 case SYNC_SOCKET_SERVER: |
| 121 ret = MultiProcessTest::SpawnChild("RunSyncSocketServer", | 121 ret = MultiProcessTest::SpawnChild("RunSyncSocketServer", |
| 122 fds_to_map, | 122 fds_to_map, |
| 123 debug_on_start); | 123 debug_on_start); |
| 124 break; | 124 break; |
| 125 default: | 125 default: |
| 126 return NULL; | 126 return base::kNullProcessHandle; |
| 127 break; | 127 break; |
| 128 } | 128 } |
| 129 return ret; | 129 return ret; |
| 130 } | 130 } |
| 131 #endif // defined(OS_POSIX) | 131 #endif // defined(OS_POSIX) |
| 132 | 132 |
| 133 TEST_F(IPCChannelTest, BasicMessageTest) { | 133 TEST_F(IPCChannelTest, BasicMessageTest) { |
| 134 int v1 = 10; | 134 int v1 = 10; |
| 135 std::string v2("foobar"); | 135 std::string v2("foobar"); |
| 136 std::wstring v3(L"hello world"); | 136 std::wstring v3(L"hello world"); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 360 |
| 361 // setup IPC channel | 361 // setup IPC channel |
| 362 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_CLIENT, | 362 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_CLIENT, |
| 363 &channel_listener); | 363 &channel_listener); |
| 364 CHECK(chan.Connect()); | 364 CHECK(chan.Connect()); |
| 365 channel_listener.Init(&chan); | 365 channel_listener.Init(&chan); |
| 366 Send(&chan, "hello from child"); | 366 Send(&chan, "hello from child"); |
| 367 // run message loop | 367 // run message loop |
| 368 MessageLoop::current()->Run(); | 368 MessageLoop::current()->Run(); |
| 369 // return true; | 369 // return true; |
| 370 return NULL; | 370 return 0; |
| 371 } | 371 } |
| 372 | 372 |
| 373 #endif // !PERFORMANCE_TEST | 373 #endif // !PERFORMANCE_TEST |
| 374 | 374 |
| 375 #ifdef PERFORMANCE_TEST | 375 #ifdef PERFORMANCE_TEST |
| 376 | 376 |
| 377 //----------------------------------------------------------------------------- | 377 //----------------------------------------------------------------------------- |
| 378 // Manually performance test | 378 // Manually performance test |
| 379 // | 379 // |
| 380 // This test times the roundtrip IPC message cycle. It is enabled with a | 380 // This test times the roundtrip IPC message cycle. It is enabled with a |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 #endif // PERFORMANCE_TEST | 537 #endif // PERFORMANCE_TEST |
| 538 | 538 |
| 539 int main(int argc, char** argv) { | 539 int main(int argc, char** argv) { |
| 540 #ifdef PERFORMANCE_TEST | 540 #ifdef PERFORMANCE_TEST |
| 541 int retval = base::PerfTestSuite(argc, argv).Run(); | 541 int retval = base::PerfTestSuite(argc, argv).Run(); |
| 542 #else | 542 #else |
| 543 int retval = base::TestSuite(argc, argv).Run(); | 543 int retval = base::TestSuite(argc, argv).Run(); |
| 544 #endif | 544 #endif |
| 545 return retval; | 545 return retval; |
| 546 } | 546 } |
| OLD | NEW |