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

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

Issue 1339813002: win: Fix ProcessInfo test when running on x86 host OS (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@fix-pipe-connection-leak
Patch Set: switch to IsWow64Process 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 23 matching lines...) Expand all
34 34
35 time_t GetTimestampForModule(HMODULE module) { 35 time_t GetTimestampForModule(HMODULE module) {
36 char filename[MAX_PATH]; 36 char filename[MAX_PATH];
37 // `char` and GetModuleFileNameA because ImageLoad is ANSI only. 37 // `char` and GetModuleFileNameA because ImageLoad is ANSI only.
38 if (!GetModuleFileNameA(module, filename, arraysize(filename))) 38 if (!GetModuleFileNameA(module, filename, arraysize(filename)))
39 return 0; 39 return 0;
40 LOADED_IMAGE* loaded_image = ImageLoad(filename, nullptr); 40 LOADED_IMAGE* loaded_image = ImageLoad(filename, nullptr);
41 return loaded_image->FileHeader->FileHeader.TimeDateStamp; 41 return loaded_image->FileHeader->FileHeader.TimeDateStamp;
42 } 42 }
43 43
44 bool IsProcessWow64(HANDLE process_handle) {
45 static decltype(IsWow64Process)* is_wow64_process =
46 reinterpret_cast<decltype(IsWow64Process)*>(
47 GetProcAddress(LoadLibrary(L"kernel32.dll"), "IsWow64Process"));
48 if (!is_wow64_process)
49 return false;
50 BOOL is_wow64;
51 if (!is_wow64_process(process_handle, &is_wow64)) {
52 PLOG(ERROR) << "IsWow64Process";
53 return false;
54 }
55 return is_wow64;
56 }
57
44 TEST(ProcessInfo, Self) { 58 TEST(ProcessInfo, Self) {
45 ProcessInfo process_info; 59 ProcessInfo process_info;
46 ASSERT_TRUE(process_info.Initialize(GetCurrentProcess())); 60 ASSERT_TRUE(process_info.Initialize(GetCurrentProcess()));
47 EXPECT_EQ(GetCurrentProcessId(), process_info.ProcessID()); 61 EXPECT_EQ(GetCurrentProcessId(), process_info.ProcessID());
48 EXPECT_GT(process_info.ParentProcessID(), 0u); 62 EXPECT_GT(process_info.ParentProcessID(), 0u);
49 63
50 #if defined(ARCH_CPU_64_BITS) 64 #if defined(ARCH_CPU_64_BITS)
51 EXPECT_TRUE(process_info.Is64Bit()); 65 EXPECT_TRUE(process_info.Is64Bit());
52 EXPECT_FALSE(process_info.IsWow64()); 66 EXPECT_FALSE(process_info.IsWow64());
53 #else 67 #else
54 EXPECT_FALSE(process_info.Is64Bit()); 68 EXPECT_FALSE(process_info.Is64Bit());
55 // Assume we won't be running these tests on a 32 bit host OS. 69 if (IsProcessWow64(GetCurrentProcess()))
56 EXPECT_TRUE(process_info.IsWow64()); 70 EXPECT_TRUE(process_info.IsWow64());
71 else
72 EXPECT_FALSE(process_info.IsWow64());
57 #endif 73 #endif
58 74
59 std::wstring command_line; 75 std::wstring command_line;
60 EXPECT_TRUE(process_info.CommandLine(&command_line)); 76 EXPECT_TRUE(process_info.CommandLine(&command_line));
61 EXPECT_EQ(std::wstring(GetCommandLine()), command_line); 77 EXPECT_EQ(std::wstring(GetCommandLine()), command_line);
62 78
63 std::vector<ProcessInfo::Module> modules; 79 std::vector<ProcessInfo::Module> modules;
64 EXPECT_TRUE(process_info.Modules(&modules)); 80 EXPECT_TRUE(process_info.Modules(&modules));
65 ASSERT_GE(modules.size(), 2u); 81 ASSERT_GE(modules.size(), 2u);
66 const wchar_t kSelfName[] = L"\\crashpad_util_test.exe"; 82 const wchar_t kSelfName[] = L"\\crashpad_util_test.exe";
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 TestOtherProcess(L"x64"); 177 TestOtherProcess(L"x64");
162 } 178 }
163 179
164 TEST(ProcessInfo, OtherProcessX86) { 180 TEST(ProcessInfo, OtherProcessX86) {
165 TestOtherProcess(L"x86"); 181 TestOtherProcess(L"x86");
166 } 182 }
167 183
168 } // namespace 184 } // namespace
169 } // namespace test 185 } // namespace test
170 } // namespace crashpad 186 } // namespace crashpad
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698