2014-08-13 15:26:21 -07:00
|
|
|
// Copyright 2014 The Crashpad Authors. All rights reserved.
|
|
|
|
//
|
|
|
|
// 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_module_writer.h"
|
|
|
|
|
2017-03-22 21:44:05 -04:00
|
|
|
#include <stddef.h>
|
2014-08-13 15:26:21 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
2015-12-09 17:36:32 -05:00
|
|
|
#include <utility>
|
|
|
|
|
2015-02-05 15:04:49 -08:00
|
|
|
#include "base/format_macros.h"
|
2016-04-25 12:13:07 -07:00
|
|
|
#include "base/memory/ptr_util.h"
|
2014-10-29 11:38:49 -04:00
|
|
|
#include "base/strings/stringprintf.h"
|
2014-08-13 15:26:21 -07:00
|
|
|
#include "base/strings/utf_string_conversions.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include "minidump/minidump_extensions.h"
|
|
|
|
#include "minidump/minidump_file_writer.h"
|
2014-10-20 12:11:14 -04:00
|
|
|
#include "minidump/test/minidump_file_writer_test_util.h"
|
2014-10-21 14:15:07 -04: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-10-29 11:38:49 -04:00
|
|
|
#include "snapshot/test/test_module_snapshot.h"
|
test: Move util/test to its own top-level directory, test.
After 9e79ea1da719, it no longer makes sense for crashpad_util_test_lib
to “hide” in util/util_test.gyp. All of util/test is moved to its own
top-level directory, test, which all other test code is allowed to
depend on. test, too, is allowed to depend on all other non-test code.
In a future change, when crashpad_util_test_lib gains a dependency on
crashpad_client, it won’t look so weird for something in util (even
though it’s in util/test) to depend on something in client, because the
thing that needs to depend on client will live in test, not util.
BUG=crashpad:33
R=scottmg@chromium.org
Review URL: https://codereview.chromium.org/1051533002
2015-03-31 17:44:14 -04:00
|
|
|
#include "test/gtest_death_check.h"
|
2015-02-18 14:15:38 -05:00
|
|
|
#include "util/file/string_file.h"
|
2015-09-14 11:09:46 -07:00
|
|
|
#include "util/misc/implicit_cast.h"
|
2014-08-13 15:26:21 -07:00
|
|
|
#include "util/misc/uuid.h"
|
2014-10-29 11:38:49 -04:00
|
|
|
#include "util/stdlib/pointer_container.h"
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-07 17:28:50 -04:00
|
|
|
namespace crashpad {
|
|
|
|
namespace test {
|
2014-08-13 15:26:21 -07:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void GetModuleListStream(const std::string& file_contents,
|
|
|
|
const MINIDUMP_MODULE_LIST** module_list) {
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
constexpr size_t kModuleListStreamOffset =
|
2014-08-13 15:26:21 -07:00
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr size_t kModulesOffset =
|
2014-08-13 15:26:21 -07:00
|
|
|
kModuleListStreamOffset + sizeof(MINIDUMP_MODULE_LIST);
|
|
|
|
|
|
|
|
ASSERT_GE(file_contents.size(), kModulesOffset);
|
|
|
|
|
2014-10-21 14:15:07 -04:00
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
2014-08-13 15:26:21 -07:00
|
|
|
const MINIDUMP_HEADER* header =
|
2014-10-21 14:15:07 -04:00
|
|
|
MinidumpHeaderAtStart(file_contents, &directory);
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
|
2014-10-21 14:15:07 -04:00
|
|
|
ASSERT_TRUE(directory);
|
2014-08-13 15:26:21 -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
|
|
|
ASSERT_EQ(directory[0].StreamType, kMinidumpStreamTypeModuleList);
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kModuleListStreamOffset);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-22 18:35:18 -04:00
|
|
|
*module_list = MinidumpWritableAtLocationDescriptor<MINIDUMP_MODULE_LIST>(
|
|
|
|
file_contents, directory[0].Location);
|
|
|
|
ASSERT_TRUE(module_list);
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MinidumpModuleWriter, EmptyModuleList) {
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-13 15:26:21 -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
|
|
|
ASSERT_EQ(string_file.string().size(),
|
|
|
|
sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
|
|
|
sizeof(MINIDUMP_MODULE_LIST));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-04 20:47:16 -08:00
|
|
|
const MINIDUMP_MODULE_LIST* module_list = nullptr;
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
GetModuleListStream(string_file.string(), &module_list));
|
2014-08-13 15:26:21 -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(module_list->NumberOfModules, 0u);
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
2014-10-14 11:10:45 -04:00
|
|
|
// If |expected_pdb_name| is not nullptr, |codeview_record| is used to locate a
|
2014-08-13 15:26:21 -07:00
|
|
|
// CodeView record in |file_contents|, and its fields are compared against the
|
|
|
|
// the |expected_pdb_*| values. If |expected_pdb_uuid| is supplied, the CodeView
|
|
|
|
// record must be a PDB 7.0 link, otherwise, it must be a PDB 2.0 link. If
|
2014-10-14 11:10:45 -04:00
|
|
|
// |expected_pdb_name| is nullptr, |codeview_record| must not point to anything.
|
2014-08-13 15:26:21 -07:00
|
|
|
void ExpectCodeViewRecord(const MINIDUMP_LOCATION_DESCRIPTOR* codeview_record,
|
|
|
|
const std::string& file_contents,
|
|
|
|
const char* expected_pdb_name,
|
|
|
|
const UUID* expected_pdb_uuid,
|
|
|
|
time_t expected_pdb_timestamp,
|
|
|
|
uint32_t expected_pdb_age) {
|
|
|
|
if (expected_pdb_name) {
|
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(codeview_record->Rva, 0u);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
std::string observed_pdb_name;
|
|
|
|
if (expected_pdb_uuid) {
|
|
|
|
// The CodeView record should be a PDB 7.0 link.
|
2015-09-01 09:32:09 -07:00
|
|
|
const CodeViewRecordPDB70* codeview_pdb70_record =
|
|
|
|
MinidumpWritableAtLocationDescriptor<CodeViewRecordPDB70>(
|
|
|
|
file_contents, *codeview_record);
|
2014-10-22 18:35:18 -04:00
|
|
|
ASSERT_TRUE(codeview_pdb70_record);
|
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(memcmp(expected_pdb_uuid,
|
2014-08-13 15:26:21 -07:00
|
|
|
&codeview_pdb70_record->uuid,
|
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
|
|
|
sizeof(codeview_pdb70_record->uuid)),
|
|
|
|
0);
|
|
|
|
EXPECT_EQ(codeview_pdb70_record->age, expected_pdb_age);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
observed_pdb_name.assign(
|
|
|
|
reinterpret_cast<const char*>(&codeview_pdb70_record->pdb_name[0]),
|
2015-09-01 09:32:09 -07:00
|
|
|
codeview_record->DataSize - offsetof(CodeViewRecordPDB70, pdb_name));
|
2014-08-13 15:26:21 -07:00
|
|
|
} else {
|
|
|
|
// The CodeView record should be a PDB 2.0 link.
|
2015-09-01 09:32:09 -07:00
|
|
|
const CodeViewRecordPDB20* codeview_pdb20_record =
|
|
|
|
MinidumpWritableAtLocationDescriptor<CodeViewRecordPDB20>(
|
|
|
|
file_contents, *codeview_record);
|
2014-10-22 18:35:18 -04:00
|
|
|
ASSERT_TRUE(codeview_pdb20_record);
|
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(codeview_pdb20_record->timestamp,
|
|
|
|
static_cast<uint32_t>(expected_pdb_timestamp));
|
|
|
|
EXPECT_EQ(codeview_pdb20_record->age, expected_pdb_age);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
observed_pdb_name.assign(
|
|
|
|
reinterpret_cast<const char*>(&codeview_pdb20_record->pdb_name[0]),
|
2015-09-01 09:32:09 -07:00
|
|
|
codeview_record->DataSize - offsetof(CodeViewRecordPDB20, pdb_name));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Check for, and then remove, the NUL terminator.
|
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(observed_pdb_name[observed_pdb_name.size() - 1], '\0');
|
2014-08-13 15:26:21 -07:00
|
|
|
observed_pdb_name.resize(observed_pdb_name.size() - 1);
|
|
|
|
|
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(observed_pdb_name, expected_pdb_name);
|
2014-08-13 15:26:21 -07:00
|
|
|
} else {
|
|
|
|
// There should be no CodeView record.
|
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(codeview_record->DataSize, 0u);
|
|
|
|
EXPECT_EQ(codeview_record->Rva, 0u);
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-14 11:10:45 -04:00
|
|
|
// If |expected_debug_name| is not nullptr, |misc_record| is used to locate a
|
2014-08-13 15:26:21 -07:00
|
|
|
// miscellanous debugging record in |file_contents|, and its fields are compared
|
2014-10-14 11:10:45 -04:00
|
|
|
// against the the |expected_debug_*| values. If |expected_debug_name| is
|
|
|
|
// nullptr, |misc_record| must not point to anything.
|
2014-08-13 15:26:21 -07:00
|
|
|
void ExpectMiscellaneousDebugRecord(
|
|
|
|
const MINIDUMP_LOCATION_DESCRIPTOR* misc_record,
|
|
|
|
const std::string& file_contents,
|
|
|
|
const char* expected_debug_name,
|
|
|
|
uint32_t expected_debug_type,
|
|
|
|
bool expected_debug_utf16) {
|
|
|
|
if (expected_debug_name) {
|
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(misc_record->Rva, 0u);
|
2014-08-13 15:26:21 -07:00
|
|
|
const IMAGE_DEBUG_MISC* misc_debug_record =
|
2014-10-22 18:35:18 -04:00
|
|
|
MinidumpWritableAtLocationDescriptor<IMAGE_DEBUG_MISC>(file_contents,
|
|
|
|
*misc_record);
|
|
|
|
ASSERT_TRUE(misc_debug_record);
|
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(misc_debug_record->DataType, expected_debug_type);
|
|
|
|
EXPECT_EQ(misc_debug_record->Unicode != 0, expected_debug_utf16);
|
|
|
|
EXPECT_EQ(misc_debug_record->Reserved[0], 0u);
|
|
|
|
EXPECT_EQ(misc_debug_record->Reserved[1], 0u);
|
|
|
|
EXPECT_EQ(misc_debug_record->Reserved[2], 0u);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
// Check for the NUL terminator.
|
|
|
|
size_t bytes_available =
|
|
|
|
misc_debug_record->Length - offsetof(IMAGE_DEBUG_MISC, Data);
|
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(misc_debug_record->Data[bytes_available - 1], '\0');
|
2014-08-13 15:26:21 -07:00
|
|
|
std::string observed_data(
|
|
|
|
reinterpret_cast<const char*>(misc_debug_record->Data));
|
|
|
|
|
|
|
|
size_t bytes_used;
|
|
|
|
if (misc_debug_record->Unicode) {
|
2014-12-12 11:06:09 -08:00
|
|
|
base::string16 observed_data_utf16(
|
|
|
|
reinterpret_cast<const base::char16*>(misc_debug_record->Data));
|
|
|
|
bytes_used = (observed_data_utf16.size() + 1) * sizeof(base::char16);
|
2014-08-13 15:26:21 -07:00
|
|
|
observed_data = base::UTF16ToUTF8(observed_data_utf16);
|
|
|
|
} else {
|
|
|
|
observed_data = reinterpret_cast<const char*>(misc_debug_record->Data);
|
|
|
|
bytes_used = (observed_data.size() + 1) * sizeof(char);
|
|
|
|
}
|
|
|
|
EXPECT_LE(bytes_used, bytes_available);
|
|
|
|
|
|
|
|
// Make sure that any padding bytes after the first NUL are also NUL.
|
|
|
|
for (size_t index = bytes_used; index < bytes_available; ++index) {
|
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(misc_debug_record->Data[index], '\0');
|
2014-08-13 15:26:21 -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(observed_data, expected_debug_name);
|
2014-08-13 15:26:21 -07:00
|
|
|
} else {
|
|
|
|
// There should be no miscellaneous debugging record.
|
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(misc_record->DataSize, 0u);
|
|
|
|
EXPECT_EQ(misc_record->Rva, 0u);
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExpectModule() verifies that |expected| matches |observed|. Fields that are
|
|
|
|
// supposed to contain constant magic numbers are verified against the expected
|
|
|
|
// constants instead of |expected|. Reserved fields are verified to be 0. RVA
|
|
|
|
// and MINIDUMP_LOCATION_DESCRIPTOR fields are not verified against |expected|.
|
|
|
|
// Instead, |ModuleNameRva| is used to locate the module name, which is compared
|
|
|
|
// against |expected_module_name|. ExpectCodeViewRecord() and
|
|
|
|
// ExpectMiscellaneousDebugRecord() are used to verify the |CvRecord| and
|
|
|
|
// |MiscRecord| fields against |expected_pdb_*| and |expected_debug_*|
|
|
|
|
// parameters, respectively.
|
|
|
|
void ExpectModule(const MINIDUMP_MODULE* expected,
|
|
|
|
const MINIDUMP_MODULE* observed,
|
|
|
|
const std::string& file_contents,
|
|
|
|
const std::string& expected_module_name,
|
|
|
|
const char* expected_pdb_name,
|
|
|
|
const UUID* expected_pdb_uuid,
|
|
|
|
time_t expected_pdb_timestamp,
|
|
|
|
uint32_t expected_pdb_age,
|
|
|
|
const char* expected_debug_name,
|
|
|
|
uint32_t expected_debug_type,
|
|
|
|
bool expected_debug_utf16) {
|
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(observed->BaseOfImage, expected->BaseOfImage);
|
|
|
|
EXPECT_EQ(observed->SizeOfImage, expected->SizeOfImage);
|
|
|
|
EXPECT_EQ(observed->CheckSum, expected->CheckSum);
|
|
|
|
EXPECT_EQ(observed->TimeDateStamp, expected->TimeDateStamp);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwSignature,
|
|
|
|
implicit_cast<uint32_t>(VS_FFI_SIGNATURE));
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwStrucVersion,
|
|
|
|
implicit_cast<uint32_t>(VS_FFI_STRUCVERSION));
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileVersionMS,
|
|
|
|
expected->VersionInfo.dwFileVersionMS);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileVersionLS,
|
|
|
|
expected->VersionInfo.dwFileVersionLS);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwProductVersionMS,
|
|
|
|
expected->VersionInfo.dwProductVersionMS);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwProductVersionLS,
|
|
|
|
expected->VersionInfo.dwProductVersionLS);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileFlagsMask,
|
|
|
|
expected->VersionInfo.dwFileFlagsMask);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileFlags,
|
|
|
|
expected->VersionInfo.dwFileFlags);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileOS, expected->VersionInfo.dwFileOS);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileType, expected->VersionInfo.dwFileType);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileSubtype,
|
|
|
|
expected->VersionInfo.dwFileSubtype);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileDateMS,
|
|
|
|
expected->VersionInfo.dwFileDateMS);
|
|
|
|
EXPECT_EQ(observed->VersionInfo.dwFileDateLS,
|
|
|
|
expected->VersionInfo.dwFileDateLS);
|
|
|
|
EXPECT_EQ(observed->Reserved0, 0u);
|
|
|
|
EXPECT_EQ(observed->Reserved1, 0u);
|
|
|
|
|
|
|
|
EXPECT_NE(observed->ModuleNameRva, 0u);
|
2014-12-12 11:06:09 -08:00
|
|
|
base::string16 observed_module_name_utf16 =
|
2014-10-21 14:15:07 -04:00
|
|
|
MinidumpStringAtRVAAsString(file_contents, observed->ModuleNameRva);
|
2014-12-12 11:06:09 -08:00
|
|
|
base::string16 expected_module_name_utf16 =
|
|
|
|
base::UTF8ToUTF16(expected_module_name);
|
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(observed_module_name_utf16, expected_module_name_utf16);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectCodeViewRecord(&observed->CvRecord,
|
|
|
|
file_contents,
|
|
|
|
expected_pdb_name,
|
|
|
|
expected_pdb_uuid,
|
|
|
|
expected_pdb_timestamp,
|
|
|
|
expected_pdb_age));
|
|
|
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectMiscellaneousDebugRecord(&observed->MiscRecord,
|
|
|
|
file_contents,
|
|
|
|
expected_debug_name,
|
|
|
|
expected_debug_type,
|
|
|
|
expected_debug_utf16));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MinidumpModuleWriter, EmptyModule) {
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kModuleName[] = "test_executable";
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_writer = base::WrapUnique(new MinidumpModuleWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
module_writer->SetName(kModuleName);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-12-09 17:36:32 -05:00
|
|
|
module_list_writer->AddModule(std::move(module_writer));
|
2017-03-15 15:35:36 -04:00
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
ASSERT_GT(string_file.string().size(),
|
2014-08-13 15:26:21 -07:00
|
|
|
sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
|
|
|
sizeof(MINIDUMP_MODULE_LIST) + 1 * sizeof(MINIDUMP_MODULE));
|
|
|
|
|
2015-02-04 20:47:16 -08:00
|
|
|
const MINIDUMP_MODULE_LIST* module_list = nullptr;
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
GetModuleListStream(string_file.string(), &module_list));
|
2014-08-13 15:26:21 -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(module_list->NumberOfModules, 1u);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
MINIDUMP_MODULE expected = {};
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
|
|
|
|
&module_list->Modules[0],
|
2015-02-18 14:15:38 -05:00
|
|
|
string_file.string(),
|
2014-10-09 15:08:54 -04:00
|
|
|
kModuleName,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2014-10-09 15:08:54 -04:00
|
|
|
0,
|
|
|
|
0,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
2014-10-09 15:08:54 -04:00
|
|
|
0,
|
|
|
|
false));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MinidumpModuleWriter, OneModule) {
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kModuleName[] = "statically_linked";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr uint64_t kModuleBase = 0x10da69000;
|
|
|
|
constexpr uint32_t kModuleSize = 0x1000;
|
|
|
|
constexpr uint32_t kChecksum = 0x76543210;
|
|
|
|
constexpr time_t kTimestamp = 0x386d4380;
|
|
|
|
constexpr uint32_t kFileVersionMS = 0x00010002;
|
|
|
|
constexpr uint32_t kFileVersionLS = 0x00030004;
|
|
|
|
constexpr uint32_t kProductVersionMS = 0x00050006;
|
|
|
|
constexpr uint32_t kProductVersionLS = 0x00070008;
|
|
|
|
constexpr uint32_t kFileFlagsMask = VS_FF_DEBUG | VS_FF_PRERELEASE |
|
|
|
|
VS_FF_PATCHED | VS_FF_PRIVATEBUILD |
|
|
|
|
VS_FF_INFOINFERRED | VS_FF_SPECIALBUILD;
|
|
|
|
constexpr uint32_t kFileFlags = VS_FF_PRIVATEBUILD | VS_FF_SPECIALBUILD;
|
|
|
|
constexpr uint32_t kFileOS = VOS_DOS;
|
|
|
|
constexpr uint32_t kFileType = VFT_DRV;
|
|
|
|
constexpr uint32_t kFileSubtype = VFT2_DRV_KEYBOARD;
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kPDBName[] = "statical.pdb";
|
|
|
|
static constexpr uint8_t kPDBUUIDBytes[16] =
|
2014-08-13 15:26:21 -07:00
|
|
|
{0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10,
|
|
|
|
0x08, 0x19, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e, 0x7f};
|
|
|
|
UUID pdb_uuid;
|
|
|
|
pdb_uuid.InitializeFromBytes(kPDBUUIDBytes);
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr uint32_t kPDBAge = 1;
|
|
|
|
constexpr uint32_t kDebugType = IMAGE_DEBUG_MISC_EXENAME;
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kDebugName[] = "statical.dbg";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr bool kDebugUTF16 = false;
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_writer = base::WrapUnique(new MinidumpModuleWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
module_writer->SetName(kModuleName);
|
|
|
|
module_writer->SetImageBaseAddress(kModuleBase);
|
|
|
|
module_writer->SetImageSize(kModuleSize);
|
|
|
|
module_writer->SetChecksum(kChecksum);
|
|
|
|
module_writer->SetTimestamp(kTimestamp);
|
|
|
|
module_writer->SetFileVersion(kFileVersionMS >> 16,
|
|
|
|
kFileVersionMS & 0xffff,
|
|
|
|
kFileVersionLS >> 16,
|
|
|
|
kFileVersionLS & 0xffff);
|
|
|
|
module_writer->SetProductVersion(kProductVersionMS >> 16,
|
|
|
|
kProductVersionMS & 0xffff,
|
|
|
|
kProductVersionLS >> 16,
|
|
|
|
kProductVersionLS & 0xffff);
|
|
|
|
module_writer->SetFileFlagsAndMask(kFileFlags, kFileFlagsMask);
|
|
|
|
module_writer->SetFileOS(kFileOS);
|
|
|
|
module_writer->SetFileTypeAndSubtype(kFileType, kFileSubtype);
|
|
|
|
|
|
|
|
auto codeview_pdb70_writer =
|
2016-04-25 12:13:07 -07:00
|
|
|
base::WrapUnique(new MinidumpModuleCodeViewRecordPDB70Writer());
|
2014-10-27 15:01:39 -04:00
|
|
|
codeview_pdb70_writer->SetPDBName(kPDBName);
|
|
|
|
codeview_pdb70_writer->SetUUIDAndAge(pdb_uuid, kPDBAge);
|
2015-12-09 17:36:32 -05:00
|
|
|
module_writer->SetCodeViewRecord(std::move(codeview_pdb70_writer));
|
2014-10-27 15:01:39 -04:00
|
|
|
|
|
|
|
auto misc_debug_writer =
|
2016-04-25 12:13:07 -07:00
|
|
|
base::WrapUnique(new MinidumpModuleMiscDebugRecordWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
misc_debug_writer->SetDataType(kDebugType);
|
|
|
|
misc_debug_writer->SetData(kDebugName, kDebugUTF16);
|
2015-12-09 17:36:32 -05:00
|
|
|
module_writer->SetMiscDebugRecord(std::move(misc_debug_writer));
|
2014-10-27 15:01:39 -04:00
|
|
|
|
2015-12-09 17:36:32 -05:00
|
|
|
module_list_writer->AddModule(std::move(module_writer));
|
2017-03-15 15:35:36 -04:00
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
ASSERT_GT(string_file.string().size(),
|
2014-08-13 15:26:21 -07:00
|
|
|
sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
|
|
|
sizeof(MINIDUMP_MODULE_LIST) + 1 * sizeof(MINIDUMP_MODULE));
|
|
|
|
|
2015-02-04 20:47:16 -08:00
|
|
|
const MINIDUMP_MODULE_LIST* module_list = nullptr;
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
GetModuleListStream(string_file.string(), &module_list));
|
2014-08-13 15:26:21 -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(module_list->NumberOfModules, 1u);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
MINIDUMP_MODULE expected = {};
|
|
|
|
expected.BaseOfImage = kModuleBase;
|
|
|
|
expected.SizeOfImage = kModuleSize;
|
|
|
|
expected.CheckSum = kChecksum;
|
|
|
|
expected.TimeDateStamp = kTimestamp;
|
|
|
|
expected.VersionInfo.dwFileVersionMS = kFileVersionMS;
|
|
|
|
expected.VersionInfo.dwFileVersionLS = kFileVersionLS;
|
|
|
|
expected.VersionInfo.dwProductVersionMS = kProductVersionMS;
|
|
|
|
expected.VersionInfo.dwProductVersionLS = kProductVersionLS;
|
|
|
|
expected.VersionInfo.dwFileFlagsMask = kFileFlagsMask;
|
|
|
|
expected.VersionInfo.dwFileFlags = kFileFlags;
|
|
|
|
expected.VersionInfo.dwFileOS = kFileOS;
|
|
|
|
expected.VersionInfo.dwFileType = kFileType;
|
|
|
|
expected.VersionInfo.dwFileSubtype = kFileSubtype;
|
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
|
|
|
|
&module_list->Modules[0],
|
2015-02-18 14:15:38 -05:00
|
|
|
string_file.string(),
|
2014-10-09 15:08:54 -04:00
|
|
|
kModuleName,
|
|
|
|
kPDBName,
|
|
|
|
&pdb_uuid,
|
|
|
|
0,
|
|
|
|
kPDBAge,
|
|
|
|
kDebugName,
|
|
|
|
kDebugType,
|
|
|
|
kDebugUTF16));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MinidumpModuleWriter, OneModule_CodeViewUsesPDB20_MiscUsesUTF16) {
|
|
|
|
// MinidumpModuleWriter.OneModule tested with a PDB 7.0 link as the CodeView
|
|
|
|
// record and an IMAGE_DEBUG_MISC record in UTF-8. This test exercises the
|
|
|
|
// alternatives, a PDB 2.0 link as the CodeView record and an IMAGE_DEBUG_MISC
|
|
|
|
// record with UTF-16 data.
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kModuleName[] = "dinosaur";
|
|
|
|
static constexpr char kPDBName[] = "d1n05.pdb";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr time_t kPDBTimestamp = 0x386d4380;
|
|
|
|
constexpr uint32_t kPDBAge = 1;
|
|
|
|
constexpr uint32_t kDebugType = IMAGE_DEBUG_MISC_EXENAME;
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kDebugName[] = "d1n05.dbg";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr bool kDebugUTF16 = true;
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_writer = base::WrapUnique(new MinidumpModuleWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
module_writer->SetName(kModuleName);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
auto codeview_pdb20_writer =
|
2016-04-25 12:13:07 -07:00
|
|
|
base::WrapUnique(new MinidumpModuleCodeViewRecordPDB20Writer());
|
2014-10-27 15:01:39 -04:00
|
|
|
codeview_pdb20_writer->SetPDBName(kPDBName);
|
|
|
|
codeview_pdb20_writer->SetTimestampAndAge(kPDBTimestamp, kPDBAge);
|
2015-12-09 17:36:32 -05:00
|
|
|
module_writer->SetCodeViewRecord(std::move(codeview_pdb20_writer));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
auto misc_debug_writer =
|
2016-04-25 12:13:07 -07:00
|
|
|
base::WrapUnique(new MinidumpModuleMiscDebugRecordWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
misc_debug_writer->SetDataType(kDebugType);
|
|
|
|
misc_debug_writer->SetData(kDebugName, kDebugUTF16);
|
2015-12-09 17:36:32 -05:00
|
|
|
module_writer->SetMiscDebugRecord(std::move(misc_debug_writer));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-12-09 17:36:32 -05:00
|
|
|
module_list_writer->AddModule(std::move(module_writer));
|
2017-03-15 15:35:36 -04:00
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
ASSERT_GT(string_file.string().size(),
|
2014-08-13 15:26:21 -07:00
|
|
|
sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
|
|
|
sizeof(MINIDUMP_MODULE_LIST) + 1 * sizeof(MINIDUMP_MODULE));
|
|
|
|
|
2015-02-04 20:47:16 -08:00
|
|
|
const MINIDUMP_MODULE_LIST* module_list = nullptr;
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
GetModuleListStream(string_file.string(), &module_list));
|
2014-08-13 15:26:21 -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(module_list->NumberOfModules, 1u);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
MINIDUMP_MODULE expected = {};
|
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
|
|
|
|
&module_list->Modules[0],
|
2015-02-18 14:15:38 -05:00
|
|
|
string_file.string(),
|
2014-10-09 15:08:54 -04:00
|
|
|
kModuleName,
|
|
|
|
kPDBName,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
2014-10-09 15:08:54 -04:00
|
|
|
kPDBTimestamp,
|
|
|
|
kPDBAge,
|
|
|
|
kDebugName,
|
|
|
|
kDebugType,
|
|
|
|
kDebugUTF16));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MinidumpModuleWriter, ThreeModules) {
|
|
|
|
// As good exercise, this test uses three modules, one with a PDB 7.0 link as
|
|
|
|
// its CodeView record, one with no CodeView record, and one with a PDB 2.0
|
|
|
|
// link as its CodeView record.
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kModuleName0[] = "main";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr uint64_t kModuleBase0 = 0x100101000;
|
|
|
|
constexpr uint32_t kModuleSize0 = 0xf000;
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kPDBName0[] = "main";
|
|
|
|
static constexpr uint8_t kPDBUUIDBytes0[16] =
|
2014-08-13 15:26:21 -07:00
|
|
|
{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11,
|
|
|
|
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99};
|
2014-10-09 15:21:05 -04:00
|
|
|
UUID pdb_uuid_0;
|
|
|
|
pdb_uuid_0.InitializeFromBytes(kPDBUUIDBytes0);
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr uint32_t kPDBAge0 = 0;
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kModuleName1[] = "ld.so";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr uint64_t kModuleBase1 = 0x200202000;
|
|
|
|
constexpr uint32_t kModuleSize1 = 0x1e000;
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kModuleName2[] = "libc.so";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr uint64_t kModuleBase2 = 0x300303000;
|
|
|
|
constexpr uint32_t kModuleSize2 = 0x2d000;
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr char kPDBName2[] = "libc.so";
|
2017-07-25 19:15:48 -04:00
|
|
|
constexpr time_t kPDBTimestamp2 = 0x386d4380;
|
|
|
|
constexpr uint32_t kPDBAge2 = 2;
|
2014-10-09 15:21:05 -04:00
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_writer_0 = base::WrapUnique(new MinidumpModuleWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
module_writer_0->SetName(kModuleName0);
|
|
|
|
module_writer_0->SetImageBaseAddress(kModuleBase0);
|
|
|
|
module_writer_0->SetImageSize(kModuleSize0);
|
2014-10-09 15:21:05 -04:00
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
auto codeview_pdb70_writer_0 =
|
2016-04-25 12:13:07 -07:00
|
|
|
base::WrapUnique(new MinidumpModuleCodeViewRecordPDB70Writer());
|
2014-10-27 15:01:39 -04:00
|
|
|
codeview_pdb70_writer_0->SetPDBName(kPDBName0);
|
|
|
|
codeview_pdb70_writer_0->SetUUIDAndAge(pdb_uuid_0, kPDBAge0);
|
2015-12-09 17:36:32 -05:00
|
|
|
module_writer_0->SetCodeViewRecord(std::move(codeview_pdb70_writer_0));
|
2014-10-09 15:21:05 -04:00
|
|
|
|
2015-12-09 17:36:32 -05:00
|
|
|
module_list_writer->AddModule(std::move(module_writer_0));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_writer_1 = base::WrapUnique(new MinidumpModuleWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
module_writer_1->SetName(kModuleName1);
|
|
|
|
module_writer_1->SetImageBaseAddress(kModuleBase1);
|
|
|
|
module_writer_1->SetImageSize(kModuleSize1);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-12-09 17:36:32 -05:00
|
|
|
module_list_writer->AddModule(std::move(module_writer_1));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_writer_2 = base::WrapUnique(new MinidumpModuleWriter());
|
2014-10-27 15:01:39 -04:00
|
|
|
module_writer_2->SetName(kModuleName2);
|
|
|
|
module_writer_2->SetImageBaseAddress(kModuleBase2);
|
|
|
|
module_writer_2->SetImageSize(kModuleSize2);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
auto codeview_pdb70_writer_2 =
|
2016-04-25 12:13:07 -07:00
|
|
|
base::WrapUnique(new MinidumpModuleCodeViewRecordPDB20Writer());
|
2014-10-27 15:01:39 -04:00
|
|
|
codeview_pdb70_writer_2->SetPDBName(kPDBName2);
|
|
|
|
codeview_pdb70_writer_2->SetTimestampAndAge(kPDBTimestamp2, kPDBAge2);
|
2015-12-09 17:36:32 -05:00
|
|
|
module_writer_2->SetCodeViewRecord(std::move(codeview_pdb70_writer_2));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-12-09 17:36:32 -05:00
|
|
|
module_list_writer->AddModule(std::move(module_writer_2));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
ASSERT_GT(string_file.string().size(),
|
2014-08-13 15:26:21 -07:00
|
|
|
sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
|
|
|
|
sizeof(MINIDUMP_MODULE_LIST) + 1 * sizeof(MINIDUMP_MODULE));
|
|
|
|
|
2015-02-04 20:47:16 -08:00
|
|
|
const MINIDUMP_MODULE_LIST* module_list = nullptr;
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
GetModuleListStream(string_file.string(), &module_list));
|
2014-08-13 15:26:21 -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(module_list->NumberOfModules, 3u);
|
2014-08-13 15:26:21 -07:00
|
|
|
|
|
|
|
MINIDUMP_MODULE expected = {};
|
|
|
|
|
|
|
|
{
|
|
|
|
SCOPED_TRACE("module 0");
|
|
|
|
|
2014-10-09 15:21:05 -04:00
|
|
|
expected.BaseOfImage = kModuleBase0;
|
|
|
|
expected.SizeOfImage = kModuleSize0;
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
|
|
|
|
&module_list->Modules[0],
|
2015-02-18 14:15:38 -05:00
|
|
|
string_file.string(),
|
2014-10-09 15:21:05 -04:00
|
|
|
kModuleName0,
|
|
|
|
kPDBName0,
|
|
|
|
&pdb_uuid_0,
|
2014-10-09 15:08:54 -04:00
|
|
|
0,
|
2014-10-09 15:21:05 -04:00
|
|
|
kPDBAge0,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
2014-10-09 15:08:54 -04:00
|
|
|
0,
|
|
|
|
false));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
SCOPED_TRACE("module 1");
|
|
|
|
|
2014-10-09 15:21:05 -04:00
|
|
|
expected.BaseOfImage = kModuleBase1;
|
|
|
|
expected.SizeOfImage = kModuleSize1;
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
|
|
|
|
&module_list->Modules[1],
|
2015-02-18 14:15:38 -05:00
|
|
|
string_file.string(),
|
2014-10-09 15:21:05 -04:00
|
|
|
kModuleName1,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
|
|
|
nullptr,
|
2014-10-09 15:08:54 -04:00
|
|
|
0,
|
|
|
|
0,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
2014-10-09 15:08:54 -04:00
|
|
|
0,
|
|
|
|
false));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
SCOPED_TRACE("module 2");
|
|
|
|
|
2014-10-09 15:21:05 -04:00
|
|
|
expected.BaseOfImage = kModuleBase2;
|
|
|
|
expected.SizeOfImage = kModuleSize2;
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2014-10-09 15:08:54 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectModule(&expected,
|
|
|
|
&module_list->Modules[2],
|
2015-02-18 14:15:38 -05:00
|
|
|
string_file.string(),
|
2014-10-09 15:21:05 -04:00
|
|
|
kModuleName2,
|
|
|
|
kPDBName2,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
2014-10-09 15:21:05 -04:00
|
|
|
kPDBTimestamp2,
|
|
|
|
kPDBAge2,
|
2014-10-14 11:10:45 -04:00
|
|
|
nullptr,
|
2014-10-09 15:08:54 -04:00
|
|
|
0,
|
|
|
|
false));
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-29 11:38:49 -04:00
|
|
|
void InitializeTestModuleSnapshotFromMinidumpModule(
|
|
|
|
TestModuleSnapshot* module_snapshot,
|
|
|
|
const MINIDUMP_MODULE& minidump_module,
|
|
|
|
const std::string& name,
|
2015-10-29 10:48:23 -07:00
|
|
|
const std::string& pdb_name,
|
2015-10-27 13:06:58 -07:00
|
|
|
const crashpad::UUID& uuid,
|
|
|
|
uint32_t age) {
|
2014-10-29 11:38:49 -04:00
|
|
|
module_snapshot->SetName(name);
|
|
|
|
|
|
|
|
module_snapshot->SetAddressAndSize(minidump_module.BaseOfImage,
|
|
|
|
minidump_module.SizeOfImage);
|
|
|
|
module_snapshot->SetTimestamp(minidump_module.TimeDateStamp);
|
|
|
|
module_snapshot->SetFileVersion(
|
|
|
|
minidump_module.VersionInfo.dwFileVersionMS >> 16,
|
|
|
|
minidump_module.VersionInfo.dwFileVersionMS & 0xffff,
|
|
|
|
minidump_module.VersionInfo.dwFileVersionLS >> 16,
|
|
|
|
minidump_module.VersionInfo.dwFileVersionLS & 0xffff);
|
|
|
|
module_snapshot->SetSourceVersion(
|
|
|
|
minidump_module.VersionInfo.dwProductVersionMS >> 16,
|
|
|
|
minidump_module.VersionInfo.dwProductVersionMS & 0xffff,
|
|
|
|
minidump_module.VersionInfo.dwProductVersionLS >> 16,
|
|
|
|
minidump_module.VersionInfo.dwProductVersionLS & 0xffff);
|
|
|
|
|
|
|
|
ModuleSnapshot::ModuleType module_type;
|
|
|
|
switch (minidump_module.VersionInfo.dwFileType) {
|
|
|
|
case VFT_APP:
|
|
|
|
module_type = ModuleSnapshot::kModuleTypeExecutable;
|
|
|
|
break;
|
|
|
|
case VFT_DLL:
|
|
|
|
module_type = ModuleSnapshot::kModuleTypeSharedLibrary;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
module_type = ModuleSnapshot::kModuleTypeUnknown;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
module_snapshot->SetModuleType(module_type);
|
|
|
|
|
2015-10-27 13:06:58 -07:00
|
|
|
module_snapshot->SetUUIDAndAge(uuid, age);
|
2015-10-29 10:48:23 -07:00
|
|
|
module_snapshot->SetDebugFileName(pdb_name);
|
2014-10-29 11:38:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MinidumpModuleWriter, InitializeFromSnapshot) {
|
|
|
|
MINIDUMP_MODULE expect_modules[3] = {};
|
2014-10-30 17:15:49 -04:00
|
|
|
const char* module_paths[arraysize(expect_modules)] = {};
|
2015-10-29 10:48:23 -07:00
|
|
|
const char* module_pdbs[arraysize(expect_modules)] = {};
|
2014-10-30 17:15:49 -04:00
|
|
|
UUID uuids[arraysize(expect_modules)] = {};
|
2015-10-27 13:06:58 -07:00
|
|
|
uint32_t ages[arraysize(expect_modules)] = {};
|
2014-10-29 11:38:49 -04:00
|
|
|
|
|
|
|
expect_modules[0].BaseOfImage = 0x100101000;
|
|
|
|
expect_modules[0].SizeOfImage = 0xf000;
|
|
|
|
expect_modules[0].TimeDateStamp = 0x01234567;
|
|
|
|
expect_modules[0].VersionInfo.dwFileVersionMS = 0x00010002;
|
|
|
|
expect_modules[0].VersionInfo.dwFileVersionLS = 0x00030004;
|
|
|
|
expect_modules[0].VersionInfo.dwProductVersionMS = 0x00050006;
|
|
|
|
expect_modules[0].VersionInfo.dwProductVersionLS = 0x00070008;
|
|
|
|
expect_modules[0].VersionInfo.dwFileType = VFT_APP;
|
|
|
|
module_paths[0] = "/usr/bin/true";
|
2015-10-29 10:48:23 -07:00
|
|
|
module_pdbs[0] = "true";
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr uint8_t kUUIDBytes0[16] =
|
2014-10-29 11:38:49 -04:00
|
|
|
{0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
|
|
|
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
|
|
|
|
uuids[0].InitializeFromBytes(kUUIDBytes0);
|
2015-10-27 13:06:58 -07:00
|
|
|
ages[0] = 10;
|
2014-10-29 11:38:49 -04:00
|
|
|
|
|
|
|
expect_modules[1].BaseOfImage = 0x200202000;
|
|
|
|
expect_modules[1].SizeOfImage = 0x1e1000;
|
|
|
|
expect_modules[1].TimeDateStamp = 0x89abcdef;
|
|
|
|
expect_modules[1].VersionInfo.dwFileVersionMS = 0x0009000a;
|
|
|
|
expect_modules[1].VersionInfo.dwFileVersionLS = 0x000b000c;
|
|
|
|
expect_modules[1].VersionInfo.dwProductVersionMS = 0x000d000e;
|
|
|
|
expect_modules[1].VersionInfo.dwProductVersionLS = 0x000f0000;
|
|
|
|
expect_modules[1].VersionInfo.dwFileType = VFT_DLL;
|
|
|
|
module_paths[1] = "/usr/lib/libSystem.B.dylib";
|
2015-10-29 10:48:23 -07:00
|
|
|
module_pdbs[1] = "libSystem.B.dylib.pdb";
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr uint8_t kUUIDBytes1[16] =
|
2014-10-29 11:38:49 -04:00
|
|
|
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
|
|
|
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
|
|
|
|
uuids[1].InitializeFromBytes(kUUIDBytes1);
|
2015-10-27 13:06:58 -07:00
|
|
|
ages[1] = 20;
|
2014-10-29 11:38:49 -04:00
|
|
|
|
|
|
|
expect_modules[2].BaseOfImage = 0x300303000;
|
|
|
|
expect_modules[2].SizeOfImage = 0x2d000;
|
|
|
|
expect_modules[2].TimeDateStamp = 0x76543210;
|
|
|
|
expect_modules[2].VersionInfo.dwFileVersionMS = 0x11112222;
|
|
|
|
expect_modules[2].VersionInfo.dwFileVersionLS = 0x33334444;
|
|
|
|
expect_modules[2].VersionInfo.dwProductVersionMS = 0x9999aaaa;
|
|
|
|
expect_modules[2].VersionInfo.dwProductVersionLS = 0xbbbbcccc;
|
|
|
|
expect_modules[2].VersionInfo.dwFileType = VFT_UNKNOWN;
|
|
|
|
module_paths[2] = "/usr/lib/dyld";
|
2015-10-29 10:48:23 -07:00
|
|
|
module_pdbs[2] = "/usr/lib/dyld.pdb";
|
2017-07-25 13:34:04 -04:00
|
|
|
static constexpr uint8_t kUUIDBytes2[16] =
|
2014-10-29 11:38:49 -04:00
|
|
|
{0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
|
|
|
|
0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, 0xf1, 0xf0};
|
|
|
|
uuids[2].InitializeFromBytes(kUUIDBytes2);
|
2015-10-27 13:06:58 -07:00
|
|
|
ages[2] = 30;
|
2014-10-29 11:38:49 -04:00
|
|
|
|
|
|
|
PointerVector<TestModuleSnapshot> module_snapshots_owner;
|
|
|
|
std::vector<const ModuleSnapshot*> module_snapshots;
|
|
|
|
for (size_t index = 0; index < arraysize(expect_modules); ++index) {
|
|
|
|
TestModuleSnapshot* module_snapshot = new TestModuleSnapshot();
|
|
|
|
module_snapshots_owner.push_back(module_snapshot);
|
|
|
|
InitializeTestModuleSnapshotFromMinidumpModule(module_snapshot,
|
|
|
|
expect_modules[index],
|
|
|
|
module_paths[index],
|
2015-10-29 10:48:23 -07:00
|
|
|
module_pdbs[index],
|
2015-10-27 13:06:58 -07:00
|
|
|
uuids[index],
|
|
|
|
ages[index]);
|
2014-10-29 11:38:49 -04:00
|
|
|
module_snapshots.push_back(module_snapshot);
|
|
|
|
}
|
|
|
|
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
2014-10-29 11:38:49 -04:00
|
|
|
module_list_writer->InitializeFromSnapshot(module_snapshots);
|
|
|
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2017-03-15 15:35:36 -04:00
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
|
2014-10-29 11:38:49 -04:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
StringFile string_file;
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-10-29 11:38:49 -04:00
|
|
|
|
2015-02-04 20:47:16 -08:00
|
|
|
const MINIDUMP_MODULE_LIST* module_list = nullptr;
|
2014-10-29 11:38:49 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(
|
2015-02-18 14:15:38 -05:00
|
|
|
GetModuleListStream(string_file.string(), &module_list));
|
2014-10-29 11:38:49 -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(module_list->NumberOfModules, 3u);
|
2014-10-29 11:38:49 -04:00
|
|
|
|
|
|
|
for (size_t index = 0; index < module_list->NumberOfModules; ++index) {
|
2015-02-05 15:04:49 -08:00
|
|
|
SCOPED_TRACE(base::StringPrintf("index %" PRIuS, index));
|
2014-10-29 11:38:49 -04:00
|
|
|
ASSERT_NO_FATAL_FAILURE(ExpectModule(&expect_modules[index],
|
|
|
|
&module_list->Modules[index],
|
2015-02-18 14:15:38 -05:00
|
|
|
string_file.string(),
|
2014-10-29 11:38:49 -04:00
|
|
|
module_paths[index],
|
2015-10-29 10:48:23 -07:00
|
|
|
module_pdbs[index],
|
2014-10-29 11:38:49 -04:00
|
|
|
&uuids[index],
|
|
|
|
0,
|
2015-10-27 13:06:58 -07:00
|
|
|
ages[index],
|
2014-10-29 11:38:49 -04:00
|
|
|
nullptr,
|
|
|
|
0,
|
|
|
|
false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(MinidumpModuleWriterDeathTest, NoModuleName) {
|
2014-08-13 15:26:21 -07:00
|
|
|
MinidumpFileWriter minidump_file_writer;
|
2016-04-25 12:13:07 -07:00
|
|
|
auto module_list_writer = base::WrapUnique(new MinidumpModuleListWriter());
|
|
|
|
auto module_writer = base::WrapUnique(new MinidumpModuleWriter());
|
2015-12-09 17:36:32 -05:00
|
|
|
module_list_writer->AddModule(std::move(module_writer));
|
2017-03-15 15:35:36 -04:00
|
|
|
ASSERT_TRUE(minidump_file_writer.AddStream(std::move(module_list_writer)));
|
2014-08-13 15:26:21 -07:00
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
StringFile string_file;
|
2015-03-09 18:02:14 -04:00
|
|
|
ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),
|
|
|
|
"name_");
|
2014-08-13 15:26:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2014-10-07 17:28:50 -04:00
|
|
|
} // namespace test
|
|
|
|
} // namespace crashpad
|