Chromium Code Reviews| Index: snapshot/win/process_reader_win_test.cc |
| diff --git a/snapshot/win/process_reader_win_test.cc b/snapshot/win/process_reader_win_test.cc |
| index 23306315522acd4e1dc5f45bd9e6ccf0e1640c1a..d84ba0ae40b0cfade19c80fd431901c08fadf644 100644 |
| --- a/snapshot/win/process_reader_win_test.cc |
| +++ b/snapshot/win/process_reader_win_test.cc |
| @@ -19,6 +19,7 @@ |
| #include "gtest/gtest.h" |
| #include "test/win/win_multiprocess.h" |
| +#include "util/win/scoped_process_suspend.h" |
| namespace crashpad { |
| namespace test { |
| @@ -26,7 +27,8 @@ namespace { |
| TEST(ProcessReaderWin, SelfBasic) { |
| ProcessReaderWin process_reader; |
| - ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess())); |
| + ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess(), |
| + ProcessSuspensionState::kRunning)); |
| #if !defined(ARCH_CPU_64_BITS) |
| EXPECT_FALSE(process_reader.Is64Bit()); |
| @@ -55,7 +57,8 @@ class ProcessReaderChild final : public WinMultiprocess { |
| private: |
| void WinMultiprocessParent() override { |
| ProcessReaderWin process_reader; |
| - ASSERT_TRUE(process_reader.Initialize(ChildProcess())); |
| + ASSERT_TRUE(process_reader.Initialize(ChildProcess(), |
| + ProcessSuspensionState::kRunning)); |
| #if !defined(ARCH_CPU_64_BITS) |
| EXPECT_FALSE(process_reader.Is64Bit()); |
| @@ -90,7 +93,8 @@ TEST(ProcessReaderWin, ChildBasic) { |
| TEST(ProcessReaderWin, SelfOneThread) { |
| ProcessReaderWin process_reader; |
| - ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess())); |
| + ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess(), |
| + ProcessSuspensionState::kRunning)); |
| const std::vector<ProcessReaderWin::Thread>& threads = |
| process_reader.Threads(); |
| @@ -110,6 +114,52 @@ TEST(ProcessReaderWin, SelfOneThread) { |
| EXPECT_EQ(0, threads[0].suspend_count); |
| } |
| +class ProcessReaderChildThreadSuspendCount final : public WinMultiprocess { |
| + public: |
| + ProcessReaderChildThreadSuspendCount() : WinMultiprocess() {} |
| + ~ProcessReaderChildThreadSuspendCount() {} |
| + |
| + private: |
| + void WinMultiprocessParent() override { |
| + { |
| + ProcessReaderWin process_reader; |
| + ASSERT_TRUE(process_reader.Initialize(ChildProcess(), |
| + ProcessSuspensionState::kRunning)); |
| + |
| + for (const auto& thread : process_reader.Threads()) |
| + EXPECT_EQ(0u, thread.suspend_count); |
| + } |
| + |
| + { |
| + ScopedProcessSuspend suspend(ChildProcess()); |
| + |
| + ProcessReaderWin process_reader; |
| + ASSERT_TRUE(process_reader.Initialize( |
| + ChildProcess(), ProcessSuspensionState::kSuspended)); |
| + |
| + // Confirm that thread counts are adjusted correctly for the process being |
| + // suspended. |
| + for (const auto& thread : process_reader.Threads()) |
| + EXPECT_EQ(0u, thread.suspend_count); |
|
Mark Mentovai
2015/09/09 19:22:11
In order to have assurance that this is testing an
scottmg
2015/09/09 19:28:00
Done.
|
| + } |
| + } |
| + |
| + void WinMultiprocessChild() override { |
| + WinVMAddress address = reinterpret_cast<WinVMAddress>(kTestMemory); |
| + CheckedWriteFile(WritePipeHandle(), &address, sizeof(address)); |
| + |
| + // Wait for the parent to signal that it's OK to exit by closing its end of |
| + // the pipe. |
| + CheckedReadFileAtEOF(ReadPipeHandle()); |
| + } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ProcessReaderChildThreadSuspendCount); |
| +}; |
| + |
| +TEST(ProcessReaderWin, ChildThreadSuspendCounts) { |
| + WinMultiprocess::Run<ProcessReaderChildThreadSuspendCount>(); |
| +} |
| + |
| } // namespace |
| } // namespace test |
| } // namespace crashpad |