2022-09-06 19:14:07 -04:00
|
|
|
|
// Copyright 2014 The Crashpad Authors
|
2014-08-03 18:47:34 -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_file_writer.h"
|
|
|
|
|
|
2016-01-06 12:22:50 -05:00
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2022-02-28 20:57:19 -08:00
|
|
|
|
#include <iterator>
|
2014-08-03 18:47:34 -04:00
|
|
|
|
#include <string>
|
2015-12-09 17:36:32 -05:00
|
|
|
|
#include <utility>
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2018-10-19 09:11:07 -07:00
|
|
|
|
#include "build/build_config.h"
|
2014-08-03 18:47:34 -04:00
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
#include "minidump/minidump_stream_writer.h"
|
2017-03-23 08:52:46 -04:00
|
|
|
|
#include "minidump/minidump_user_extension_stream_data_source.h"
|
2014-10-20 12:11:14 -04:00
|
|
|
|
#include "minidump/test/minidump_file_writer_test_util.h"
|
2017-04-11 14:48:10 -04:00
|
|
|
|
#include "minidump/test/minidump_user_extension_stream_util.h"
|
2014-10-22 18:35:18 -04:00
|
|
|
|
#include "minidump/test/minidump_writable_test_util.h"
|
2014-11-07 14:47:08 -05:00
|
|
|
|
#include "snapshot/test/test_cpu_context.h"
|
|
|
|
|
#include "snapshot/test/test_exception_snapshot.h"
|
2015-09-25 10:31:02 -07:00
|
|
|
|
#include "snapshot/test/test_memory_snapshot.h"
|
2014-11-07 14:47:08 -05:00
|
|
|
|
#include "snapshot/test/test_module_snapshot.h"
|
|
|
|
|
#include "snapshot/test/test_process_snapshot.h"
|
|
|
|
|
#include "snapshot/test/test_system_snapshot.h"
|
|
|
|
|
#include "snapshot/test/test_thread_snapshot.h"
|
mac: Tests that crash intentionally shouldn’t go to ReportCrash
Crashpad has many tests that crash intentionally. Some of these are
gtest death tests, and others arrange for intentional crashes to test
Crashpad’s own crash-catching logic. On macOS, all of the gtest death
tests and some of the other intentional crashes were being logged by
ReportCrash, the system’s crash reporter. Since these reports
corresponded to intentional crashes, they were never useful, and served
only to clutter ~/Library/Logs/DiagnosticReports.
Since Crashpad is adept at handling exceptions on its own, this
introduces the “exception swallowing server”,
crashpad_exception_swallower, which is a Mach exception server that
implements a no-op exception handler routine for all exceptions
received. The exception swallowing server is established as the task
handler for EXC_CRASH and EXC_CORPSE_NOTIFY exceptions during gtest
death tests invoked by {ASSERT,EXPECT}_DEATH_{CHECK,CRASH}, and for all
child processes invoked by the Multiprocess test infrastructure. The
exception swallowing server is not in effect at other times, so
unexpected crashes in test code can still be handled by ReportCrash or
another crash reporter.
With this change in place, no new reports are generated in the
user-level ~/Library/Logs/DiagnosticReports or the system’s
/Library/Logs/DiagnosticReports during a run of Crashpad’s full test
suite on macOS.
Bug: crashpad:33
Change-Id: I13891853a7e25accc30da21fa7ea8bd7d1f3bd2f
Reviewed-on: https://chromium-review.googlesource.com/777859
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-11-20 13:32:26 -05:00
|
|
|
|
#include "test/gtest_death.h"
|
2020-01-28 12:02:55 -08:00
|
|
|
|
#include "util/file/output_stream_file_writer.h"
|
2015-02-18 14:15:38 -05:00
|
|
|
|
#include "util/file/string_file.h"
|
2020-01-28 12:02:55 -08:00
|
|
|
|
#include "util/stream/output_stream_interface.h"
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2014-10-07 17:28:50 -04:00
|
|
|
|
namespace crashpad {
|
|
|
|
|
namespace test {
|
2014-08-03 18:47:34 -04:00
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpFileWriter, Empty) {
|
|
|
|
|
MinidumpFileWriter minidump_file;
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
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));
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2014-10-21 14:15:07 -04:00
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
2014-08-03 18:47:34 -04:00
|
|
|
|
const MINIDUMP_HEADER* header =
|
2015-02-18 14:15:38 -05:00
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 0, 0));
|
2014-10-21 14:15:07 -04:00
|
|
|
|
EXPECT_FALSE(directory);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TestStream final : public internal::MinidumpStreamWriter {
|
|
|
|
|
public:
|
|
|
|
|
TestStream(MinidumpStreamType stream_type,
|
|
|
|
|
size_t stream_size,
|
|
|
|
|
uint8_t stream_value)
|
|
|
|
|
: stream_data_(stream_size, stream_value), stream_type_(stream_type) {}
|
|
|
|
|
|
2021-09-20 12:55:12 -07:00
|
|
|
|
TestStream(const TestStream&) = delete;
|
|
|
|
|
TestStream& operator=(const TestStream&) = delete;
|
|
|
|
|
|
2014-10-27 15:01:39 -04:00
|
|
|
|
~TestStream() override {}
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
|
|
|
|
// MinidumpStreamWriter:
|
2014-10-14 11:11:57 -04:00
|
|
|
|
MinidumpStreamType StreamType() const override {
|
2014-08-03 18:47:34 -04:00
|
|
|
|
return stream_type_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// MinidumpWritable:
|
2014-10-14 11:11:57 -04:00
|
|
|
|
size_t SizeOfObject() override {
|
2014-08-03 18:47:34 -04:00
|
|
|
|
EXPECT_GE(state(), kStateFrozen);
|
|
|
|
|
return stream_data_.size();
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-14 11:11:57 -04:00
|
|
|
|
bool WriteObject(FileWriterInterface* file_writer) override {
|
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(kStateWritable, state());
|
2014-08-03 18:47:34 -04:00
|
|
|
|
return file_writer->Write(&stream_data_[0], stream_data_.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::string stream_data_;
|
|
|
|
|
MinidumpStreamType stream_type_;
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-28 12:02:55 -08:00
|
|
|
|
class StringFileOutputStream : public OutputStreamInterface {
|
|
|
|
|
public:
|
|
|
|
|
StringFileOutputStream() = default;
|
2021-09-20 12:55:12 -07:00
|
|
|
|
|
|
|
|
|
StringFileOutputStream(const StringFileOutputStream&) = delete;
|
|
|
|
|
StringFileOutputStream& operator=(const StringFileOutputStream&) = delete;
|
|
|
|
|
|
2020-01-28 12:02:55 -08:00
|
|
|
|
~StringFileOutputStream() override = default;
|
|
|
|
|
bool Write(const uint8_t* data, size_t size) override {
|
|
|
|
|
return string_file_.Write(data, size);
|
|
|
|
|
}
|
|
|
|
|
bool Flush() override { return true; }
|
|
|
|
|
const StringFile& string_file() const { return string_file_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
StringFile string_file_;
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-03 18:47:34 -04:00
|
|
|
|
TEST(MinidumpFileWriter, OneStream) {
|
|
|
|
|
MinidumpFileWriter minidump_file;
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr time_t kTimestamp = 0x155d2fb8;
|
2014-08-03 18:47:34 -04:00
|
|
|
|
minidump_file.SetTimestamp(kTimestamp);
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStreamSize = 5;
|
|
|
|
|
constexpr MinidumpStreamType kStreamType =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x4d);
|
|
|
|
|
constexpr uint8_t kStreamValue = 0x5a;
|
2014-10-27 15:01:39 -04:00
|
|
|
|
auto stream =
|
2017-10-12 12:42:28 -04:00
|
|
|
|
std::make_unique<TestStream>(kStreamType, kStreamSize, kStreamValue);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddStream(std::move(stream)));
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kStreamOffset =
|
|
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
|
|
|
|
constexpr size_t kFileSize = kStreamOffset + kStreamSize;
|
2014-08-03 18:47:34 -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(string_file.string().size(), kFileSize);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2014-10-21 14:15:07 -04:00
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
2014-08-03 18:47:34 -04:00
|
|
|
|
const MINIDUMP_HEADER* header =
|
2015-02-18 14:15:38 -05:00
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, kTimestamp));
|
2014-10-21 14:15:07 -04:00
|
|
|
|
ASSERT_TRUE(directory);
|
2014-08-03 18:47:34 -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(directory[0].StreamType, kStreamType);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.DataSize, kStreamSize);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kStreamOffset);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2014-10-22 18:35:18 -04:00
|
|
|
|
const uint8_t* stream_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[0].Location);
|
2014-10-22 18:35:18 -04:00
|
|
|
|
ASSERT_TRUE(stream_data);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
|
|
|
|
std::string expected_stream(kStreamSize, kStreamValue);
|
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(stream_data, expected_stream.c_str(), kStreamSize), 0);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 08:52:46 -04:00
|
|
|
|
TEST(MinidumpFileWriter, AddUserExtensionStream) {
|
|
|
|
|
MinidumpFileWriter minidump_file;
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr time_t kTimestamp = 0x155d2fb8;
|
2017-03-23 08:52:46 -04:00
|
|
|
|
minidump_file.SetTimestamp(kTimestamp);
|
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr uint8_t kStreamData[] = "Hello World!";
|
2022-02-28 20:57:19 -08:00
|
|
|
|
constexpr size_t kStreamSize = std::size(kStreamData);
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr MinidumpStreamType kStreamType =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x4d);
|
2017-03-23 08:52:46 -04:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto data_source = std::make_unique<test::BufferExtensionStreamDataSource>(
|
|
|
|
|
kStreamType, kStreamData, kStreamSize);
|
2017-04-11 14:48:10 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddUserExtensionStream(std::move(data_source)));
|
2017-03-23 08:52:46 -04:00
|
|
|
|
|
|
|
|
|
// Adding the same stream type a second time should fail.
|
2017-10-12 12:42:28 -04:00
|
|
|
|
data_source = std::make_unique<test::BufferExtensionStreamDataSource>(
|
|
|
|
|
kStreamType, kStreamData, kStreamSize);
|
2017-04-11 14:48:10 -04:00
|
|
|
|
ASSERT_FALSE(minidump_file.AddUserExtensionStream(std::move(data_source)));
|
2017-03-23 08:52:46 -04:00
|
|
|
|
|
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kStreamOffset =
|
|
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
|
|
|
|
constexpr size_t kFileSize = kStreamOffset + kStreamSize;
|
2017-03-23 08:52:46 -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(string_file.string().size(), kFileSize);
|
2017-03-23 08:52:46 -04:00
|
|
|
|
|
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
|
|
|
|
const MINIDUMP_HEADER* header =
|
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, kTimestamp));
|
|
|
|
|
ASSERT_TRUE(directory);
|
|
|
|
|
|
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(directory[0].StreamType, kStreamType);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.DataSize, kStreamSize);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kStreamOffset);
|
2017-03-23 08:52:46 -04:00
|
|
|
|
|
|
|
|
|
const uint8_t* stream_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
|
|
|
|
|
string_file.string(), directory[0].Location);
|
|
|
|
|
ASSERT_TRUE(stream_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(memcmp(stream_data, kStreamData, kStreamSize), 0);
|
2017-03-23 08:52:46 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-11 14:48:10 -04:00
|
|
|
|
TEST(MinidumpFileWriter, AddEmptyUserExtensionStream) {
|
|
|
|
|
MinidumpFileWriter minidump_file;
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr time_t kTimestamp = 0x155d2fb8;
|
2017-04-11 14:48:10 -04:00
|
|
|
|
minidump_file.SetTimestamp(kTimestamp);
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr MinidumpStreamType kStreamType =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x4d);
|
2017-04-11 14:48:10 -04:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto data_source = std::make_unique<test::BufferExtensionStreamDataSource>(
|
|
|
|
|
kStreamType, nullptr, 0);
|
2017-04-11 14:48:10 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddUserExtensionStream(std::move(data_source)));
|
|
|
|
|
|
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kStreamOffset =
|
|
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
|
|
|
|
constexpr size_t kFileSize = kStreamOffset;
|
2017-04-11 14:48:10 -04:00
|
|
|
|
|
|
|
|
|
ASSERT_EQ(string_file.string().size(), kFileSize);
|
|
|
|
|
|
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
|
|
|
|
const MINIDUMP_HEADER* header =
|
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, kTimestamp));
|
|
|
|
|
ASSERT_TRUE(directory);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(directory[0].StreamType, kStreamType);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.DataSize, 0u);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kStreamOffset);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-03 18:47:34 -04:00
|
|
|
|
TEST(MinidumpFileWriter, ThreeStreams) {
|
|
|
|
|
MinidumpFileWriter minidump_file;
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr time_t kTimestamp = 0x155d2fb8;
|
2014-08-03 18:47:34 -04:00
|
|
|
|
minidump_file.SetTimestamp(kTimestamp);
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStream0Size = 5;
|
|
|
|
|
constexpr MinidumpStreamType kStream0Type =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x6d);
|
|
|
|
|
constexpr uint8_t kStream0Value = 0x5a;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto stream0 =
|
|
|
|
|
std::make_unique<TestStream>(kStream0Type, kStream0Size, kStream0Value);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddStream(std::move(stream0)));
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
|
|
|
|
// Make the second stream’s type be a smaller quantity than the first stream’s
|
|
|
|
|
// to test that the streams show up in the order that they were added, not in
|
|
|
|
|
// numeric order.
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStream1Size = 3;
|
|
|
|
|
constexpr MinidumpStreamType kStream1Type =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x4d);
|
|
|
|
|
constexpr uint8_t kStream1Value = 0xa5;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto stream1 =
|
|
|
|
|
std::make_unique<TestStream>(kStream1Type, kStream1Size, kStream1Value);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddStream(std::move(stream1)));
|
2014-10-22 18:35:18 -04:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStream2Size = 1;
|
|
|
|
|
constexpr MinidumpStreamType kStream2Type =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x7e);
|
|
|
|
|
constexpr uint8_t kStream2Value = 0x36;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto stream2 =
|
|
|
|
|
std::make_unique<TestStream>(kStream2Type, kStream2Size, kStream2Value);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddStream(std::move(stream2)));
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kStream0Offset =
|
2014-08-03 18:47:34 -04:00
|
|
|
|
kDirectoryOffset + 3 * sizeof(MINIDUMP_DIRECTORY);
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStream1Padding = 3;
|
|
|
|
|
constexpr size_t kStream1Offset =
|
|
|
|
|
kStream0Offset + kStream0Size + kStream1Padding;
|
|
|
|
|
constexpr size_t kStream2Padding = 1;
|
|
|
|
|
constexpr size_t kStream2Offset =
|
|
|
|
|
kStream1Offset + kStream1Size + kStream2Padding;
|
|
|
|
|
constexpr size_t kFileSize = kStream2Offset + kStream2Size;
|
2014-08-03 18:47:34 -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(string_file.string().size(), kFileSize);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2014-10-21 14:15:07 -04:00
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
2014-08-03 18:47:34 -04:00
|
|
|
|
const MINIDUMP_HEADER* header =
|
2015-02-18 14:15:38 -05:00
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
2014-10-09 15:08:54 -04:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 3, kTimestamp));
|
2014-10-21 14:15:07 -04:00
|
|
|
|
ASSERT_TRUE(directory);
|
2014-08-03 18:47:34 -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(directory[0].StreamType, kStream0Type);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.DataSize, kStream0Size);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kStream0Offset);
|
|
|
|
|
EXPECT_EQ(directory[1].StreamType, kStream1Type);
|
|
|
|
|
EXPECT_EQ(directory[1].Location.DataSize, kStream1Size);
|
|
|
|
|
EXPECT_EQ(directory[1].Location.Rva, kStream1Offset);
|
|
|
|
|
EXPECT_EQ(directory[2].StreamType, kStream2Type);
|
|
|
|
|
EXPECT_EQ(directory[2].Location.DataSize, kStream2Size);
|
|
|
|
|
EXPECT_EQ(directory[2].Location.Rva, kStream2Offset);
|
2014-10-22 18:35:18 -04:00
|
|
|
|
|
|
|
|
|
const uint8_t* stream0_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[0].Location);
|
2014-10-22 18:35:18 -04:00
|
|
|
|
ASSERT_TRUE(stream0_data);
|
|
|
|
|
|
|
|
|
|
std::string expected_stream0(kStream0Size, kStream0Value);
|
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(stream0_data, expected_stream0.c_str(), kStream0Size), 0);
|
2014-10-22 18:35:18 -04:00
|
|
|
|
|
2017-07-25 13:34:04 -04:00
|
|
|
|
static constexpr int kZeroes[16] = {};
|
2014-10-22 18:35:18 -04:00
|
|
|
|
ASSERT_GE(sizeof(kZeroes), kStream1Padding);
|
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(stream0_data + kStream0Size, kZeroes, kStream1Padding), 0);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2014-10-22 18:35:18 -04:00
|
|
|
|
const uint8_t* stream1_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[1].Location);
|
2014-10-22 18:35:18 -04:00
|
|
|
|
ASSERT_TRUE(stream1_data);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
|
|
|
|
std::string expected_stream1(kStream1Size, kStream1Value);
|
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(stream1_data, expected_stream1.c_str(), kStream1Size), 0);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
|
|
|
|
ASSERT_GE(sizeof(kZeroes), kStream2Padding);
|
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(stream1_data + kStream1Size, kZeroes, kStream2Padding), 0);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2014-10-22 18:35:18 -04:00
|
|
|
|
const uint8_t* stream2_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[2].Location);
|
2014-10-22 18:35:18 -04:00
|
|
|
|
ASSERT_TRUE(stream2_data);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
|
|
|
|
std::string expected_stream2(kStream2Size, kStream2Value);
|
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(stream2_data, expected_stream2.c_str(), kStream2Size), 0);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
}
|
|
|
|
|
|
2014-08-12 10:26:40 -07:00
|
|
|
|
TEST(MinidumpFileWriter, ZeroLengthStream) {
|
|
|
|
|
MinidumpFileWriter minidump_file;
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStreamSize = 0;
|
|
|
|
|
constexpr MinidumpStreamType kStreamType =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x4d);
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto stream = std::make_unique<TestStream>(
|
|
|
|
|
kStreamType, kStreamSize, static_cast<uint8_t>(0));
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddStream(std::move(stream)));
|
2014-08-12 10:26:40 -07:00
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
2014-08-12 10:26:40 -07:00
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kStreamOffset =
|
|
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
|
|
|
|
constexpr size_t kFileSize = kStreamOffset + kStreamSize;
|
2014-08-12 10:26:40 -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(), kFileSize);
|
2014-08-12 10:26:40 -07:00
|
|
|
|
|
2014-10-21 14:15:07 -04:00
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
2014-08-12 10:26:40 -07:00
|
|
|
|
const MINIDUMP_HEADER* header =
|
2015-02-18 14:15:38 -05:00
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &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-12 10:26:40 -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(directory[0].StreamType, kStreamType);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.DataSize, kStreamSize);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kStreamOffset);
|
2014-08-12 10:26:40 -07:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-07 14:47:08 -05:00
|
|
|
|
TEST(MinidumpFileWriter, InitializeFromSnapshot_Basic) {
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint32_t kSnapshotTime = 0x4976043c;
|
|
|
|
|
constexpr timeval kSnapshotTimeval = {static_cast<time_t>(kSnapshotTime), 0};
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
TestProcessSnapshot process_snapshot;
|
|
|
|
|
process_snapshot.SetSnapshotTime(kSnapshotTimeval);
|
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_snapshot = std::make_unique<TestSystemSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
system_snapshot->SetCPUArchitecture(kCPUArchitectureX86_64);
|
|
|
|
|
system_snapshot->SetOperatingSystem(SystemSnapshot::kOperatingSystemMacOSX);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.SetSystem(std::move(system_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto peb_snapshot = std::make_unique<TestMemorySnapshot>();
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint64_t kPebAddress = 0x07f90000;
|
2015-09-25 10:31:02 -07:00
|
|
|
|
peb_snapshot->SetAddress(kPebAddress);
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kPebSize = 0x280;
|
2015-09-25 10:31:02 -07:00
|
|
|
|
peb_snapshot->SetSize(kPebSize);
|
|
|
|
|
peb_snapshot->SetValue('p');
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.AddExtraMemory(std::move(peb_snapshot));
|
2015-09-25 10:31:02 -07:00
|
|
|
|
|
2014-11-07 14:47:08 -05:00
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
|
|
|
|
minidump_file_writer.InitializeFromSnapshot(&process_snapshot);
|
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
|
|
|
|
const MINIDUMP_HEADER* header =
|
2015-02-18 14:15:38 -05:00
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 5, kSnapshotTime));
|
|
|
|
|
ASSERT_TRUE(directory);
|
|
|
|
|
|
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(directory[0].StreamType, kMinidumpStreamTypeSystemInfo);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_SYSTEM_INFO>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[0].Location));
|
2014-11-07 14:47:08 -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(directory[1].StreamType, kMinidumpStreamTypeMiscInfo);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MISC_INFO_4>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[1].Location));
|
2014-11-07 14:47:08 -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(directory[2].StreamType, kMinidumpStreamTypeThreadList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_THREAD_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[2].Location));
|
2014-11-07 14:47:08 -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(directory[3].StreamType, kMinidumpStreamTypeModuleList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MODULE_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[3].Location));
|
2014-11-07 14:47:08 -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(directory[4].StreamType, kMinidumpStreamTypeMemoryList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[4].Location));
|
2015-09-25 10:31:02 -07:00
|
|
|
|
|
|
|
|
|
const MINIDUMP_MEMORY_LIST* memory_list =
|
|
|
|
|
MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>(
|
|
|
|
|
string_file.string(), directory[4].Location);
|
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(memory_list->NumberOfMemoryRanges, 1u);
|
|
|
|
|
EXPECT_EQ(memory_list->MemoryRanges[0].StartOfMemoryRange, kPebAddress);
|
|
|
|
|
EXPECT_EQ(memory_list->MemoryRanges[0].Memory.DataSize, kPebSize);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) {
|
2018-10-19 09:11:07 -07:00
|
|
|
|
// In a 32-bit environment, this will give a “timestamp out of range” warning,
|
2014-11-07 14:47:08 -05:00
|
|
|
|
// but the test should complete without failure.
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint32_t kSnapshotTime = 0xfd469ab8;
|
2018-10-19 09:11:07 -07:00
|
|
|
|
constexpr timeval kSnapshotTimeval = {
|
2022-01-19 15:00:24 -05:00
|
|
|
|
#if BUILDFLAG(IS_WIN)
|
|
|
|
|
static_cast<long>(kSnapshotTime),
|
2018-10-19 09:11:07 -07:00
|
|
|
|
#else
|
2022-01-19 15:00:24 -05:00
|
|
|
|
static_cast<time_t>(kSnapshotTime),
|
2018-10-19 09:11:07 -07:00
|
|
|
|
#endif
|
2022-01-19 15:00:24 -05:00
|
|
|
|
0
|
|
|
|
|
};
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
TestProcessSnapshot process_snapshot;
|
|
|
|
|
process_snapshot.SetSnapshotTime(kSnapshotTimeval);
|
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_snapshot = std::make_unique<TestSystemSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
system_snapshot->SetCPUArchitecture(kCPUArchitectureX86_64);
|
|
|
|
|
system_snapshot->SetOperatingSystem(SystemSnapshot::kOperatingSystemMacOSX);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.SetSystem(std::move(system_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto thread_snapshot = std::make_unique<TestThreadSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
InitializeCPUContextX86_64(thread_snapshot->MutableContext(), 5);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.AddThread(std::move(thread_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto exception_snapshot = std::make_unique<TestExceptionSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
InitializeCPUContextX86_64(exception_snapshot->MutableContext(), 11);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.SetException(std::move(exception_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
// The module does not have anything that needs to be represented in a
|
|
|
|
|
// MinidumpModuleCrashpadInfo structure, so no such structure is expected to
|
|
|
|
|
// be present, which will in turn suppress the addition of a
|
|
|
|
|
// MinidumpCrashpadInfo stream.
|
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 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
|
|
|
|
minidump_file_writer.InitializeFromSnapshot(&process_snapshot);
|
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
|
|
|
|
const MINIDUMP_HEADER* header =
|
2015-02-18 14:15:38 -05:00
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 6, kSnapshotTime));
|
|
|
|
|
ASSERT_TRUE(directory);
|
|
|
|
|
|
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(directory[0].StreamType, kMinidumpStreamTypeSystemInfo);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_SYSTEM_INFO>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[0].Location));
|
2014-11-07 14:47:08 -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(directory[1].StreamType, kMinidumpStreamTypeMiscInfo);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MISC_INFO_4>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[1].Location));
|
2014-11-07 14:47:08 -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(directory[2].StreamType, kMinidumpStreamTypeThreadList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_THREAD_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[2].Location));
|
2014-11-07 14:47:08 -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(directory[3].StreamType, kMinidumpStreamTypeException);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_EXCEPTION_STREAM>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[3].Location));
|
2014-11-07 14:47:08 -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(directory[4].StreamType, kMinidumpStreamTypeModuleList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MODULE_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[4].Location));
|
2014-11-07 14:47:08 -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(directory[5].StreamType, kMinidumpStreamTypeMemoryList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[5].Location));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(MinidumpFileWriter, InitializeFromSnapshot_CrashpadInfo) {
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr uint32_t kSnapshotTime = 0x15393bd3;
|
|
|
|
|
constexpr timeval kSnapshotTimeval = {static_cast<time_t>(kSnapshotTime), 0};
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
TestProcessSnapshot process_snapshot;
|
|
|
|
|
process_snapshot.SetSnapshotTime(kSnapshotTimeval);
|
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto system_snapshot = std::make_unique<TestSystemSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
system_snapshot->SetCPUArchitecture(kCPUArchitectureX86_64);
|
|
|
|
|
system_snapshot->SetOperatingSystem(SystemSnapshot::kOperatingSystemMacOSX);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.SetSystem(std::move(system_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto thread_snapshot = std::make_unique<TestThreadSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
InitializeCPUContextX86_64(thread_snapshot->MutableContext(), 5);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.AddThread(std::move(thread_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto exception_snapshot = std::make_unique<TestExceptionSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
InitializeCPUContextX86_64(exception_snapshot->MutableContext(), 11);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.SetException(std::move(exception_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
// The module needs an annotation for the MinidumpCrashpadInfo stream to be
|
|
|
|
|
// considered useful and be included.
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto module_snapshot = std::make_unique<TestModuleSnapshot>();
|
2014-11-07 14:47:08 -05:00
|
|
|
|
std::vector<std::string> annotations_list(1, std::string("annotation"));
|
|
|
|
|
module_snapshot->SetAnnotationsVector(annotations_list);
|
2015-12-09 17:36:32 -05:00
|
|
|
|
process_snapshot.AddModule(std::move(module_snapshot));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
MinidumpFileWriter minidump_file_writer;
|
|
|
|
|
minidump_file_writer.InitializeFromSnapshot(&process_snapshot);
|
|
|
|
|
|
2015-02-18 14:15:38 -05:00
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
|
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
|
|
|
|
const MINIDUMP_HEADER* header =
|
2015-02-18 14:15:38 -05:00
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 7, kSnapshotTime));
|
|
|
|
|
ASSERT_TRUE(directory);
|
|
|
|
|
|
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(directory[0].StreamType, kMinidumpStreamTypeSystemInfo);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_SYSTEM_INFO>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[0].Location));
|
2014-11-07 14:47:08 -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(directory[1].StreamType, kMinidumpStreamTypeMiscInfo);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MISC_INFO_4>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[1].Location));
|
2014-11-07 14:47:08 -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(directory[2].StreamType, kMinidumpStreamTypeThreadList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_THREAD_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[2].Location));
|
2014-11-07 14:47:08 -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(directory[3].StreamType, kMinidumpStreamTypeException);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_EXCEPTION_STREAM>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[3].Location));
|
2014-11-07 14:47:08 -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(directory[4].StreamType, kMinidumpStreamTypeModuleList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MODULE_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[4].Location));
|
2014-11-07 14:47:08 -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(directory[5].StreamType, kMinidumpStreamTypeCrashpadInfo);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MinidumpCrashpadInfo>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[5].Location));
|
2014-11-07 14:47:08 -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(directory[6].StreamType, kMinidumpStreamTypeMemoryList);
|
2014-11-07 14:47:08 -05:00
|
|
|
|
EXPECT_TRUE(MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_LIST>(
|
2015-02-18 14:15:38 -05:00
|
|
|
|
string_file.string(), directory[6].Location));
|
2014-11-07 14:47:08 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
TEST(MinidumpFileWriter, SameStreamType) {
|
2014-08-03 18:47:34 -04:00
|
|
|
|
MinidumpFileWriter minidump_file;
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStream0Size = 3;
|
|
|
|
|
constexpr MinidumpStreamType kStreamType =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x4d);
|
|
|
|
|
constexpr uint8_t kStream0Value = 0x5a;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto stream0 =
|
|
|
|
|
std::make_unique<TestStream>(kStreamType, kStream0Size, kStream0Value);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_TRUE(minidump_file.AddStream(std::move(stream0)));
|
2014-08-03 18:47:34 -04:00
|
|
|
|
|
2017-03-15 15:35:36 -04:00
|
|
|
|
// An attempt to add a second stream of the same type should fail.
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kStream1Size = 5;
|
|
|
|
|
constexpr uint8_t kStream1Value = 0xa5;
|
2017-10-12 12:42:28 -04:00
|
|
|
|
auto stream1 =
|
|
|
|
|
std::make_unique<TestStream>(kStreamType, kStream1Size, kStream1Value);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
ASSERT_FALSE(minidump_file.AddStream(std::move(stream1)));
|
|
|
|
|
|
|
|
|
|
StringFile string_file;
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
|
|
|
|
|
|
2017-07-25 19:15:48 -04:00
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kStream0Offset =
|
|
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
|
|
|
|
constexpr size_t kFileSize = kStream0Offset + kStream0Size;
|
2017-03-15 15:35:36 -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(string_file.string().size(), kFileSize);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
|
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
|
|
|
|
const MINIDUMP_HEADER* header =
|
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0));
|
|
|
|
|
ASSERT_TRUE(directory);
|
|
|
|
|
|
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(directory[0].StreamType, kStreamType);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.DataSize, kStream0Size);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kStream0Offset);
|
2017-03-15 15:35:36 -04:00
|
|
|
|
|
|
|
|
|
const uint8_t* stream_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
|
|
|
|
|
string_file.string(), directory[0].Location);
|
|
|
|
|
ASSERT_TRUE(stream_data);
|
|
|
|
|
|
|
|
|
|
std::string expected_stream(kStream0Size, kStream0Value);
|
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(stream_data, expected_stream.c_str(), kStream0Size), 0);
|
2014-08-03 18:47:34 -04:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-28 12:02:55 -08:00
|
|
|
|
TEST(MinidumpFileWriter, WriteMinidumpDisallowSeek) {
|
|
|
|
|
MinidumpFileWriter minidump_file;
|
|
|
|
|
constexpr time_t kTimestamp = 0x155d2fb8;
|
|
|
|
|
minidump_file.SetTimestamp(kTimestamp);
|
|
|
|
|
|
|
|
|
|
constexpr size_t kStreamSize = 5;
|
|
|
|
|
constexpr MinidumpStreamType kStreamType =
|
|
|
|
|
static_cast<MinidumpStreamType>(0x4d);
|
|
|
|
|
constexpr uint8_t kStreamValue = 0x5a;
|
|
|
|
|
auto stream =
|
|
|
|
|
std::make_unique<TestStream>(kStreamType, kStreamSize, kStreamValue);
|
|
|
|
|
ASSERT_TRUE(minidump_file.AddStream(std::move(stream)));
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<StringFileOutputStream> string_file_output_stream =
|
|
|
|
|
std::make_unique<StringFileOutputStream>();
|
|
|
|
|
const StringFile& string_file = string_file_output_stream->string_file();
|
|
|
|
|
OutputStreamFileWriter output_stream(std::move(string_file_output_stream));
|
|
|
|
|
ASSERT_TRUE(minidump_file.WriteMinidump(&output_stream, false));
|
|
|
|
|
ASSERT_TRUE(output_stream.Flush());
|
|
|
|
|
|
|
|
|
|
constexpr size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
|
|
|
|
|
constexpr size_t kStreamOffset =
|
|
|
|
|
kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
|
|
|
|
|
constexpr size_t kFileSize = kStreamOffset + kStreamSize;
|
|
|
|
|
|
|
|
|
|
ASSERT_EQ(string_file.string().size(), kFileSize);
|
|
|
|
|
|
|
|
|
|
const MINIDUMP_DIRECTORY* directory;
|
|
|
|
|
const MINIDUMP_HEADER* header =
|
|
|
|
|
MinidumpHeaderAtStart(string_file.string(), &directory);
|
|
|
|
|
ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, kTimestamp));
|
|
|
|
|
ASSERT_TRUE(directory);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(directory[0].StreamType, kStreamType);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.DataSize, kStreamSize);
|
|
|
|
|
EXPECT_EQ(directory[0].Location.Rva, kStreamOffset);
|
|
|
|
|
|
|
|
|
|
const uint8_t* stream_data = MinidumpWritableAtLocationDescriptor<uint8_t>(
|
|
|
|
|
string_file.string(), directory[0].Location);
|
|
|
|
|
ASSERT_TRUE(stream_data);
|
|
|
|
|
|
|
|
|
|
std::string expected_stream(kStreamSize, kStreamValue);
|
|
|
|
|
EXPECT_EQ(memcmp(stream_data, expected_stream.c_str(), kStreamSize), 0);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-03 18:47:34 -04:00
|
|
|
|
} // namespace
|
2014-10-07 17:28:50 -04:00
|
|
|
|
} // namespace test
|
|
|
|
|
} // namespace crashpad
|