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

Side by Side Diff: util/win/process_info_test.cc

Issue 981393003: win: Support reading process info cross-bitness (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@64-port-test-2
Patch Set: rebase Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « util/win/process_info.cc ('k') | util/win/process_structs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ASSERT_GE(modules.size(), 2u); 54 ASSERT_GE(modules.size(), 2u);
55 const wchar_t kSelfName[] = L"\\crashpad_util_test.exe"; 55 const wchar_t kSelfName[] = L"\\crashpad_util_test.exe";
56 ASSERT_GE(modules[0].size(), wcslen(kSelfName)); 56 ASSERT_GE(modules[0].size(), wcslen(kSelfName));
57 EXPECT_EQ(kSelfName, 57 EXPECT_EQ(kSelfName,
58 modules[0].substr(modules[0].size() - wcslen(kSelfName))); 58 modules[0].substr(modules[0].size() - wcslen(kSelfName)));
59 ASSERT_GE(modules[1].size(), wcslen(kNtdllName)); 59 ASSERT_GE(modules[1].size(), wcslen(kNtdllName));
60 EXPECT_EQ(kNtdllName, 60 EXPECT_EQ(kNtdllName,
61 modules[1].substr(modules[1].size() - wcslen(kNtdllName))); 61 modules[1].substr(modules[1].size() - wcslen(kNtdllName)));
62 } 62 }
63 63
64 TEST(ProcessInfo, SomeOtherProcess) { 64 void TestOtherProcess(const std::wstring& child_name_suffix) {
65 ProcessInfo process_info; 65 ProcessInfo process_info;
66 66
67 ::UUID system_uuid; 67 ::UUID system_uuid;
68 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid)); 68 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid));
69 UUID started_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1)); 69 UUID started_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1));
70 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid)); 70 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid));
71 UUID done_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1)); 71 UUID done_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1));
72 72
73 ScopedKernelHANDLE started( 73 ScopedKernelHANDLE started(
74 CreateEvent(nullptr, true, false, started_uuid.ToString16().c_str())); 74 CreateEvent(nullptr, true, false, started_uuid.ToString16().c_str()));
75 ASSERT_TRUE(started.get()); 75 ASSERT_TRUE(started.get());
76 ScopedKernelHANDLE done( 76 ScopedKernelHANDLE done(
77 CreateEvent(nullptr, true, false, done_uuid.ToString16().c_str())); 77 CreateEvent(nullptr, true, false, done_uuid.ToString16().c_str()));
78 ASSERT_TRUE(done.get()); 78 ASSERT_TRUE(done.get());
79 79
80 base::FilePath test_executable = Paths::Executable(); 80 base::FilePath test_executable = Paths::Executable();
81 std::wstring child_test_executable = 81 std::wstring child_test_executable =
82 test_executable.RemoveFinalExtension().value() + 82 test_executable.RemoveFinalExtension().value() +
83 L"_process_info_test_child.exe"; 83 L"_process_info_test_child_" + child_name_suffix + L".exe";
84 // TODO(scottmg): Command line escaping utility. 84 // TODO(scottmg): Command line escaping utility.
85 std::wstring command_line = child_test_executable + L" " + 85 std::wstring command_line = child_test_executable + L" " +
86 started_uuid.ToString16() + L" " + 86 started_uuid.ToString16() + L" " +
87 done_uuid.ToString16(); 87 done_uuid.ToString16();
88 STARTUPINFO startup_info = {0}; 88 STARTUPINFO startup_info = {0};
89 startup_info.cb = sizeof(startup_info); 89 startup_info.cb = sizeof(startup_info);
90 PROCESS_INFORMATION process_information; 90 PROCESS_INFORMATION process_information;
91 ASSERT_TRUE(CreateProcess(child_test_executable.c_str(), 91 ASSERT_TRUE(CreateProcess(child_test_executable.c_str(),
92 &command_line[0], 92 &command_line[0],
93 nullptr, 93 nullptr,
(...skipping 12 matching lines...) Expand all
106 ASSERT_EQ(WaitForSingleObject(started.get(), INFINITE), WAIT_OBJECT_0); 106 ASSERT_EQ(WaitForSingleObject(started.get(), INFINITE), WAIT_OBJECT_0);
107 107
108 ASSERT_TRUE(process_info.Initialize(process_information.hProcess)); 108 ASSERT_TRUE(process_info.Initialize(process_information.hProcess));
109 109
110 // Tell the test it's OK to shut down now that we've read our data. 110 // Tell the test it's OK to shut down now that we've read our data.
111 SetEvent(done.get()); 111 SetEvent(done.get());
112 112
113 std::vector<std::wstring> modules; 113 std::vector<std::wstring> modules;
114 EXPECT_TRUE(process_info.Modules(&modules)); 114 EXPECT_TRUE(process_info.Modules(&modules));
115 ASSERT_GE(modules.size(), 3u); 115 ASSERT_GE(modules.size(), 3u);
116 const wchar_t kChildName[] = 116 std::wstring child_name = L"\\crashpad_util_test_process_info_test_child_" +
117 L"\\crashpad_util_test_process_info_test_child.exe"; 117 child_name_suffix + L".exe";
118 ASSERT_GE(modules[0].size(), wcslen(kChildName)); 118 ASSERT_GE(modules[0].size(), child_name.size());
119 EXPECT_EQ(kChildName, 119 EXPECT_EQ(child_name,
120 modules[0].substr(modules[0].size() - wcslen(kChildName))); 120 modules[0].substr(modules[0].size() - child_name.size()));
121 ASSERT_GE(modules[1].size(), wcslen(kNtdllName)); 121 ASSERT_GE(modules[1].size(), wcslen(kNtdllName));
122 EXPECT_EQ(kNtdllName, 122 EXPECT_EQ(kNtdllName,
123 modules[1].substr(modules[1].size() - wcslen(kNtdllName))); 123 modules[1].substr(modules[1].size() - wcslen(kNtdllName)));
124 // lz32.dll is an uncommonly-used-but-always-available module that the test 124 // lz32.dll is an uncommonly-used-but-always-available module that the test
125 // binary manually loads. 125 // binary manually loads.
126 const wchar_t kLz32dllName[] = L"\\lz32.dll"; 126 const wchar_t kLz32dllName[] = L"\\lz32.dll";
127 ASSERT_GE(modules.back().size(), wcslen(kLz32dllName)); 127 ASSERT_GE(modules.back().size(), wcslen(kLz32dllName));
128 EXPECT_EQ( 128 EXPECT_EQ(
129 kLz32dllName, 129 kLz32dllName,
130 modules.back().substr(modules.back().size() - wcslen(kLz32dllName))); 130 modules.back().substr(modules.back().size() - wcslen(kLz32dllName)));
131 } 131 }
132 132
133 TEST(ProcessInfo, OtherProcessX64) {
134 TestOtherProcess(L"x64");
135 }
136
137 TEST(ProcessInfo, OtherProcessX86) {
138 TestOtherProcess(L"x86");
139 }
140
133 } // namespace 141 } // namespace
134 } // namespace test 142 } // namespace test
135 } // namespace crashpad 143 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/win/process_info.cc ('k') | util/win/process_structs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698