| 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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 TEST(ProcessReader, SelfSeveralThreads) { | 363 TEST(ProcessReader, SelfSeveralThreads) { |
| 364 // Set up the ProcessReader here, before any other threads are running. This | 364 // Set up the ProcessReader here, before any other threads are running. This |
| 365 // tests that the threads it returns are lazily initialized as a snapshot of | 365 // tests that the threads it returns are lazily initialized as a snapshot of |
| 366 // the threads at the time of the first call to Threads(), and not at the | 366 // the threads at the time of the first call to Threads(), and not at the |
| 367 // time the ProcessReader was created or initialized. | 367 // time the ProcessReader was created or initialized. |
| 368 ProcessReader process_reader; | 368 ProcessReader process_reader; |
| 369 ASSERT_TRUE(process_reader.Initialize(mach_task_self())); | 369 ASSERT_TRUE(process_reader.Initialize(mach_task_self())); |
| 370 | 370 |
| 371 TestThreadPool thread_pool; | 371 TestThreadPool thread_pool; |
| 372 const size_t kChildThreads = 16; | 372 const size_t kChildThreads = 16; |
| 373 thread_pool.StartThreads(kChildThreads); | 373 ASSERT_NO_FATAL_FAILURE(thread_pool.StartThreads(kChildThreads)); |
| 374 if (Test::HasFatalFailure()) { | |
| 375 return; | |
| 376 } | |
| 377 | 374 |
| 378 // Build a map of all expected threads, keyed by each thread’s ID. The values | 375 // Build a map of all expected threads, keyed by each thread’s ID. The values |
| 379 // are addresses that should lie somewhere within each thread’s stack. | 376 // are addresses that should lie somewhere within each thread’s stack. |
| 380 ThreadMap thread_map; | 377 ThreadMap thread_map; |
| 381 const uint64_t self_thread_id = PthreadToThreadID(pthread_self()); | 378 const uint64_t self_thread_id = PthreadToThreadID(pthread_self()); |
| 382 TestThreadPool::ThreadExpectation expectation; | 379 TestThreadPool::ThreadExpectation expectation; |
| 383 expectation.stack_address = reinterpret_cast<mach_vm_address_t>(&thread_map); | 380 expectation.stack_address = reinterpret_cast<mach_vm_address_t>(&thread_map); |
| 384 expectation.suspend_count = 0; | 381 expectation.suspend_count = 0; |
| 385 thread_map[self_thread_id] = expectation; | 382 thread_map[self_thread_id] = expectation; |
| 386 for (size_t thread_index = 0; thread_index < kChildThreads; ++thread_index) { | 383 for (size_t thread_index = 0; thread_index < kChildThreads; ++thread_index) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 452 |
| 456 const std::vector<ProcessReader::Thread>& threads = process_reader.Threads()
; | 453 const std::vector<ProcessReader::Thread>& threads = process_reader.Threads()
; |
| 457 | 454 |
| 458 // The child shouldn’t have any threads other than its main thread and the | 455 // The child shouldn’t have any threads other than its main thread and the |
| 459 // ones it created in its pool, so pass false for |tolerate_extra_threads|. | 456 // ones it created in its pool, so pass false for |tolerate_extra_threads|. |
| 460 ExpectSeveralThreads(&thread_map, threads, false); | 457 ExpectSeveralThreads(&thread_map, threads, false); |
| 461 } | 458 } |
| 462 | 459 |
| 463 void MachMultiprocessChild() override { | 460 void MachMultiprocessChild() override { |
| 464 TestThreadPool thread_pool; | 461 TestThreadPool thread_pool; |
| 465 thread_pool.StartThreads(thread_count_); | 462 ASSERT_NO_FATAL_FAILURE(thread_pool.StartThreads(thread_count_)); |
| 466 if (testing::Test::HasFatalFailure()) { | |
| 467 return; | |
| 468 } | |
| 469 | 463 |
| 470 int write_fd = WritePipeFD(); | 464 int write_fd = WritePipeFD(); |
| 471 | 465 |
| 472 // This thread isn’t part of the thread pool, but the parent will be able | 466 // This thread isn’t part of the thread pool, but the parent will be able |
| 473 // to inspect it. Write an entry for it. | 467 // to inspect it. Write an entry for it. |
| 474 uint64_t thread_id = PthreadToThreadID(pthread_self()); | 468 uint64_t thread_id = PthreadToThreadID(pthread_self()); |
| 475 | 469 |
| 476 CheckedWriteFD(write_fd, &thread_id, sizeof(thread_id)); | 470 CheckedWriteFD(write_fd, &thread_id, sizeof(thread_id)); |
| 477 | 471 |
| 478 TestThreadPool::ThreadExpectation expectation; | 472 TestThreadPool::ThreadExpectation expectation; |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 }; | 683 }; |
| 690 | 684 |
| 691 TEST(ProcessReader, ChildModules) { | 685 TEST(ProcessReader, ChildModules) { |
| 692 ProcessReaderModulesChild process_reader_modules_child; | 686 ProcessReaderModulesChild process_reader_modules_child; |
| 693 process_reader_modules_child.Run(); | 687 process_reader_modules_child.Run(); |
| 694 } | 688 } |
| 695 | 689 |
| 696 } // namespace | 690 } // namespace |
| 697 } // namespace test | 691 } // namespace test |
| 698 } // namespace crashpad | 692 } // namespace crashpad |
| OLD | NEW |