2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2014 The Crashpad Authors
|
2014-10-17 18:00:41 -04: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 "minidump/minidump_crashpad_info_writer.h"
|
|
|
|
|
|
2015-02-04 17:30:03 -08:00
|
|
|
|
#include <windows.h>
|
2014-10-17 18:00:41 -04:00
|
|
|
|
#include <dbghelp.h>
|
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2015-12-09 17:36:32 -05:00
|
|
|
|
#include <utility>
|
2015-02-17 17:38:02 -05:00
|
|
|
|
|
2014-10-17 18:00:41 -04:00
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
#include "minidump/minidump_extensions.h"
|
|
|
|
|
#include "minidump/minidump_file_writer.h"
|
2014-10-24 14:58:53 -04:00
|
|
|
|
#include "minidump/minidump_module_crashpad_info_writer.h"
|
2015-02-17 17:38:02 -05:00
|
|
|
|
#include "minidump/minidump_simple_string_dictionary_writer.h"
|
2014-10-20 12:11:14 -04:00
|
|
|
|
#include "minidump/test/minidump_file_writer_test_util.h"
|
2014-11-07 11:38:13 -05:00
|
|
|
|
#include "minidump/test/minidump_string_writer_test_util.h"
|
2014-10-22 18:35:18 -04:00
|
|
|
|
#include "minidump/test/minidump_writable_test_util.h"
|
2014-11-07 11:38:13 -05:00
|
|
|
|
#include "snapshot/test/test_module_snapshot.h"
|
|
|
|
|
#include "snapshot/test/test_process_snapshot.h"
|
2015-02-18 14:15:38 -05:00
|
|
|
|
#include "util/file/string_file.h"
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
|
|
|
|
namespace crashpad {
|
|
|
|
|
namespace test {
|
|
|
|
|
namespace {
|
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
|
void GetCrashpadInfoStream(
|
|
|
|
|
const std::string& file_contents,
|
|
|
|
|
const MinidumpCrashpadInfo** crashpad_info,
|
|
|
|
|
const MinidumpSimpleStringDictionary** simple_annotations,
|
|
|
|
|
const MinidumpModuleCrashpadInfoList** module_list) {
|
2014-10-21 14:15:07 -04:00
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
2014-10-17 18:00:41 -04:00
|
|
|
|
const MINIDUMP_HEADER* header =
|
2014-10-21 14:15:07 -04:00
|
|
|
|
MinidumpHeaderAtStart(file_contents, &directory);
|
2014-10-17 18:00:41 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
|
2014-10-21 14:15:07 -04:00
|
|
|
|
ASSERT_TRUE(directory);
|
2014-10-17 18:00:41 -04: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
|
|
|
|
ASSERT_EQ(directory[0].StreamType, kMinidumpStreamTypeCrashpadInfo);
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2014-10-22 18:35:18 -04:00
|
|
|
|
*crashpad_info = MinidumpWritableAtLocationDescriptor<MinidumpCrashpadInfo>(
|
|
|
|
|
file_contents, directory[0].Location);
|
|
|
|
|
ASSERT_TRUE(*crashpad_info);
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
|
*simple_annotations =
|
|
|
|
|
MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
|
|
|
|
|
file_contents, (*crashpad_info)->simple_annotations);
|
|
|
|
|
|
2014-10-24 14:44:55 -04:00
|
|
|
|
*module_list =
|
|
|
|
|
MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfoList>(
|
|
|
|
|
file_contents, (*crashpad_info)->module_list);
|
2014-10-17 18:00:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpCrashpadInfoWriter, Empty) {
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto crashpad_info_writer = std::make_unique<MinidumpCrashpadInfoWriter>();
|
2014-11-07 11:38:13 -05:00
|
|
|
|
EXPECT_FALSE(crashpad_info_writer->IsUseful());
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2015-02-05 08:48:24 -08:00
|
|
|
|
const MinidumpCrashpadInfo* crashpad_info = nullptr;
|
2015-02-17 17:38:02 -05:00
|
|
|
|
const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
|
|
|
|
|
const MinidumpModuleCrashpadInfoList* module_list = nullptr;
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), &crashpad_info, &simple_annotations, &module_list));
|
2015-02-17 17:38:02 -05: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(crashpad_info->version, MinidumpCrashpadInfo::kVersion);
|
|
|
|
|
EXPECT_EQ(crashpad_info->report_id, UUID());
|
|
|
|
|
EXPECT_EQ(crashpad_info->client_id, UUID());
|
2015-03-11 17:10:50 -04:00
|
|
|
|
EXPECT_FALSE(simple_annotations);
|
|
|
|
|
EXPECT_FALSE(module_list);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-13 13:00:56 -04:00
|
|
|
|
TEST(MinidumpCrashpadInfoWriter, ReportAndClientID) {
|
2015-03-11 17:10:50 -04:00
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto crashpad_info_writer = std::make_unique<MinidumpCrashpadInfoWriter>();
|
2015-03-11 17:10:50 -04:00
|
|
|
|
|
2015-03-13 13:00:56 -04:00
|
|
|
|
UUID report_id;
|
|
|
|
|
ASSERT_TRUE(
|
|
|
|
|
report_id.InitializeFromString("01234567-89ab-cdef-0123-456789abcdef"));
|
|
|
|
|
crashpad_info_writer->SetReportID(report_id);
|
|
|
|
|
|
2015-03-11 17:10:50 -04:00
|
|
|
|
UUID client_id;
|
|
|
|
|
ASSERT_TRUE(
|
|
|
|
|
client_id.InitializeFromString("00112233-4455-6677-8899-aabbccddeeff"));
|
|
|
|
|
crashpad_info_writer->SetClientID(client_id);
|
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(crashpad_info_writer->IsUseful());
|
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
|
2015-03-11 17:10:50 -04:00
|
|
|
|
|
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
|
|
|
|
|
|
|
|
|
const MinidumpCrashpadInfo* crashpad_info = nullptr;
|
|
|
|
|
const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
|
|
|
|
|
const MinidumpModuleCrashpadInfoList* module_list = nullptr;
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
|
|
|
|
string_file.string(), &crashpad_info, &simple_annotations, &module_list));
|
|
|
|
|
|
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(crashpad_info->version, MinidumpCrashpadInfo::kVersion);
|
|
|
|
|
EXPECT_EQ(crashpad_info->report_id, report_id);
|
|
|
|
|
EXPECT_EQ(crashpad_info->client_id, client_id);
|
2015-02-17 17:38:02 -05:00
|
|
|
|
EXPECT_FALSE(simple_annotations);
|
|
|
|
|
EXPECT_FALSE(module_list);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 13:45:52 -05:00
|
|
|
|
TEST(MinidumpCrashpadInfoWriter, AddressMask) {
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
|
|
|
|
auto crashpad_info_writer = std::make_unique<MinidumpCrashpadInfoWriter>();
|
|
|
|
|
|
|
|
|
|
constexpr uint64_t mask = 0xFFFFFF8000000000;
|
|
|
|
|
crashpad_info_writer->SetAddressMask(mask);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
|
|
|
|
|
|
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
|
|
|
|
|
|
|
|
|
const MinidumpCrashpadInfo* crashpad_info = nullptr;
|
|
|
|
|
const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
|
|
|
|
|
const MinidumpModuleCrashpadInfoList* module_list = nullptr;
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
|
|
|
|
string_file.string(), &crashpad_info, &simple_annotations, &module_list));
|
|
|
|
|
|
|
|
|
|
UUID empty_report_id;
|
|
|
|
|
ASSERT_TRUE(empty_report_id.InitializeFromString(
|
|
|
|
|
"00000000-0000-0000-0000-000000000000"));
|
|
|
|
|
UUID empty_client_id;
|
|
|
|
|
ASSERT_TRUE(empty_client_id.InitializeFromString(
|
|
|
|
|
"00000000-0000-0000-0000-000000000000"));
|
|
|
|
|
|
2023-05-05 21:11:35 +00:00
|
|
|
|
// Copy address_mask into a local variable because
|
|
|
|
|
// |MinidumpCrashpadInfo::address_mask| requires 8-byte alignment but the
|
|
|
|
|
// struct itself is 4-byte aligned.
|
|
|
|
|
const auto address_mask = [&crashpad_info] {
|
|
|
|
|
uint64_t data = 0;
|
|
|
|
|
memcpy(&data, &crashpad_info->address_mask, sizeof(data));
|
|
|
|
|
return data;
|
|
|
|
|
}();
|
|
|
|
|
|
2023-01-06 13:45:52 -05:00
|
|
|
|
EXPECT_EQ(crashpad_info->version, MinidumpCrashpadInfo::kVersion);
|
2023-05-05 21:11:35 +00:00
|
|
|
|
EXPECT_EQ(address_mask, mask);
|
2023-01-06 13:45:52 -05:00
|
|
|
|
EXPECT_EQ(crashpad_info->report_id, empty_report_id);
|
|
|
|
|
EXPECT_EQ(crashpad_info->client_id, empty_client_id);
|
|
|
|
|
EXPECT_FALSE(simple_annotations);
|
|
|
|
|
EXPECT_FALSE(module_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpCrashpadInfoWriter, EmptyAddressMask) {
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
|
|
|
|
auto crashpad_info_writer = std::make_unique<MinidumpCrashpadInfoWriter>();
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
|
|
|
|
|
|
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
|
|
|
|
|
|
|
|
|
const MinidumpCrashpadInfo* crashpad_info = nullptr;
|
|
|
|
|
const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
|
|
|
|
|
const MinidumpModuleCrashpadInfoList* module_list = nullptr;
|
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
|
|
|
|
string_file.string(), &crashpad_info, &simple_annotations, &module_list));
|
|
|
|
|
|
2023-05-05 21:11:35 +00:00
|
|
|
|
// Copy address_mask into a local variable because
|
|
|
|
|
// |MinidumpCrashpadInfo::address_mask| requires 8-byte alignment but the
|
|
|
|
|
// struct itself is 4-byte aligned.
|
|
|
|
|
const auto address_mask = [&crashpad_info] {
|
|
|
|
|
uint64_t data = 0;
|
|
|
|
|
memcpy(&data, &crashpad_info->address_mask, sizeof(data));
|
|
|
|
|
return data;
|
|
|
|
|
}();
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(address_mask, 0UL);
|
2023-01-06 13:45:52 -05:00
|
|
|
|
}
|
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
|
TEST(MinidumpCrashpadInfoWriter, SimpleAnnotations) {
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto crashpad_info_writer = std::make_unique<MinidumpCrashpadInfoWriter>();
|
2015-02-17 17:38:02 -05:00
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kKey[] =
|
2015-02-17 17:38:02 -05:00
|
|
|
|
"a thing that provides a means of gaining access to or understanding "
|
|
|
|
|
"something";
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kValue[] =
|
2015-02-17 17:38:02 -05:00
|
|
|
|
"the numerical amount denoted by an algebraic term; a magnitude, "
|
|
|
|
|
"quantity, or number";
|
|
|
|
|
auto simple_string_dictionary_writer =
|
2017-10-12 12:42:28 -04:00
|
|
|
|
std::make_unique<MinidumpSimpleStringDictionaryWriter>();
|
2015-02-17 17:38:02 -05:00
|
|
|
|
auto simple_string_dictionary_entry_writer =
|
2017-10-12 12:42:28 -04:00
|
|
|
|
std::make_unique<MinidumpSimpleStringDictionaryEntryWriter>();
|
2015-02-17 17:38:02 -05:00
|
|
|
|
simple_string_dictionary_entry_writer->SetKeyValue(kKey, kValue);
|
|
|
|
|
simple_string_dictionary_writer->AddEntry(
|
2015-12-09 17:36:32 -05:00
|
|
|
|
std::move(simple_string_dictionary_entry_writer));
|
2015-02-17 17:38:02 -05:00
|
|
|
|
crashpad_info_writer->SetSimpleAnnotations(
|
2015-12-09 17:36:32 -05:00
|
|
|
|
std::move(simple_string_dictionary_writer));
|
2015-02-17 17:38:02 -05:00
|
|
|
|
|
|
|
|
|
EXPECT_TRUE(crashpad_info_writer->IsUseful());
|
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
|
2015-02-17 17:38:02 -05:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2015-02-17 17:38:02 -05:00
|
|
|
|
|
|
|
|
|
const MinidumpCrashpadInfo* crashpad_info = nullptr;
|
|
|
|
|
const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
|
2015-02-05 08:48:24 -08:00
|
|
|
|
const MinidumpModuleCrashpadInfoList* module_list = nullptr;
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2014-10-24 14:44:55 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), &crashpad_info, &simple_annotations, &module_list));
|
2014-10-17 18:00:41 -04: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(crashpad_info->version, MinidumpCrashpadInfo::kVersion);
|
2014-10-24 14:44:55 -04:00
|
|
|
|
EXPECT_FALSE(module_list);
|
2015-02-17 17:38:02 -05:00
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(simple_annotations);
|
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(simple_annotations->count, 1u);
|
|
|
|
|
EXPECT_EQ(MinidumpUTF8StringAtRVAAsString(string_file.string(),
|
|
|
|
|
simple_annotations->entries[0].key),
|
|
|
|
|
kKey);
|
|
|
|
|
EXPECT_EQ(MinidumpUTF8StringAtRVAAsString(
|
|
|
|
|
string_file.string(), simple_annotations->entries[0].value),
|
|
|
|
|
kValue);
|
2014-10-17 18:00:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-24 14:44:55 -04:00
|
|
|
|
TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) {
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint32_t kMinidumpModuleListIndex = 3;
|
2014-10-24 14:44:55 -04:00
|
|
|
|
|
2014-10-17 18:00:41 -04:00
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto crashpad_info_writer = std::make_unique<MinidumpCrashpadInfoWriter>();
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
|
auto module_list_writer =
|
2017-10-12 12:42:28 -04:00
|
|
|
|
std::make_unique<MinidumpModuleCrashpadInfoListWriter>();
|
|
|
|
|
auto module_writer = std::make_unique<MinidumpModuleCrashpadInfoWriter>();
|
2015-12-09 17:36:32 -05:00
|
|
|
|
module_list_writer->AddModule(std::move(module_writer),
|
|
|
|
|
kMinidumpModuleListIndex);
|
|
|
|
|
crashpad_info_writer->SetModuleList(std::move(module_list_writer));
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2014-11-07 11:38:13 -05:00
|
|
|
|
EXPECT_TRUE(crashpad_info_writer->IsUseful());
|
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(crashpad_info_writer)));
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
2015-02-05 08:48:24 -08:00
|
|
|
|
const MinidumpCrashpadInfo* crashpad_info = nullptr;
|
2015-02-17 17:38:02 -05:00
|
|
|
|
const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
|
|
|
|
|
const MinidumpModuleCrashpadInfoList* module_list = nullptr;
|
2014-10-17 18:00:41 -04:00
|
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), &crashpad_info, &simple_annotations, &module_list));
|
2014-10-24 14:44:55 -04: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(crashpad_info->version, MinidumpCrashpadInfo::kVersion);
|
2015-02-17 17:38:02 -05:00
|
|
|
|
EXPECT_FALSE(simple_annotations);
|
|
|
|
|
|
2014-10-24 14:44:55 -04:00
|
|
|
|
ASSERT_TRUE(module_list);
|
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(module_list->count, 1u);
|
2014-10-24 14:44:55 -04: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(module_list->modules[0].minidump_module_list_index,
|
|
|
|
|
kMinidumpModuleListIndex);
|
2014-10-24 14:44:55 -04:00
|
|
|
|
const MinidumpModuleCrashpadInfo* module =
|
|
|
|
|
MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
|
2015-03-04 10:53:34 -05:00
|
|
|
|
string_file.string(), module_list->modules[0].location);
|
2014-10-24 14:44:55 -04:00
|
|
|
|
ASSERT_TRUE(module);
|
|
|
|
|
|
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(module->version, MinidumpModuleCrashpadInfo::kVersion);
|
|
|
|
|
EXPECT_EQ(module->list_annotations.DataSize, 0u);
|
|
|
|
|
EXPECT_EQ(module->list_annotations.Rva, 0u);
|
|
|
|
|
EXPECT_EQ(module->simple_annotations.DataSize, 0u);
|
|
|
|
|
EXPECT_EQ(module->simple_annotations.Rva, 0u);
|
2014-10-17 18:00:41 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-07 11:38:13 -05:00
|
|
|
|
TEST(MinidumpCrashpadInfoWriter, InitializeFromSnapshot) {
|
2015-03-13 13:00:56 -04:00
|
|
|
|
UUID report_id;
|
|
|
|
|
ASSERT_TRUE(
|
|
|
|
|
report_id.InitializeFromString("fedcba98-7654-3210-fedc-ba9876543210"));
|
|
|
|
|
|
2015-03-11 17:10:50 -04:00
|
|
|
|
UUID client_id;
|
|
|
|
|
ASSERT_TRUE(
|
|
|
|
|
client_id.InitializeFromString("fedcba98-7654-3210-0123-456789abcdef"));
|
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr char kKey[] = "version";
|
|
|
|
|
static constexpr char kValue[] = "40.0.2214.111";
|
|
|
|
|
static constexpr char kEntry[] = "This is a simple annotation in a list.";
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
|
|
|
|
// Test with a useless module, one that doesn’t carry anything that would
|
|
|
|
|
// require MinidumpCrashpadInfo or any child object.
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto process_snapshot = std::make_unique<TestProcessSnapshot>();
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto module_snapshot = std::make_unique<TestModuleSnapshot>();
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot->AddModule(std::move(module_snapshot));
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto info_writer = std::make_unique<MinidumpCrashpadInfoWriter>();
|
2014-11-07 11:38:13 -05:00
|
|
|
|
info_writer->InitializeFromSnapshot(process_snapshot.get());
|
|
|
|
|
EXPECT_FALSE(info_writer->IsUseful());
|
|
|
|
|
|
|
|
|
|
// Try again with a useful module.
|
|
|
|
|
process_snapshot.reset(new TestProcessSnapshot());
|
|
|
|
|
|
2015-03-13 13:00:56 -04:00
|
|
|
|
process_snapshot->SetReportID(report_id);
|
2015-03-11 17:10:50 -04:00
|
|
|
|
process_snapshot->SetClientID(client_id);
|
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
|
std::map<std::string, std::string> annotations_simple_map;
|
|
|
|
|
annotations_simple_map[kKey] = kValue;
|
|
|
|
|
process_snapshot->SetAnnotationsSimpleMap(annotations_simple_map);
|
|
|
|
|
|
2014-11-07 11:38:13 -05:00
|
|
|
|
module_snapshot.reset(new TestModuleSnapshot());
|
|
|
|
|
std::vector<std::string> annotations_list(1, std::string(kEntry));
|
|
|
|
|
module_snapshot->SetAnnotationsVector(annotations_list);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot->AddModule(std::move(module_snapshot));
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
|
|
|
|
info_writer.reset(new MinidumpCrashpadInfoWriter());
|
|
|
|
|
info_writer->InitializeFromSnapshot(process_snapshot.get());
|
|
|
|
|
EXPECT_TRUE(info_writer->IsUseful());
|
|
|
|
|
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(info_writer)));
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
2015-02-05 08:48:24 -08:00
|
|
|
|
const MinidumpCrashpadInfo* info = nullptr;
|
2015-02-17 17:38:02 -05:00
|
|
|
|
const MinidumpSimpleStringDictionary* simple_annotations;
|
2014-11-07 11:38:13 -05:00
|
|
|
|
const MinidumpModuleCrashpadInfoList* module_list;
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), &info, &simple_annotations, &module_list));
|
2014-11-07 11:38:13 -05: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(info->version, MinidumpCrashpadInfo::kVersion);
|
2015-02-17 17:38:02 -05: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(info->report_id, report_id);
|
|
|
|
|
EXPECT_EQ(info->client_id, client_id);
|
2015-03-11 17:10:50 -04:00
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
|
ASSERT_TRUE(simple_annotations);
|
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(simple_annotations->count, 1u);
|
|
|
|
|
EXPECT_EQ(MinidumpUTF8StringAtRVAAsString(string_file.string(),
|
|
|
|
|
simple_annotations->entries[0].key),
|
|
|
|
|
kKey);
|
|
|
|
|
EXPECT_EQ(MinidumpUTF8StringAtRVAAsString(
|
|
|
|
|
string_file.string(), simple_annotations->entries[0].value),
|
|
|
|
|
kValue);
|
2015-02-17 17:38:02 -05:00
|
|
|
|
|
2014-11-07 11:38:13 -05:00
|
|
|
|
ASSERT_TRUE(module_list);
|
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(module_list->count, 1u);
|
2014-11-07 11:38:13 -05: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(module_list->modules[0].minidump_module_list_index, 0u);
|
2014-11-07 11:38:13 -05:00
|
|
|
|
const MinidumpModuleCrashpadInfo* module =
|
|
|
|
|
MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
|
2015-03-04 10:53:34 -05:00
|
|
|
|
string_file.string(), module_list->modules[0].location);
|
2014-11-07 11:38:13 -05:00
|
|
|
|
ASSERT_TRUE(module);
|
|
|
|
|
|
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(module->version, MinidumpModuleCrashpadInfo::kVersion);
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
|
|
|
|
const MinidumpRVAList* list_annotations =
|
|
|
|
|
MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), module->list_annotations);
|
2014-11-07 11:38:13 -05:00
|
|
|
|
ASSERT_TRUE(list_annotations);
|
|
|
|
|
|
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(list_annotations->count, 1u);
|
|
|
|
|
EXPECT_EQ(MinidumpUTF8StringAtRVAAsString(string_file.string(),
|
|
|
|
|
list_annotations->children[0]),
|
|
|
|
|
kEntry);
|
2014-11-07 11:38:13 -05:00
|
|
|
|
|
2015-02-17 17:38:02 -05:00
|
|
|
|
const MinidumpSimpleStringDictionary* module_simple_annotations =
|
2014-11-07 11:38:13 -05:00
|
|
|
|
MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), module->simple_annotations);
|
2015-02-17 17:38:02 -05:00
|
|
|
|
EXPECT_FALSE(module_simple_annotations);
|
2014-11-07 11:38:13 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-10-17 18:00:41 -04:00
|
|
|
|
} // namespace
|
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace crashpad
|