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

Unified Diff: snapshot/win/process_reader_win_test.cc

Issue 1160843006: win: add a child ProcessReader test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: . Created 5 years, 7 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 | « no previous file | test/win/win_multiprocess.cc » ('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 38de7865a25f45cb03a637069eb7816773d21d80..d4890b8a0f33369c6983992597ff18c845dd6ee5 100644
--- a/snapshot/win/process_reader_win_test.cc
+++ b/snapshot/win/process_reader_win_test.cc
@@ -14,9 +14,11 @@
#include "snapshot/win/process_reader_win.h"
+#include <string.h>
#include <windows.h>
#include "gtest/gtest.h"
+#include "test/win/win_multiprocess.h"
namespace crashpad {
namespace test {
@@ -43,6 +45,50 @@ TEST(ProcessReaderWin, SelfBasic) {
EXPECT_STREQ(kTestMemory, buffer);
}
+const char kTestMemory[] = "Read me from another process";
+
+class ProcessReaderChild final : public WinMultiprocess {
+ public:
+ ProcessReaderChild() : WinMultiprocess() {}
+ ~ProcessReaderChild() {}
+
+ private:
+ void WinMultiprocessParent() override {
+ ProcessReaderWin process_reader;
+ ASSERT_TRUE(process_reader.Initialize(ChildProcess()));
+
+#if !defined(ARCH_CPU_64_BITS)
+ EXPECT_FALSE(process_reader.Is64Bit());
+#else
+ EXPECT_TRUE(process_reader.Is64Bit());
+#endif
+
+ WinVMAddress address;
+ CheckedReadFile(ReadPipeHandle(), &address, sizeof(address));
+
+ char buffer[sizeof(kTestMemory)];
+ ASSERT_TRUE(
+ process_reader.ReadMemory(address, sizeof(kTestMemory), &buffer));
+ EXPECT_EQ(0, strcmp(kTestMemory, buffer));
+ }
+
+ 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(ProcessReaderChild);
+};
+
+TEST(ProcessReaderWin, ChildBasic) {
+ ProcessReaderChild process_reader_child;
+ process_reader_child.Run();
+}
+
TEST(ProcessReaderWin, SelfOneThread) {
ProcessReaderWin process_reader;
ASSERT_TRUE(process_reader.Initialize(GetCurrentProcess()));
« no previous file with comments | « no previous file | test/win/win_multiprocess.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698