2022-09-06 19:14:07 -04:00
|
|
|
// Copyright 2015 The Crashpad Authors
|
2015-03-05 22:07:38 -08:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
#include "util/win/process_info.h"
|
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
#include <dbghelp.h>
|
2015-09-25 21:11:04 -07:00
|
|
|
#include <intrin.h>
|
2015-03-05 22:07:38 -08:00
|
|
|
#include <wchar.h>
|
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
#include <memory>
|
|
|
|
|
2024-05-01 15:17:40 -07:00
|
|
|
#include "base/containers/heap_array.h"
|
2015-03-05 22:07:38 -08:00
|
|
|
#include "base/files/file_path.h"
|
2020-06-22 20:01:51 +02:00
|
|
|
#include "base/logging.h"
|
2015-10-16 15:31:32 -07:00
|
|
|
#include "base/strings/stringprintf.h"
|
|
|
|
#include "base/strings/utf_string_conversions.h"
|
2015-03-05 22:07:38 -08:00
|
|
|
#include "build/build_config.h"
|
|
|
|
#include "gtest/gtest.h"
|
2015-10-19 13:40:50 -04:00
|
|
|
#include "test/errors.h"
|
2016-01-06 12:22:50 -05:00
|
|
|
#include "test/scoped_temp_dir.h"
|
2017-04-03 13:53:11 -04:00
|
|
|
#include "test/test_paths.h"
|
2015-09-20 11:16:31 -07:00
|
|
|
#include "test/win/child_launcher.h"
|
2015-05-01 13:48:23 -07:00
|
|
|
#include "util/file/file_io.h"
|
2017-04-28 10:08:35 -04:00
|
|
|
#include "util/misc/from_pointer_cast.h"
|
2015-11-16 13:39:01 -05:00
|
|
|
#include "util/misc/random_string.h"
|
2015-03-05 22:07:38 -08:00
|
|
|
#include "util/misc/uuid.h"
|
2015-11-02 13:59:36 -05:00
|
|
|
#include "util/win/command_line.h"
|
2015-10-19 14:32:07 -04:00
|
|
|
#include "util/win/get_function.h"
|
2015-11-05 14:00:26 -05:00
|
|
|
#include "util/win/handle.h"
|
2015-03-05 22:07:38 -08:00
|
|
|
#include "util/win/scoped_handle.h"
|
2019-07-24 15:19:03 +02:00
|
|
|
#include "util/win/scoped_registry_key.h"
|
2015-03-05 22:07:38 -08:00
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
namespace test {
|
|
|
|
namespace {
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
constexpr wchar_t kNtdllName[] = L"\\ntdll.dll";
|
2015-03-05 22:07:38 -08:00
|
|
|
|
2017-10-25 16:29:38 -04:00
|
|
|
#if !defined(ARCH_CPU_64_BITS)
|
2015-09-14 11:07:59 -07:00
|
|
|
bool IsProcessWow64(HANDLE process_handle) {
|
2015-10-19 14:32:07 -04:00
|
|
|
static const auto is_wow64_process =
|
|
|
|
GET_FUNCTION(L"kernel32.dll", ::IsWow64Process);
|
2015-09-14 11:07:59 -07:00
|
|
|
if (!is_wow64_process)
|
|
|
|
return false;
|
|
|
|
BOOL is_wow64;
|
|
|
|
if (!is_wow64_process(process_handle, &is_wow64)) {
|
|
|
|
PLOG(ERROR) << "IsWow64Process";
|
|
|
|
return false;
|
|
|
|
}
|
2015-10-22 14:32:13 -07:00
|
|
|
return !!is_wow64;
|
2015-09-14 11:07:59 -07:00
|
|
|
}
|
2017-10-25 16:29:38 -04:00
|
|
|
#endif
|
2015-09-14 11:07:59 -07:00
|
|
|
|
2015-09-25 21:11:04 -07:00
|
|
|
void VerifyAddressInInCodePage(const ProcessInfo& process_info,
|
|
|
|
WinVMAddress code_address) {
|
|
|
|
// Make sure the child code address is an code page address with the right
|
|
|
|
// information.
|
2015-12-08 15:38:17 -05:00
|
|
|
const ProcessInfo::MemoryBasicInformation64Vector& memory_info =
|
2015-10-07 12:23:08 -07:00
|
|
|
process_info.MemoryInfo();
|
2015-09-25 21:11:04 -07:00
|
|
|
bool found_region = false;
|
|
|
|
for (const auto& mi : memory_info) {
|
2015-10-07 12:23:08 -07:00
|
|
|
if (mi.BaseAddress <= code_address &&
|
|
|
|
mi.BaseAddress + mi.RegionSize > code_address) {
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(mi.State, static_cast<DWORD>(MEM_COMMIT));
|
|
|
|
EXPECT_EQ(mi.Protect, static_cast<DWORD>(PAGE_EXECUTE_READ));
|
|
|
|
EXPECT_EQ(mi.Type, static_cast<DWORD>(MEM_IMAGE));
|
2015-09-25 21:11:04 -07:00
|
|
|
EXPECT_FALSE(found_region);
|
|
|
|
found_region = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(found_region);
|
|
|
|
}
|
|
|
|
|
2015-03-05 22:07:38 -08:00
|
|
|
TEST(ProcessInfo, Self) {
|
|
|
|
ProcessInfo process_info;
|
|
|
|
ASSERT_TRUE(process_info.Initialize(GetCurrentProcess()));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(process_info.ProcessID(), GetCurrentProcessId());
|
2015-03-05 22:07:38 -08:00
|
|
|
EXPECT_GT(process_info.ParentProcessID(), 0u);
|
|
|
|
|
|
|
|
#if defined(ARCH_CPU_64_BITS)
|
|
|
|
EXPECT_TRUE(process_info.Is64Bit());
|
|
|
|
EXPECT_FALSE(process_info.IsWow64());
|
|
|
|
#else
|
|
|
|
EXPECT_FALSE(process_info.Is64Bit());
|
2015-09-14 11:07:59 -07:00
|
|
|
if (IsProcessWow64(GetCurrentProcess()))
|
|
|
|
EXPECT_TRUE(process_info.IsWow64());
|
|
|
|
else
|
|
|
|
EXPECT_FALSE(process_info.IsWow64());
|
2015-03-05 22:07:38 -08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
std::wstring command_line;
|
|
|
|
EXPECT_TRUE(process_info.CommandLine(&command_line));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(command_line, std::wstring(GetCommandLine()));
|
2015-03-05 22:07:38 -08:00
|
|
|
|
2015-05-01 13:48:23 -07:00
|
|
|
std::vector<ProcessInfo::Module> modules;
|
2015-03-05 22:07:38 -08:00
|
|
|
EXPECT_TRUE(process_info.Modules(&modules));
|
|
|
|
ASSERT_GE(modules.size(), 2u);
|
2017-11-01 10:46:35 -04:00
|
|
|
std::wstring self_name =
|
|
|
|
std::wstring(1, '\\') +
|
|
|
|
TestPaths::ExpectedExecutableBasename(L"crashpad_util_test").value();
|
|
|
|
ASSERT_GE(modules[0].name.size(), self_name.size());
|
|
|
|
EXPECT_EQ(modules[0].name.substr(modules[0].name.size() - self_name.size()),
|
|
|
|
self_name);
|
2015-05-01 13:48:23 -07:00
|
|
|
ASSERT_GE(modules[1].name.size(), wcslen(kNtdllName));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(modules[1].name.substr(modules[1].name.size() - wcslen(kNtdllName)),
|
|
|
|
kNtdllName);
|
2015-05-01 13:48:23 -07:00
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(modules[0].dll_base,
|
|
|
|
reinterpret_cast<uintptr_t>(GetModuleHandle(nullptr)));
|
|
|
|
EXPECT_EQ(modules[1].dll_base,
|
|
|
|
reinterpret_cast<uintptr_t>(GetModuleHandle(L"ntdll.dll")));
|
2015-05-01 13:48:23 -07:00
|
|
|
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_GT(modules[0].size, 0u);
|
|
|
|
EXPECT_GT(modules[1].size, 0u);
|
2015-05-01 13:48:23 -07:00
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(modules[0].timestamp,
|
|
|
|
GetTimestampForLoadedLibrary(GetModuleHandle(nullptr)));
|
2015-05-01 13:48:23 -07:00
|
|
|
// System modules are forced to particular stamps and the file header values
|
|
|
|
// don't match the on-disk times. Just make sure we got some data here.
|
|
|
|
EXPECT_GT(modules[1].timestamp, 0);
|
2015-09-25 21:11:04 -07:00
|
|
|
|
|
|
|
// Find something we know is a code address and confirm expected memory
|
|
|
|
// information settings.
|
|
|
|
VerifyAddressInInCodePage(process_info,
|
2017-04-28 10:08:35 -04:00
|
|
|
FromPointerCast<WinVMAddress>(_ReturnAddress()));
|
2015-03-05 22:07:38 -08:00
|
|
|
}
|
|
|
|
|
2017-11-01 10:37:01 -04:00
|
|
|
void TestOtherProcess(TestPaths::Architecture architecture) {
|
2015-03-05 22:07:38 -08:00
|
|
|
ProcessInfo process_info;
|
|
|
|
|
2016-11-10 15:11:20 -05:00
|
|
|
UUID done_uuid;
|
|
|
|
done_uuid.InitializeWithNew();
|
2015-03-05 22:07:38 -08:00
|
|
|
|
|
|
|
ScopedKernelHANDLE done(
|
2020-09-12 09:20:14 +02:00
|
|
|
CreateEvent(nullptr, true, false, done_uuid.ToWString().c_str()));
|
2017-03-24 15:35:40 -04:00
|
|
|
ASSERT_TRUE(done.get()) << ErrorMessage("CreateEvent");
|
2015-03-05 22:07:38 -08:00
|
|
|
|
2017-11-01 10:37:01 -04:00
|
|
|
base::FilePath child_test_executable =
|
|
|
|
TestPaths::BuildArtifact(L"util",
|
|
|
|
L"process_info_test_child",
|
|
|
|
TestPaths::FileType::kExecutable,
|
|
|
|
architecture);
|
2015-09-22 09:20:23 -07:00
|
|
|
std::wstring args;
|
2020-09-12 09:20:14 +02:00
|
|
|
AppendCommandLineArgument(done_uuid.ToWString(), &args);
|
2015-09-22 09:20:23 -07:00
|
|
|
|
|
|
|
ChildLauncher child(child_test_executable, args);
|
2017-04-19 13:38:26 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(child.Start());
|
2015-03-05 22:07:38 -08:00
|
|
|
|
2015-09-25 21:11:04 -07:00
|
|
|
// The child sends us a code address we can look up in the memory map.
|
|
|
|
WinVMAddress code_address;
|
Make file_io reads more rational and predictable
ReadFile() attempted to continue reading after a short read. In most
cases, this is fine. However, ReadFile() would keep trying to fill a
partially-filled buffer until experiencing a 0-length read(), signaling
end-of-file. For certain weird file descriptors like terminal input, EOF
is an ephemeral condition, and attempting to read beyond EOF doesn’t
actually return 0 (EOF) provided that they remain open, it will block
waiting for more input. Consequently, ReadFile() and anything based on
ReadFile() had an undocumented and quirky interface, which was that any
short read that it returned (not an underlying short read) actually
indicated EOF.
This facet of ReadFile() was unexpected, so it’s being removed. The new
behavior is that ReadFile() will return an underlying short read. The
behavior of FileReaderInterface::Read() is updated in accordance with
this change.
Upon experiencing a short read, the caller can determine the best
action. Most callers were already prepared for this behavior. Outside of
util/file, only crashpad_database_util properly implemented EOF
detection according to previous semantics, and adapting it to new
semantics is trivial.
Callers who require an exact-length read can use the new
ReadFileExactly(), or the newly renamed LoggingReadFileExactly() or
CheckedReadFileExactly(). These functions will retry following a short
read. The renamed functions were previously called LoggingReadFile() and
CheckedReadFile(), but those names implied that they were simply
wrapping ReadFile(), which is not the case. They wrapped ReadFile() and
further, insisted on a full read. Since ReadFile()’s semantics are now
changing but these functions’ are not, they’re now even more distinct
from ReadFile(), and must be renamed to avoid confusion.
Test: *
Change-Id: I06b77e0d6ad8719bd2eb67dab93a8740542dd908
Reviewed-on: https://chromium-review.googlesource.com/456676
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-03-16 13:36:38 -04:00
|
|
|
CheckedReadFileExactly(
|
2015-09-25 21:11:04 -07:00
|
|
|
child.stdout_read_handle(), &code_address, sizeof(code_address));
|
2015-03-05 22:07:38 -08:00
|
|
|
|
2015-09-20 11:16:31 -07:00
|
|
|
ASSERT_TRUE(process_info.Initialize(child.process_handle()));
|
2015-03-05 22:07:38 -08:00
|
|
|
|
|
|
|
// Tell the test it's OK to shut down now that we've read our data.
|
2017-03-24 15:35:40 -04:00
|
|
|
EXPECT_TRUE(SetEvent(done.get())) << ErrorMessage("SetEvent");
|
|
|
|
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(child.WaitForExit(), 0u);
|
2015-03-05 22:07:38 -08:00
|
|
|
|
2015-05-01 13:48:23 -07:00
|
|
|
std::vector<ProcessInfo::Module> modules;
|
2015-03-05 22:07:38 -08:00
|
|
|
EXPECT_TRUE(process_info.Modules(&modules));
|
|
|
|
ASSERT_GE(modules.size(), 3u);
|
2015-09-18 16:06:05 -07:00
|
|
|
std::wstring child_name = L"\\crashpad_util_test_process_info_test_child.exe";
|
2015-05-01 13:48:23 -07:00
|
|
|
ASSERT_GE(modules[0].name.size(), child_name.size());
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(modules[0].name.substr(modules[0].name.size() - child_name.size()),
|
|
|
|
child_name);
|
2015-05-01 13:48:23 -07:00
|
|
|
ASSERT_GE(modules[1].name.size(), wcslen(kNtdllName));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(modules[1].name.substr(modules[1].name.size() - wcslen(kNtdllName)),
|
|
|
|
kNtdllName);
|
2015-03-05 22:07:38 -08:00
|
|
|
// lz32.dll is an uncommonly-used-but-always-available module that the test
|
|
|
|
// binary manually loads.
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr wchar_t kLz32dllName[] = L"\\lz32.dll";
|
2017-12-08 16:01:18 -08:00
|
|
|
auto& lz32 = modules[modules.size() - 2];
|
|
|
|
ASSERT_GE(lz32.name.size(), wcslen(kLz32dllName));
|
|
|
|
EXPECT_EQ(lz32.name.substr(lz32.name.size() - wcslen(kLz32dllName)),
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
kLz32dllName);
|
2015-09-25 21:11:04 -07:00
|
|
|
|
2017-12-08 16:01:18 -08:00
|
|
|
// Note that the test code corrupts the PEB MemoryOrder list, whereas
|
|
|
|
// ProcessInfo::Modules() retrieves the module names via the PEB LoadOrder
|
|
|
|
// list. These are expected to point to the same strings, but theoretically
|
|
|
|
// could be separate.
|
|
|
|
auto& corrupted = modules.back();
|
|
|
|
EXPECT_EQ(corrupted.name, L"???");
|
|
|
|
|
2015-09-25 21:11:04 -07:00
|
|
|
VerifyAddressInInCodePage(process_info, code_address);
|
2015-03-05 22:07:38 -08:00
|
|
|
}
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
TEST(ProcessInfo, OtherProcess) {
|
2017-11-01 10:37:01 -04:00
|
|
|
TestOtherProcess(TestPaths::Architecture::kDefault);
|
2015-03-09 16:37:43 -07:00
|
|
|
}
|
|
|
|
|
2015-09-18 16:06:05 -07:00
|
|
|
#if defined(ARCH_CPU_64_BITS)
|
|
|
|
TEST(ProcessInfo, OtherProcessWOW64) {
|
2017-11-01 10:37:01 -04:00
|
|
|
if (!TestPaths::Has32BitBuildArtifacts()) {
|
2019-10-11 12:07:21 -04:00
|
|
|
GTEST_SKIP();
|
win: Dynamically disable WoW64 tests absent explicit 32-bit build output
Rather than having the 64-bit build assume that it lives in
out\{Debug,Release}_x64 and that it can find 32-bit build output in
out\{Debug,Release}, require the location of 32-bit build output to be
provided explicitly via the CRASHPAD_TEST_32_BIT_OUTPUT environment
variable. If this variable is not set, 64-bit tests that require 32-bit
test build output will dynamically disable themselves at runtime.
In order for this to work, a new DISABLED_TEST() macro is added to
support dynamically disabled tests. gtest does not have its own
first-class support for this
(https://groups.google.com/d/topic/googletestframework/Nwh3u7YFuN4,
https://github.com/google/googletest/issues/490) so this local solution
is used instead.
For tests via Crashpad’s own build\run_tests.py, which is how Crashpad’s
own buildbots and trybots invoke tests, CRASHPAD_TEST_32_BIT_OUTPUT is
set to a locaton compatible with the paths expected for the GYP-based
build. No test coverage is lost on Crashpad’s own buildbots and trybots.
For Crashpad tests in Chromium’s buildbots and trybots, this environment
variable will not be set, causing these tests to be dynamically
disabled.
Bug: crashpad:203, chromium:743139, chromium:777924
Change-Id: I3c0de2bf4f835e13ed5a4adda5760d6fed508126
Reviewed-on: https://chromium-review.googlesource.com/739795
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-10-26 13:48:01 -04:00
|
|
|
}
|
|
|
|
|
2017-11-01 10:37:01 -04:00
|
|
|
TestOtherProcess(TestPaths::Architecture::k32Bit);
|
2015-03-09 16:37:43 -07:00
|
|
|
}
|
2015-09-18 16:06:05 -07:00
|
|
|
#endif // ARCH_CPU_64_BITS
|
2015-03-09 16:37:43 -07:00
|
|
|
|
2015-10-01 11:47:32 -07:00
|
|
|
TEST(ProcessInfo, AccessibleRangesNone) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_FREE;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(2, 4),
|
|
|
|
memory_info);
|
|
|
|
|
|
|
|
EXPECT_TRUE(result.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, AccessibleRangesOneInside) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(2, 4),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 2u);
|
|
|
|
EXPECT_EQ(result[0].size(), 4u);
|
2015-10-01 11:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, AccessibleRangesOneTruncatedSize) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 20;
|
|
|
|
mbi.State = MEM_FREE;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 5u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
2015-10-01 11:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, AccessibleRangesOneMovedStart) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_FREE;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 20;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 10u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
2015-10-01 15:28:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, ReserveIsInaccessible) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_RESERVE;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 15:28:40 -07:00
|
|
|
mbi.RegionSize = 20;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 10u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
2015-10-01 15:28:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, PageGuardIsInaccessible) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_COMMIT;
|
|
|
|
mbi.Protect = PAGE_GUARD;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 15:28:40 -07:00
|
|
|
mbi.RegionSize = 20;
|
|
|
|
mbi.State = MEM_COMMIT;
|
|
|
|
mbi.Protect = 0;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 10u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
2015-10-01 15:28:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, PageNoAccessIsInaccessible) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_COMMIT;
|
|
|
|
mbi.Protect = PAGE_NOACCESS;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 15:28:40 -07:00
|
|
|
mbi.RegionSize = 20;
|
|
|
|
mbi.State = MEM_COMMIT;
|
|
|
|
mbi.Protect = 0;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 10u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
2015-10-01 11:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, AccessibleRangesCoalesced) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_FREE;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 2;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 12;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 5;
|
2015-10-01 15:28:40 -07:00
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(11, 4),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 11u);
|
|
|
|
EXPECT_EQ(result[0].size(), 4u);
|
2015-10-01 11:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, AccessibleRangesMiddleUnavailable) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
mbi.BaseAddress = 0;
|
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 5;
|
|
|
|
mbi.State = MEM_FREE;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 15;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 100;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 45),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 2u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 5u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
|
|
|
EXPECT_EQ(result[1].base(), 15u);
|
|
|
|
EXPECT_EQ(result[1].size(), 35u);
|
2015-10-01 11:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, RequestedBeforeMap) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(CheckedRange<WinVMAddress, WinVMSize>(5, 10),
|
|
|
|
memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 10u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
2015-10-01 11:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(ProcessInfo, RequestedAfterMap) {
|
2015-12-08 15:38:17 -05:00
|
|
|
ProcessInfo::MemoryBasicInformation64Vector memory_info;
|
2015-10-07 12:23:08 -07:00
|
|
|
MEMORY_BASIC_INFORMATION64 mbi = {0};
|
2015-10-01 11:47:32 -07:00
|
|
|
|
2015-10-07 12:23:08 -07:00
|
|
|
mbi.BaseAddress = 10;
|
2015-10-01 11:47:32 -07:00
|
|
|
mbi.RegionSize = 10;
|
|
|
|
mbi.State = MEM_COMMIT;
|
2015-10-07 12:23:08 -07:00
|
|
|
memory_info.push_back(mbi);
|
2015-10-01 11:47:32 -07:00
|
|
|
|
|
|
|
std::vector<CheckedRange<WinVMAddress, WinVMSize>> result =
|
|
|
|
GetReadableRangesOfMemoryMap(
|
|
|
|
CheckedRange<WinVMAddress, WinVMSize>(15, 100), memory_info);
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(result.size(), 1u);
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(result[0].base(), 15u);
|
|
|
|
EXPECT_EQ(result[0].size(), 5u);
|
2015-10-01 11:47:32 -07:00
|
|
|
}
|
|
|
|
|
2015-10-01 15:28:40 -07:00
|
|
|
TEST(ProcessInfo, ReadableRanges) {
|
|
|
|
SYSTEM_INFO system_info;
|
|
|
|
GetSystemInfo(&system_info);
|
|
|
|
|
|
|
|
const size_t kBlockSize = system_info.dwPageSize;
|
|
|
|
|
|
|
|
// Allocate 6 pages, and then commit the second, fourth, and fifth, and mark
|
|
|
|
// two as committed, but PAGE_NOACCESS, so we have a setup like this:
|
|
|
|
// 0 1 2 3 4 5
|
|
|
|
// +-----------------------------------------------+
|
|
|
|
// | ????? | | xxxxx | | | ????? |
|
|
|
|
// +-----------------------------------------------+
|
|
|
|
void* reserve_region =
|
|
|
|
VirtualAlloc(nullptr, kBlockSize * 6, MEM_RESERVE, PAGE_READWRITE);
|
|
|
|
ASSERT_TRUE(reserve_region);
|
|
|
|
uintptr_t reserved_as_int = reinterpret_cast<uintptr_t>(reserve_region);
|
|
|
|
void* readable1 =
|
|
|
|
VirtualAlloc(reinterpret_cast<void*>(reserved_as_int + kBlockSize),
|
|
|
|
kBlockSize,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
|
|
|
ASSERT_TRUE(readable1);
|
|
|
|
void* readable2 =
|
|
|
|
VirtualAlloc(reinterpret_cast<void*>(reserved_as_int + (kBlockSize * 3)),
|
|
|
|
kBlockSize * 2,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_READWRITE);
|
|
|
|
ASSERT_TRUE(readable2);
|
|
|
|
|
|
|
|
void* no_access =
|
|
|
|
VirtualAlloc(reinterpret_cast<void*>(reserved_as_int + (kBlockSize * 2)),
|
|
|
|
kBlockSize,
|
|
|
|
MEM_COMMIT,
|
|
|
|
PAGE_NOACCESS);
|
|
|
|
ASSERT_TRUE(no_access);
|
|
|
|
|
|
|
|
HANDLE current_process = GetCurrentProcess();
|
|
|
|
ProcessInfo info;
|
|
|
|
info.Initialize(current_process);
|
|
|
|
auto ranges = info.GetReadableRanges(
|
|
|
|
CheckedRange<WinVMAddress, WinVMSize>(reserved_as_int, kBlockSize * 6));
|
|
|
|
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(ranges.size(), 2u);
|
|
|
|
EXPECT_EQ(ranges[0].base(), reserved_as_int + kBlockSize);
|
|
|
|
EXPECT_EQ(ranges[0].size(), kBlockSize);
|
|
|
|
EXPECT_EQ(ranges[1].base(), reserved_as_int + (kBlockSize * 3));
|
|
|
|
EXPECT_EQ(ranges[1].size(), kBlockSize * 2);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
// Also make sure what we think we can read corresponds with what we can
|
|
|
|
// actually read.
|
2024-05-01 15:17:40 -07:00
|
|
|
auto into = base::HeapArray<unsigned char>::Uninit(kBlockSize * 6);
|
2015-10-01 15:28:40 -07:00
|
|
|
SIZE_T bytes_read;
|
|
|
|
|
|
|
|
EXPECT_TRUE(ReadProcessMemory(
|
2024-05-01 15:17:40 -07:00
|
|
|
current_process, readable1, into.data(), kBlockSize, &bytes_read));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(bytes_read, kBlockSize);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
EXPECT_TRUE(ReadProcessMemory(
|
2024-05-01 15:17:40 -07:00
|
|
|
current_process, readable2, into.data(), kBlockSize * 2, &bytes_read));
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(bytes_read, kBlockSize * 2);
|
2015-10-01 15:28:40 -07:00
|
|
|
|
|
|
|
EXPECT_FALSE(ReadProcessMemory(
|
2024-05-01 15:17:40 -07:00
|
|
|
current_process, no_access, into.data(), kBlockSize, &bytes_read));
|
2015-10-01 15:28:40 -07:00
|
|
|
EXPECT_FALSE(ReadProcessMemory(
|
2024-05-01 15:17:40 -07:00
|
|
|
current_process, reserve_region, into.data(), kBlockSize, &bytes_read));
|
|
|
|
EXPECT_FALSE(ReadProcessMemory(
|
|
|
|
current_process, reserve_region, into.data(), into.size(), &bytes_read));
|
2015-10-01 15:28:40 -07:00
|
|
|
}
|
|
|
|
|
2015-10-16 15:31:32 -07:00
|
|
|
TEST(ProcessInfo, Handles) {
|
|
|
|
ScopedTempDir temp_dir;
|
|
|
|
|
|
|
|
ScopedFileHandle file(LoggingOpenFileForWrite(
|
|
|
|
temp_dir.path().Append(FILE_PATH_LITERAL("test_file")),
|
|
|
|
FileWriteMode::kTruncateOrCreate,
|
|
|
|
FilePermissions::kWorldReadable));
|
|
|
|
ASSERT_TRUE(file.is_valid());
|
|
|
|
|
|
|
|
SECURITY_ATTRIBUTES security_attributes = {0};
|
2015-11-05 15:08:28 -05:00
|
|
|
security_attributes.nLength = sizeof(security_attributes);
|
2015-10-16 15:31:32 -07:00
|
|
|
security_attributes.bInheritHandle = true;
|
2015-11-05 15:08:28 -05:00
|
|
|
ScopedFileHandle inherited_file(CreateFile(
|
|
|
|
temp_dir.path().Append(FILE_PATH_LITERAL("inheritable")).value().c_str(),
|
|
|
|
GENERIC_WRITE,
|
|
|
|
0,
|
|
|
|
&security_attributes,
|
|
|
|
CREATE_NEW,
|
|
|
|
FILE_ATTRIBUTE_NORMAL,
|
|
|
|
nullptr));
|
2015-10-16 15:31:32 -07:00
|
|
|
ASSERT_TRUE(inherited_file.is_valid());
|
|
|
|
|
|
|
|
HKEY key;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
ASSERT_EQ(RegOpenKeyEx(
|
|
|
|
HKEY_CURRENT_USER, L"SOFTWARE\\Microsoft", 0, KEY_READ, &key),
|
|
|
|
ERROR_SUCCESS);
|
2015-10-16 15:31:32 -07:00
|
|
|
ScopedRegistryKey scoped_key(key);
|
|
|
|
ASSERT_TRUE(scoped_key.is_valid());
|
|
|
|
|
|
|
|
std::wstring mapping_name =
|
2020-09-12 09:20:14 +02:00
|
|
|
base::UTF8ToWide(base::StringPrintf("Local\\test_mapping_%lu_%s",
|
|
|
|
GetCurrentProcessId(),
|
|
|
|
RandomString().c_str()));
|
2015-10-16 15:31:32 -07:00
|
|
|
ScopedKernelHANDLE mapping(CreateFileMapping(INVALID_HANDLE_VALUE,
|
|
|
|
nullptr,
|
|
|
|
PAGE_READWRITE,
|
|
|
|
0,
|
|
|
|
1024,
|
|
|
|
mapping_name.c_str()));
|
2015-10-19 13:40:50 -04:00
|
|
|
ASSERT_TRUE(mapping.is_valid()) << ErrorMessage("CreateFileMapping");
|
2015-10-16 15:31:32 -07:00
|
|
|
|
|
|
|
ProcessInfo info;
|
|
|
|
info.Initialize(GetCurrentProcess());
|
|
|
|
bool found_file_handle = false;
|
|
|
|
bool found_inherited_file_handle = false;
|
|
|
|
bool found_key_handle = false;
|
|
|
|
bool found_mapping_handle = false;
|
|
|
|
for (auto handle : info.Handles()) {
|
2015-11-06 15:03:13 -05:00
|
|
|
if (handle.handle == HandleToInt(file.get())) {
|
2015-10-16 15:31:32 -07:00
|
|
|
EXPECT_FALSE(found_file_handle);
|
|
|
|
found_file_handle = true;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(handle.type_name, L"File");
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(handle.handle_count, 1u);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_NE(handle.pointer_count, 0u);
|
|
|
|
EXPECT_EQ(handle.granted_access & STANDARD_RIGHTS_ALL,
|
2017-10-25 14:04:46 -04:00
|
|
|
static_cast<uint32_t>(STANDARD_RIGHTS_READ |
|
|
|
|
STANDARD_RIGHTS_WRITE | SYNCHRONIZE));
|
|
|
|
EXPECT_EQ(handle.attributes, 0u);
|
2015-10-16 15:31:32 -07:00
|
|
|
}
|
2015-11-06 15:03:13 -05:00
|
|
|
if (handle.handle == HandleToInt(inherited_file.get())) {
|
2015-10-16 15:31:32 -07:00
|
|
|
EXPECT_FALSE(found_inherited_file_handle);
|
|
|
|
found_inherited_file_handle = true;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(handle.type_name, L"File");
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(handle.handle_count, 1u);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_NE(handle.pointer_count, 0u);
|
|
|
|
EXPECT_EQ(handle.granted_access & STANDARD_RIGHTS_ALL,
|
2017-10-25 14:04:46 -04:00
|
|
|
static_cast<uint32_t>(STANDARD_RIGHTS_READ |
|
|
|
|
STANDARD_RIGHTS_WRITE | SYNCHRONIZE));
|
2015-10-16 15:31:32 -07:00
|
|
|
|
|
|
|
// OBJ_INHERIT from ntdef.h, but including that conflicts with other
|
|
|
|
// headers.
|
2017-10-25 14:04:46 -04:00
|
|
|
constexpr uint32_t kObjInherit = 0x2;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(handle.attributes, kObjInherit);
|
2015-10-16 15:31:32 -07:00
|
|
|
}
|
2015-11-06 15:03:13 -05:00
|
|
|
if (handle.handle == HandleToInt(scoped_key.get())) {
|
2015-10-16 15:31:32 -07:00
|
|
|
EXPECT_FALSE(found_key_handle);
|
|
|
|
found_key_handle = true;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(handle.type_name, L"Key");
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(handle.handle_count, 1u);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_NE(handle.pointer_count, 0u);
|
|
|
|
EXPECT_EQ(handle.granted_access & STANDARD_RIGHTS_ALL,
|
2017-10-25 14:04:46 -04:00
|
|
|
static_cast<uint32_t>(STANDARD_RIGHTS_READ));
|
|
|
|
EXPECT_EQ(handle.attributes, 0u);
|
2015-10-16 15:31:32 -07:00
|
|
|
}
|
2015-11-06 15:03:13 -05:00
|
|
|
if (handle.handle == HandleToInt(mapping.get())) {
|
2015-10-16 15:31:32 -07:00
|
|
|
EXPECT_FALSE(found_mapping_handle);
|
|
|
|
found_mapping_handle = true;
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_EQ(handle.type_name, L"Section");
|
2017-10-25 14:04:46 -04:00
|
|
|
EXPECT_EQ(handle.handle_count, 1u);
|
test: Use (actual, [un]expected) in gtest {ASSERT,EXPECT}_{EQ,NE}
gtest used to require (expected, actual) ordering for arguments to
EXPECT_EQ and ASSERT_EQ, and in failed test assertions would identify
each side as “expected” or “actual.” Tests in Crashpad adhered to this
traditional ordering. After a gtest change in February 2016, it is now
agnostic with respect to the order of these arguments.
This change mechanically updates all uses of these macros to (actual,
expected) by reversing them. This provides consistency with our use of
the logging CHECK_EQ and DCHECK_EQ macros, and makes for better
readability by ordinary native speakers. The rough (but working!)
conversion tool is
https://chromium-review.googlesource.com/c/466727/1/rewrite_expectassert_eq.py,
and “git cl format” cleaned up its output.
EXPECT_NE and ASSERT_NE never had a preferred ordering. gtest never made
a judgment that one side or the other needed to provide an “unexpected”
value. Consequently, some code used (unexpected, actual) while other
code used (actual, unexpected). For consistency with the new EXPECT_EQ
and ASSERT_EQ usage, as well as consistency with CHECK_NE and DCHECK_NE,
this change also updates these use sites to (actual, unexpected) where
one side can be called “unexpected” as, for example, std::string::npos
can be. Unfortunately, this portion was a manual conversion.
References:
https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#binary-comparison
https://github.com/google/googletest/commit/77d6b173380332b1c1bc540532641f410ec82d65
https://github.com/google/googletest/pull/713
Change-Id: I978fef7c94183b8b1ef63f12f5ab4d6693626be3
Reviewed-on: https://chromium-review.googlesource.com/466727
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-04-04 00:35:21 -04:00
|
|
|
EXPECT_NE(handle.pointer_count, 0u);
|
|
|
|
EXPECT_EQ(handle.granted_access & STANDARD_RIGHTS_ALL,
|
2017-10-25 14:04:46 -04:00
|
|
|
static_cast<uint32_t>(DELETE | READ_CONTROL | WRITE_DAC |
|
|
|
|
WRITE_OWNER | STANDARD_RIGHTS_READ |
|
|
|
|
STANDARD_RIGHTS_WRITE));
|
|
|
|
EXPECT_EQ(handle.attributes, 0u);
|
2015-10-16 15:31:32 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(found_file_handle);
|
2015-11-05 14:00:26 -05:00
|
|
|
EXPECT_TRUE(found_inherited_file_handle);
|
2015-10-16 15:31:32 -07:00
|
|
|
EXPECT_TRUE(found_key_handle);
|
|
|
|
EXPECT_TRUE(found_mapping_handle);
|
|
|
|
}
|
|
|
|
|
2015-10-21 16:07:03 -07:00
|
|
|
TEST(ProcessInfo, OutOfRangeCheck) {
|
2024-05-01 15:17:40 -07:00
|
|
|
auto safe_memory = base::HeapArray<char>::Uninit(12345);
|
2015-10-21 16:07:03 -07:00
|
|
|
|
|
|
|
ProcessInfo info;
|
|
|
|
info.Initialize(GetCurrentProcess());
|
|
|
|
|
|
|
|
EXPECT_TRUE(
|
|
|
|
info.LoggingRangeIsFullyReadable(CheckedRange<WinVMAddress, WinVMSize>(
|
2024-05-01 15:17:40 -07:00
|
|
|
FromPointerCast<WinVMAddress>(safe_memory.data()),
|
|
|
|
safe_memory.size())));
|
2015-10-21 16:07:03 -07:00
|
|
|
EXPECT_FALSE(info.LoggingRangeIsFullyReadable(
|
|
|
|
CheckedRange<WinVMAddress, WinVMSize>(0, 1024)));
|
|
|
|
}
|
|
|
|
|
2015-03-05 22:07:38 -08:00
|
|
|
} // namespace
|
|
|
|
} // namespace test
|
|
|
|
} // namespace crashpad
|