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

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

Issue 1139103003: win: Fix module timestamp 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 unified diff | Download patch
« no previous file with comments | « util/util_test.gyp ('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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "util/win/process_info.h" 15 #include "util/win/process_info.h"
16 16
17 #include <imagehlp.h>
17 #include <rpc.h> 18 #include <rpc.h>
18 #include <wchar.h> 19 #include <wchar.h>
19 20
20 #include "base/files/file_path.h" 21 #include "base/files/file_path.h"
21 #include "build/build_config.h" 22 #include "build/build_config.h"
22 #include "gtest/gtest.h" 23 #include "gtest/gtest.h"
23 #include "test/paths.h" 24 #include "test/paths.h"
24 #include "util/file/file_io.h" 25 #include "util/file/file_io.h"
25 #include "util/misc/uuid.h" 26 #include "util/misc/uuid.h"
26 #include "util/win/scoped_handle.h" 27 #include "util/win/scoped_handle.h"
27 28
28 namespace crashpad { 29 namespace crashpad {
29 namespace test { 30 namespace test {
30 namespace { 31 namespace {
31 32
32 const wchar_t kNtdllName[] = L"\\ntdll.dll"; 33 const wchar_t kNtdllName[] = L"\\ntdll.dll";
33 34
34 time_t GetTimestampForModule(HMODULE module) { 35 time_t GetTimestampForModule(HMODULE module) {
35 wchar_t filename[MAX_PATH]; 36 char filename[MAX_PATH];
36 if (!GetModuleFileName(module, filename, arraysize(filename))) 37 // `char` and GetModuleFileNameA because ImageLoad is ANSI only.
38 if (!GetModuleFileNameA(module, filename, arraysize(filename)))
37 return 0; 39 return 0;
38 struct _stat stat_buf; 40 LOADED_IMAGE* loaded_image = ImageLoad(filename, nullptr);
39 int rv = _wstat(filename, &stat_buf); 41 return loaded_image->FileHeader->FileHeader.TimeDateStamp;
40 EXPECT_EQ(0, rv);
41 if (rv != 0)
42 return 0;
43 return stat_buf.st_mtime;
44 } 42 }
45 43
46 TEST(ProcessInfo, Self) { 44 TEST(ProcessInfo, Self) {
47 ProcessInfo process_info; 45 ProcessInfo process_info;
48 ASSERT_TRUE(process_info.Initialize(GetCurrentProcess())); 46 ASSERT_TRUE(process_info.Initialize(GetCurrentProcess()));
49 EXPECT_EQ(GetCurrentProcessId(), process_info.ProcessID()); 47 EXPECT_EQ(GetCurrentProcessId(), process_info.ProcessID());
50 EXPECT_GT(process_info.ParentProcessID(), 0u); 48 EXPECT_GT(process_info.ParentProcessID(), 0u);
51 49
52 #if defined(ARCH_CPU_64_BITS) 50 #if defined(ARCH_CPU_64_BITS)
53 EXPECT_TRUE(process_info.Is64Bit()); 51 EXPECT_TRUE(process_info.Is64Bit());
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 TestOtherProcess(L"x64"); 161 TestOtherProcess(L"x64");
164 } 162 }
165 163
166 TEST(ProcessInfo, OtherProcessX86) { 164 TEST(ProcessInfo, OtherProcessX86) {
167 TestOtherProcess(L"x86"); 165 TestOtherProcess(L"x86");
168 } 166 }
169 167
170 } // namespace 168 } // namespace
171 } // namespace test 169 } // namespace test
172 } // namespace crashpad 170 } // namespace crashpad
OLDNEW
« no previous file with comments | « util/util_test.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698