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

Side by Side Diff: ipc/ipc_send_fds_test.cc

Issue 10387218: Make GlobalDescriptors::MaybeGet return -1 when the key is not found. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied Jeremy's suggestions + sync. Created 8 years, 6 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
OLDNEW
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 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "ipc/ipc_tests.h" 7 #include "ipc/ipc_tests.h"
8 8
9 #if defined(OS_MACOSX) 9 #if defined(OS_MACOSX)
10 extern "C" { 10 extern "C" {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 CHECK(listener.GotExpectedNumberOfDescriptors()); 125 CHECK(listener.GotExpectedNumberOfDescriptors());
126 126
127 return 0; 127 return 0;
128 } 128 }
129 129
130 } // namespace 130 } // namespace
131 131
132 // --------------------------------------------------------------------------- 132 // ---------------------------------------------------------------------------
133 #if defined(OS_MACOSX) 133 #if defined(OS_MACOSX)
134 // TODO(port): Make this test cross-platform. 134 // TODO(port): Make this test cross-platform.
135 MULTIPROCESS_TEST_MAIN(RunTestDescriptorClientSandboxed) { 135 MULTIPROCESS_IPC_TEST_MAIN(RunTestDescriptorClientSandboxed) {
136 struct stat st; 136 struct stat st;
137 const int fd = open(kDevZeroPath, O_RDONLY); 137 const int fd = open(kDevZeroPath, O_RDONLY);
138 fstat(fd, &st); 138 fstat(fd, &st);
139 if (HANDLE_EINTR(close(fd)) < 0) { 139 if (HANDLE_EINTR(close(fd)) < 0) {
140 return -1; 140 return -1;
141 } 141 }
142 142
143 // Enable the Sandbox. 143 // Enable the Sandbox.
144 char* error_buff = NULL; 144 char* error_buff = NULL;
145 int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED, 145 int error = sandbox_init(kSBXProfilePureComputation, SANDBOX_NAMED,
(...skipping 24 matching lines...) Expand all
170 &listener); 170 &listener);
171 ASSERT_TRUE(chan.Connect()); 171 ASSERT_TRUE(chan.Connect());
172 172
173 base::ProcessHandle process_handle = SpawnChild( 173 base::ProcessHandle process_handle = SpawnChild(
174 TEST_DESCRIPTOR_CLIENT_SANDBOXED, 174 TEST_DESCRIPTOR_CLIENT_SANDBOXED,
175 &chan); 175 &chan);
176 TestDescriptorServer(chan, process_handle); 176 TestDescriptorServer(chan, process_handle);
177 } 177 }
178 #endif // defined(OS_MACOSX) 178 #endif // defined(OS_MACOSX)
179 179
180 MULTIPROCESS_TEST_MAIN(RunTestDescriptorClient) { 180 MULTIPROCESS_IPC_TEST_MAIN(RunTestDescriptorClient) {
181 struct stat st; 181 struct stat st;
182 const int fd = open(kDevZeroPath, O_RDONLY); 182 const int fd = open(kDevZeroPath, O_RDONLY);
183 fstat(fd, &st); 183 fstat(fd, &st);
184 EXPECT_GE(HANDLE_EINTR(close(fd)), 0); 184 EXPECT_GE(HANDLE_EINTR(close(fd)), 0);
185 185
186 return TestDescriptorClient(st.st_ino); 186 return TestDescriptorClient(st.st_ino);
187 } 187 }
188 188
189 TEST_F(IPCChannelTest, DescriptorTest) { 189 TEST_F(IPCChannelTest, DescriptorTest) {
190 // Setup IPC channel. 190 // Setup IPC channel.
191 MyChannelDescriptorListener listener(-1); 191 MyChannelDescriptorListener listener(-1);
192 192
193 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER, 193 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_SERVER,
194 &listener); 194 &listener);
195 ASSERT_TRUE(chan.Connect()); 195 ASSERT_TRUE(chan.Connect());
196 196
197 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT, 197 base::ProcessHandle process_handle = SpawnChild(TEST_DESCRIPTOR_CLIENT,
198 &chan); 198 &chan);
199 TestDescriptorServer(chan, process_handle); 199 TestDescriptorServer(chan, process_handle);
200 } 200 }
201 201
202 #endif // defined(OS_POSIX) 202 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « ipc/ipc_fuzzing_tests.cc ('k') | ipc/ipc_tests.h » ('j') | ipc/ipc_tests.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698