| OLD | NEW |
| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 235 } |
| 236 | 236 |
| 237 int rv_int = pthread_create(&thread_, nullptr, ThreadMainThunk, this); | 237 int rv_int = pthread_create(&thread_, nullptr, ThreadMainThunk, this); |
| 238 ASSERT_EQ(0, rv_int); | 238 ASSERT_EQ(0, rv_int); |
| 239 | 239 |
| 240 // Wait for the new thread to be ready. | 240 // Wait for the new thread to be ready. |
| 241 init_semaphore_.Wait(); | 241 init_semaphore_.Wait(); |
| 242 | 242 |
| 243 // Tell the parent process that everything is set up. | 243 // Tell the parent process that everything is set up. |
| 244 char c = '\0'; | 244 char c = '\0'; |
| 245 CheckedWriteFile(test_exception_ports_->WritePipeFD(), &c, 1); | 245 CheckedWriteFile(test_exception_ports_->WritePipeHandle(), &c, 1); |
| 246 | 246 |
| 247 // Wait for the parent process to say that its end is set up. | 247 // Wait for the parent process to say that its end is set up. |
| 248 CheckedReadFile(test_exception_ports_->ReadPipeFD(), &c, 1); | 248 CheckedReadFile(test_exception_ports_->ReadPipeHandle(), &c, 1); |
| 249 EXPECT_EQ('\0', c); | 249 EXPECT_EQ('\0', c); |
| 250 | 250 |
| 251 // Regardless of where ExceptionPorts::SetExceptionPort() ran, | 251 // Regardless of where ExceptionPorts::SetExceptionPort() ran, |
| 252 // ExceptionPorts::GetExceptionPorts() can always be tested in-process. | 252 // ExceptionPorts::GetExceptionPorts() can always be tested in-process. |
| 253 { | 253 { |
| 254 SCOPED_TRACE("task"); | 254 SCOPED_TRACE("task"); |
| 255 TestGetExceptionPorts(self_task_ports, remote_port, EXCEPTION_DEFAULT); | 255 TestGetExceptionPorts(self_task_ports, remote_port, EXCEPTION_DEFAULT); |
| 256 } | 256 } |
| 257 | 257 |
| 258 { | 258 { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 | 352 |
| 353 DISALLOW_COPY_AND_ASSIGN(Child); | 353 DISALLOW_COPY_AND_ASSIGN(Child); |
| 354 }; | 354 }; |
| 355 | 355 |
| 356 // MachMultiprocess: | 356 // MachMultiprocess: |
| 357 | 357 |
| 358 void MachMultiprocessParent() override { | 358 void MachMultiprocessParent() override { |
| 359 // Wait for the child process to be ready. It needs to have all of its | 359 // Wait for the child process to be ready. It needs to have all of its |
| 360 // threads set up before proceeding if in kSetOutOfProcess mode. | 360 // threads set up before proceeding if in kSetOutOfProcess mode. |
| 361 char c; | 361 char c; |
| 362 CheckedReadFile(ReadPipeFD(), &c, 1); | 362 CheckedReadFile(ReadPipeHandle(), &c, 1); |
| 363 EXPECT_EQ('\0', c); | 363 EXPECT_EQ('\0', c); |
| 364 | 364 |
| 365 mach_port_t local_port = LocalPort(); | 365 mach_port_t local_port = LocalPort(); |
| 366 | 366 |
| 367 // Get an ExceptionPorts object for the task and each of its threads. | 367 // Get an ExceptionPorts object for the task and each of its threads. |
| 368 ExceptionPorts task_ports(ExceptionPorts::kTargetTypeTask, ChildTask()); | 368 ExceptionPorts task_ports(ExceptionPorts::kTargetTypeTask, ChildTask()); |
| 369 EXPECT_EQ("task", task_ports.TargetTypeName()); | 369 EXPECT_EQ("task", task_ports.TargetTypeName()); |
| 370 | 370 |
| 371 // Hopefully the threads returned by task_threads() are in order, with the | 371 // Hopefully the threads returned by task_threads() are in order, with the |
| 372 // main thread first and the other thread second. This is currently always | 372 // main thread first and the other thread second. This is currently always |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 435 |
| 436 { | 436 { |
| 437 SCOPED_TRACE("other_thread"); | 437 SCOPED_TRACE("other_thread"); |
| 438 TestGetExceptionPorts( | 438 TestGetExceptionPorts( |
| 439 other_thread_ports, thread_handler, EXCEPTION_STATE_IDENTITY); | 439 other_thread_ports, thread_handler, EXCEPTION_STATE_IDENTITY); |
| 440 } | 440 } |
| 441 | 441 |
| 442 // Let the child process know that everything in the parent process is set | 442 // Let the child process know that everything in the parent process is set |
| 443 // up. | 443 // up. |
| 444 c = '\0'; | 444 c = '\0'; |
| 445 CheckedWriteFile(WritePipeFD(), &c, 1); | 445 CheckedWriteFile(WritePipeHandle(), &c, 1); |
| 446 | 446 |
| 447 if (who_crashes_ != kNobodyCrashes) { | 447 if (who_crashes_ != kNobodyCrashes) { |
| 448 UniversalMachExcServer universal_mach_exc_server(this); | 448 UniversalMachExcServer universal_mach_exc_server(this); |
| 449 | 449 |
| 450 kern_return_t kr = | 450 kern_return_t kr = |
| 451 MachMessageServer::Run(&universal_mach_exc_server, | 451 MachMessageServer::Run(&universal_mach_exc_server, |
| 452 local_port, | 452 local_port, |
| 453 MACH_MSG_OPTION_NONE, | 453 MACH_MSG_OPTION_NONE, |
| 454 MachMessageServer::kOneShot, | 454 MachMessageServer::kOneShot, |
| 455 MachMessageServer::kReceiveLargeError, | 455 MachMessageServer::kReceiveLargeError, |
| 456 kMachMessageTimeoutWaitIndefinitely); | 456 kMachMessageTimeoutWaitIndefinitely); |
| 457 EXPECT_EQ(KERN_SUCCESS, kr) | 457 EXPECT_EQ(KERN_SUCCESS, kr) |
| 458 << MachErrorMessage(kr, "MachMessageServer::Run"); | 458 << MachErrorMessage(kr, "MachMessageServer::Run"); |
| 459 | 459 |
| 460 EXPECT_TRUE(handled_); | 460 EXPECT_TRUE(handled_); |
| 461 } | 461 } |
| 462 | 462 |
| 463 // Wait for the child process to exit or terminate, as indicated by it | 463 // Wait for the child process to exit or terminate, as indicated by it |
| 464 // closing its pipe. This keeps LocalPort() alive in the child as | 464 // closing its pipe. This keeps LocalPort() alive in the child as |
| 465 // RemotePort(), for the child’s use in its TestGetExceptionPorts(). | 465 // RemotePort(), for the child’s use in its TestGetExceptionPorts(). |
| 466 CheckedReadFileAtEOF(ReadPipeFD()); | 466 CheckedReadFileAtEOF(ReadPipeHandle()); |
| 467 } | 467 } |
| 468 | 468 |
| 469 void MachMultiprocessChild() override { | 469 void MachMultiprocessChild() override { |
| 470 Child child(this); | 470 Child child(this); |
| 471 child.Run(); | 471 child.Run(); |
| 472 } | 472 } |
| 473 | 473 |
| 474 SetType set_type_; | 474 SetType set_type_; |
| 475 SetOn set_on_; | 475 SetOn set_on_; |
| 476 WhoCrashes who_crashes_; | 476 WhoCrashes who_crashes_; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 if (geteuid() == 0) { | 574 if (geteuid() == 0) { |
| 575 EXPECT_TRUE(rv); | 575 EXPECT_TRUE(rv); |
| 576 } else { | 576 } else { |
| 577 EXPECT_FALSE(rv); | 577 EXPECT_FALSE(rv); |
| 578 } | 578 } |
| 579 } | 579 } |
| 580 | 580 |
| 581 } // namespace | 581 } // namespace |
| 582 } // namespace test | 582 } // namespace test |
| 583 } // namespace crashpad | 583 } // namespace crashpad |
| OLD | NEW |