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

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

Issue 1052813002: win: make CrashpadInfo retrievable (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fix mac includes Created 5 years, 8 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
« util/win/process_info.cc ('K') | « util/win/process_info.cc ('k') | no next file » | 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #else 42 #else
43 EXPECT_FALSE(process_info.Is64Bit()); 43 EXPECT_FALSE(process_info.Is64Bit());
44 // Assume we won't be running these tests on a 32 bit host OS. 44 // Assume we won't be running these tests on a 32 bit host OS.
45 EXPECT_TRUE(process_info.IsWow64()); 45 EXPECT_TRUE(process_info.IsWow64());
46 #endif 46 #endif
47 47
48 std::wstring command_line; 48 std::wstring command_line;
49 EXPECT_TRUE(process_info.CommandLine(&command_line)); 49 EXPECT_TRUE(process_info.CommandLine(&command_line));
50 EXPECT_EQ(std::wstring(GetCommandLine()), command_line); 50 EXPECT_EQ(std::wstring(GetCommandLine()), command_line);
51 51
52 std::vector<std::wstring> modules; 52 std::vector<ProcessInfo::Module> modules;
53 EXPECT_TRUE(process_info.Modules(&modules)); 53 EXPECT_TRUE(process_info.Modules(&modules));
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].name.size(), wcslen(kSelfName));
57 EXPECT_EQ(kSelfName, 57 EXPECT_EQ(kSelfName,
58 modules[0].substr(modules[0].size() - wcslen(kSelfName))); 58 modules[0].name.substr(modules[0].name.size() - wcslen(kSelfName)));
59 ASSERT_GE(modules[1].size(), wcslen(kNtdllName)); 59 ASSERT_GE(modules[1].name.size(), wcslen(kNtdllName));
60 EXPECT_EQ(kNtdllName, 60 EXPECT_EQ(
61 modules[1].substr(modules[1].size() - wcslen(kNtdllName))); 61 kNtdllName,
62 modules[1].name.substr(modules[1].name.size() - wcslen(kNtdllName)));
Mark Mentovai 2015/04/29 19:37:16 Verify the sanity of the two other fields in Proce
scottmg 2015/04/30 03:31:32 Done.
62 } 63 }
63 64
64 void TestOtherProcess(const std::wstring& child_name_suffix) { 65 void TestOtherProcess(const std::wstring& child_name_suffix) {
65 ProcessInfo process_info; 66 ProcessInfo process_info;
66 67
67 ::UUID system_uuid; 68 ::UUID system_uuid;
68 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid)); 69 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid));
69 UUID started_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1)); 70 UUID started_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1));
70 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid)); 71 ASSERT_EQ(RPC_S_OK, UuidCreate(&system_uuid));
71 UUID done_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1)); 72 UUID done_uuid(reinterpret_cast<const uint8_t*>(&system_uuid.Data1));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ScopedKernelHANDLE process_handle(process_information.hProcess); 104 ScopedKernelHANDLE process_handle(process_information.hProcess);
104 105
105 // Wait until the test has completed initialization. 106 // Wait until the test has completed initialization.
106 ASSERT_EQ(WaitForSingleObject(started.get(), INFINITE), WAIT_OBJECT_0); 107 ASSERT_EQ(WaitForSingleObject(started.get(), INFINITE), WAIT_OBJECT_0);
107 108
108 ASSERT_TRUE(process_info.Initialize(process_information.hProcess)); 109 ASSERT_TRUE(process_info.Initialize(process_information.hProcess));
109 110
110 // Tell the test it's OK to shut down now that we've read our data. 111 // Tell the test it's OK to shut down now that we've read our data.
111 SetEvent(done.get()); 112 SetEvent(done.get());
112 113
113 std::vector<std::wstring> modules; 114 std::vector<ProcessInfo::Module> modules;
114 EXPECT_TRUE(process_info.Modules(&modules)); 115 EXPECT_TRUE(process_info.Modules(&modules));
115 ASSERT_GE(modules.size(), 3u); 116 ASSERT_GE(modules.size(), 3u);
116 std::wstring child_name = L"\\crashpad_util_test_process_info_test_child_" + 117 std::wstring child_name = L"\\crashpad_util_test_process_info_test_child_" +
117 child_name_suffix + L".exe"; 118 child_name_suffix + L".exe";
118 ASSERT_GE(modules[0].size(), child_name.size()); 119 ASSERT_GE(modules[0].name.size(), child_name.size());
119 EXPECT_EQ(child_name, 120 EXPECT_EQ(child_name,
120 modules[0].substr(modules[0].size() - child_name.size())); 121 modules[0].name.substr(modules[0].name.size() - child_name.size()));
121 ASSERT_GE(modules[1].size(), wcslen(kNtdllName)); 122 ASSERT_GE(modules[1].name.size(), wcslen(kNtdllName));
122 EXPECT_EQ(kNtdllName, 123 EXPECT_EQ(
123 modules[1].substr(modules[1].size() - wcslen(kNtdllName))); 124 kNtdllName,
125 modules[1].name.substr(modules[1].name.size() - wcslen(kNtdllName)));
124 // lz32.dll is an uncommonly-used-but-always-available module that the test 126 // lz32.dll is an uncommonly-used-but-always-available module that the test
125 // binary manually loads. 127 // binary manually loads.
126 const wchar_t kLz32dllName[] = L"\\lz32.dll"; 128 const wchar_t kLz32dllName[] = L"\\lz32.dll";
127 ASSERT_GE(modules.back().size(), wcslen(kLz32dllName)); 129 ASSERT_GE(modules.back().name.size(), wcslen(kLz32dllName));
128 EXPECT_EQ( 130 EXPECT_EQ(kLz32dllName,
129 kLz32dllName, 131 modules.back().name.substr(modules.back().name.size() -
130 modules.back().substr(modules.back().size() - wcslen(kLz32dllName))); 132 wcslen(kLz32dllName)));
131 } 133 }
132 134
133 TEST(ProcessInfo, OtherProcessX64) { 135 TEST(ProcessInfo, OtherProcessX64) {
134 TestOtherProcess(L"x64"); 136 TestOtherProcess(L"x64");
135 } 137 }
136 138
137 TEST(ProcessInfo, OtherProcessX86) { 139 TEST(ProcessInfo, OtherProcessX86) {
138 TestOtherProcess(L"x86"); 140 TestOtherProcess(L"x86");
139 } 141 }
140 142
141 } // namespace 143 } // namespace
142 } // namespace test 144 } // namespace test
143 } // namespace crashpad 145 } // namespace crashpad
OLDNEW
« util/win/process_info.cc ('K') | « util/win/process_info.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698