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

Side by Side Diff: ipc/ipc_test_base.cc

Issue 11819041: Make ipc_tests file structure a little saner and add an ipc_perftests target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ugh Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_test_base.h ('k') | ipc/ipc_tests.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "build/build_config.h"
6
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #elif defined(OS_POSIX)
10 #include <sys/types.h>
11 #include <unistd.h>
12 #endif
13
14 #include <stdio.h>
15 #include <string>
16 #include <utility>
17
18 #include "ipc/ipc_test_base.h"
19
20 #include "base/base_switches.h"
21 #include "base/command_line.h"
22 #include "base/debug/debug_on_start_win.h"
23 #include "base/perftimer.h"
24 #include "base/pickle.h"
25 #include "base/test/perf_test_suite.h"
26 #include "base/test/test_suite.h"
27 #include "base/threading/thread.h"
28 #include "base/time.h"
29 #include "ipc/ipc_descriptors.h"
30 #include "ipc/ipc_channel.h"
31 #include "ipc/ipc_channel_proxy.h"
32 #include "ipc/ipc_message_utils.h"
33 #include "ipc/ipc_multiprocess_test.h"
34 #include "ipc/ipc_sender.h"
35 #include "ipc/ipc_switches.h"
36 #include "testing/multiprocess_func_list.h"
37
38 // Define to enable IPC performance testing instead of the regular unit tests
39 // #define PERFORMANCE_TEST
40
41 const char kTestClientChannel[] = "T1";
42 const char kReflectorChannel[] = "T2";
43 const char kFuzzerChannel[] = "F3";
44 const char kSyncSocketChannel[] = "S4";
45
46 void IPCTestBase::SetUp() {
47 MultiProcessTest::SetUp();
48
49 // Construct a fresh IO Message loop for the duration of each test.
50 message_loop_ = new MessageLoopForIO();
51 }
52
53 void IPCTestBase::TearDown() {
54 delete message_loop_;
55 message_loop_ = NULL;
56
57 MultiProcessTest::TearDown();
58 }
59
60 #if defined(OS_WIN)
61 base::ProcessHandle IPCTestBase::SpawnChild(IPCTestBase::ChildType child_type,
62 IPC::Channel *channel) {
63 // kDebugChildren support.
64 bool debug_on_start =
65 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
66
67 switch (child_type) {
68 case TEST_CLIENT:
69 return MultiProcessTest::SpawnChild("RunTestClient", debug_on_start);
70 case TEST_REFLECTOR:
71 return MultiProcessTest::SpawnChild("RunReflector", debug_on_start);
72 case FUZZER_SERVER:
73 return MultiProcessTest::SpawnChild("RunFuzzServer", debug_on_start);
74 case SYNC_SOCKET_SERVER:
75 return MultiProcessTest::SpawnChild("RunSyncSocketServer", debug_on_start);
76 default:
77 return NULL;
78 }
79 }
80 #elif defined(OS_POSIX)
81 base::ProcessHandle IPCTestBase::SpawnChild(IPCTestBase::ChildType child_type,
82 IPC::Channel *channel) {
83 // kDebugChildren support.
84 bool debug_on_start =
85 CommandLine::ForCurrentProcess()->HasSwitch(switches::kDebugChildren);
86
87 base::FileHandleMappingVector fds_to_map;
88 const int ipcfd = channel->GetClientFileDescriptor();
89 if (ipcfd > -1) {
90 fds_to_map.push_back(std::pair<int, int>(ipcfd, kPrimaryIPCChannel + 3));
91 }
92
93 base::ProcessHandle ret = base::kNullProcessHandle;
94 switch (child_type) {
95 case TEST_CLIENT:
96 ret = MultiProcessTest::SpawnChild("RunTestClient",
97 fds_to_map,
98 debug_on_start);
99 break;
100 case TEST_DESCRIPTOR_CLIENT:
101 ret = MultiProcessTest::SpawnChild("RunTestDescriptorClient",
102 fds_to_map,
103 debug_on_start);
104 break;
105 case TEST_DESCRIPTOR_CLIENT_SANDBOXED:
106 ret = MultiProcessTest::SpawnChild("RunTestDescriptorClientSandboxed",
107 fds_to_map,
108 debug_on_start);
109 break;
110 case TEST_REFLECTOR:
111 ret = MultiProcessTest::SpawnChild("RunReflector",
112 fds_to_map,
113 debug_on_start);
114 break;
115 case FUZZER_SERVER:
116 ret = MultiProcessTest::SpawnChild("RunFuzzServer",
117 fds_to_map,
118 debug_on_start);
119 break;
120 case SYNC_SOCKET_SERVER:
121 ret = MultiProcessTest::SpawnChild("RunSyncSocketServer",
122 fds_to_map,
123 debug_on_start);
124 break;
125 default:
126 return base::kNullProcessHandle;
127 break;
128 }
129 return ret;
130 }
131 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « ipc/ipc_test_base.h ('k') | ipc/ipc_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698