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

Side by Side Diff: util/mach/exception_ports_test.cc

Issue 656703002: Convert NULL to nullptr (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Fix 80-column violations Created 6 years, 2 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
« no previous file with comments | « util/mach/exception_ports.cc ('k') | util/mach/mach_message_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 EXPECT_EQ(LocalPort(), exception_port); 179 EXPECT_EQ(LocalPort(), exception_port);
180 180
181 EXPECT_EQ(EXC_CRASH, exception); 181 EXPECT_EQ(EXC_CRASH, exception);
182 EXPECT_EQ(2u, code_count); 182 EXPECT_EQ(2u, code_count);
183 183
184 // The exception and code_count checks above would ideally use ASSERT_EQ so 184 // The exception and code_count checks above would ideally use ASSERT_EQ so
185 // that the next conditional would not be necessary, but ASSERT_* requires a 185 // that the next conditional would not be necessary, but ASSERT_* requires a
186 // function returning type void, and the interface dictates otherwise here. 186 // function returning type void, and the interface dictates otherwise here.
187 if (exception == EXC_CRASH && code_count >= 1) { 187 if (exception == EXC_CRASH && code_count >= 1) {
188 int signal; 188 int signal;
189 ExcCrashRecoverOriginalException(code[0], NULL, &signal); 189 ExcCrashRecoverOriginalException(code[0], nullptr, &signal);
190 190
191 // The child crashed with a division by zero, which shows up as SIGFPE. 191 // The child crashed with a division by zero, which shows up as SIGFPE.
192 // This was chosen because it’s unlikely to be generated by testing or 192 // This was chosen because it’s unlikely to be generated by testing or
193 // assertion failures. 193 // assertion failures.
194 EXPECT_EQ(SIGFPE, signal); 194 EXPECT_EQ(SIGFPE, signal);
195 195
196 SetExpectedChildTermination(kTerminationSignal, signal); 196 SetExpectedChildTermination(kTerminationSignal, signal);
197 } 197 }
198 198
199 return ExcServerSuccessfulReturnValue(behavior, false); 199 return ExcServerSuccessfulReturnValue(behavior, false);
(...skipping 24 matching lines...) Expand all
224 EXC_MASK_CRASH, remote_port, EXCEPTION_DEFAULT, THREAD_STATE_NONE)); 224 EXC_MASK_CRASH, remote_port, EXCEPTION_DEFAULT, THREAD_STATE_NONE));
225 225
226 if (test_exception_ports_->set_on() == kSetOnTaskAndThreads) { 226 if (test_exception_ports_->set_on() == kSetOnTaskAndThreads) {
227 ASSERT_TRUE(self_thread_ports.SetExceptionPort(EXC_MASK_CRASH, 227 ASSERT_TRUE(self_thread_ports.SetExceptionPort(EXC_MASK_CRASH,
228 remote_port, 228 remote_port,
229 EXCEPTION_STATE, 229 EXCEPTION_STATE,
230 MACHINE_THREAD_STATE)); 230 MACHINE_THREAD_STATE));
231 } 231 }
232 } 232 }
233 233
234 int rv_int = pthread_create(&thread_, NULL, ThreadMainThunk, this); 234 int rv_int = pthread_create(&thread_, nullptr, ThreadMainThunk, this);
235 ASSERT_EQ(0, rv_int); 235 ASSERT_EQ(0, rv_int);
236 236
237 // Wait for the new thread to be ready. 237 // Wait for the new thread to be ready.
238 init_semaphore_.Wait(); 238 init_semaphore_.Wait();
239 239
240 // Tell the parent process that everything is set up. 240 // Tell the parent process that everything is set up.
241 char c = '\0'; 241 char c = '\0';
242 CheckedWriteFD(test_exception_ports_->WritePipeFD(), &c, 1); 242 CheckedWriteFD(test_exception_ports_->WritePipeFD(), &c, 1);
243 243
244 // Wait for the parent process to say that its end is set up. 244 // Wait for the parent process to say that its end is set up.
(...skipping 19 matching lines...) Expand all
264 264
265 // Let the other thread know it’s safe to proceed. 265 // Let the other thread know it’s safe to proceed.
266 crash_semaphore_.Signal(); 266 crash_semaphore_.Signal();
267 267
268 // If this thread is the one that crashes, do it. 268 // If this thread is the one that crashes, do it.
269 if (test_exception_ports_->who_crashes() == kMainThreadCrashes) { 269 if (test_exception_ports_->who_crashes() == kMainThreadCrashes) {
270 Crash(); 270 Crash();
271 } 271 }
272 272
273 // Reap the other thread. 273 // Reap the other thread.
274 rv_int = pthread_join(thread_, NULL); 274 rv_int = pthread_join(thread_, nullptr);
275 ASSERT_EQ(0, rv_int); 275 ASSERT_EQ(0, rv_int);
276 } 276 }
277 277
278 private: 278 private:
279 // Calls ThreadMain(). 279 // Calls ThreadMain().
280 static void* ThreadMainThunk(void* argument) { 280 static void* ThreadMainThunk(void* argument) {
281 Child* self = reinterpret_cast<Child*>(argument); 281 Child* self = reinterpret_cast<Child*>(argument);
282 return self->ThreadMain(); 282 return self->ThreadMain();
283 } 283 }
284 284
(...skipping 28 matching lines...) Expand all
313 : MACH_PORT_NULL; 313 : MACH_PORT_NULL;
314 TestGetExceptionPorts( 314 TestGetExceptionPorts(
315 self_thread_ports, thread_handler, EXCEPTION_STATE_IDENTITY); 315 self_thread_ports, thread_handler, EXCEPTION_STATE_IDENTITY);
316 } 316 }
317 317
318 // If this thread is the one that crashes, do it. 318 // If this thread is the one that crashes, do it.
319 if (test_exception_ports_->who_crashes() == kOtherThreadCrashes) { 319 if (test_exception_ports_->who_crashes() == kOtherThreadCrashes) {
320 Crash(); 320 Crash();
321 } 321 }
322 322
323 return NULL; 323 return nullptr;
324 } 324 }
325 325
326 // Crashes by performing a division by zero. The assignment is present to 326 // Crashes by performing a division by zero. The assignment is present to
327 // avoid optimizing zero_ out entirely by making it appear that its value 327 // avoid optimizing zero_ out entirely by making it appear that its value
328 // might change. 328 // might change.
329 static void Crash() { zero_ = 1 / zero_; } 329 static void Crash() { zero_ = 1 / zero_; }
330 330
331 // The parent object. 331 // The parent object.
332 TestExceptionPorts* test_exception_ports_; // weak 332 TestExceptionPorts* test_exception_ports_; // weak
333 333
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 if (geteuid() == 0) { 568 if (geteuid() == 0) {
569 EXPECT_TRUE(rv); 569 EXPECT_TRUE(rv);
570 } else { 570 } else {
571 EXPECT_FALSE(rv); 571 EXPECT_FALSE(rv);
572 } 572 }
573 } 573 }
574 574
575 } // namespace 575 } // namespace
576 } // namespace test 576 } // namespace test
577 } // namespace crashpad 577 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/mach/exception_ports.cc ('k') | util/mach/mach_message_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698