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

Unified Diff: snapshot/win/process_reader_win_test.cc

Issue 1326443007: win: Fix incorrect thread suspend count due to ScopedProcessSuspend (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: assert some threads captured Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « snapshot/win/process_reader_win.cc ('k') | snapshot/win/process_snapshot_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1cb4bdda51ad37efe98fdc25f256adaf9cbcf352 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,56 @@ 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));
+
+ const auto& threads = process_reader.Threads();
+ ASSERT_FALSE(threads.empty());
+ for (const auto& thread : 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.
+ const auto& threads = process_reader.Threads();
+ ASSERT_FALSE(threads.empty());
+ for (const auto& thread : threads)
+ EXPECT_EQ(0u, thread.suspend_count);
+ }
+ }
+
+ 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
« no previous file with comments | « snapshot/win/process_reader_win.cc ('k') | snapshot/win/process_snapshot_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698