mirror of
https://github.com/chromium/crashpad.git
synced 2025-03-09 14:06:33 +00:00
win: Fix module timestamp test
This test was added in https://codereview.chromium.org/1052813002. It was previously checking the timestamp from in-memory module traversal vs. the disk mtime. This is flaky (of course) because it depends on the linker writing the header and closing the file during the same time quantum. So the bots occasionally failed with: [ RUN ] ProcessInfo.Self e:\b\build\slave\chromium_win_dbg\build\crashpad\util\win\process_info_test.cc(86): error: Value of: GetTimestampForModule(GetModuleHandleW(nullptr)) Actual: 1431650338 Expected: modules[0].timestamp Which is: 1431650337 Instead, use imagehlp to pull the timestamp out of the header so that it matches the header value that will be the in-memory timestamp. R=cpu@chromium.org TBR=mark@chromium.org Review URL: https://codereview.chromium.org/1139103003
This commit is contained in:
parent
b0889f61ee
commit
8171e6f765
@ -96,6 +96,7 @@
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-limagehlp.lib',
|
||||
'-lrpcrt4.lib',
|
||||
],
|
||||
},
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "util/win/process_info.h"
|
||||
|
||||
#include <imagehlp.h>
|
||||
#include <rpc.h>
|
||||
#include <wchar.h>
|
||||
|
||||
@ -32,15 +33,12 @@ namespace {
|
||||
const wchar_t kNtdllName[] = L"\\ntdll.dll";
|
||||
|
||||
time_t GetTimestampForModule(HMODULE module) {
|
||||
wchar_t filename[MAX_PATH];
|
||||
if (!GetModuleFileName(module, filename, arraysize(filename)))
|
||||
char filename[MAX_PATH];
|
||||
// `char` and GetModuleFileNameA because ImageLoad is ANSI only.
|
||||
if (!GetModuleFileNameA(module, filename, arraysize(filename)))
|
||||
return 0;
|
||||
struct _stat stat_buf;
|
||||
int rv = _wstat(filename, &stat_buf);
|
||||
EXPECT_EQ(0, rv);
|
||||
if (rv != 0)
|
||||
return 0;
|
||||
return stat_buf.st_mtime;
|
||||
LOADED_IMAGE* loaded_image = ImageLoad(filename, nullptr);
|
||||
return loaded_image->FileHeader->FileHeader.TimeDateStamp;
|
||||
}
|
||||
|
||||
TEST(ProcessInfo, Self) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user