Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1192)

Unified Diff: third_party/crashpad/crashpad/minidump/minidump_file_writer_test.cc

Issue 2814043003: Update Crashpad to 1f28a123a4c9449e3d7ddad4ff00dacd366d5216 (Closed)
Patch Set: Add missing GN config to fix compile/link. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/crashpad/crashpad/minidump/minidump_file_writer_test.cc
diff --git a/third_party/crashpad/crashpad/minidump/minidump_file_writer_test.cc b/third_party/crashpad/crashpad/minidump/minidump_file_writer_test.cc
index 4429c119dbfbcc14ce54eb4db030a8f5eb02a9dc..63f2ade8adb089410234773daf9516c4967019c9 100644
--- a/third_party/crashpad/crashpad/minidump/minidump_file_writer_test.cc
+++ b/third_party/crashpad/crashpad/minidump/minidump_file_writer_test.cc
@@ -28,6 +28,7 @@
#include "minidump/minidump_user_extension_stream_data_source.h"
#include "minidump/minidump_writable.h"
#include "minidump/test/minidump_file_writer_test_util.h"
+#include "minidump/test/minidump_user_extension_stream_util.h"
#include "minidump/test/minidump_writable_test_util.h"
#include "snapshot/test/test_cpu_context.h"
#include "snapshot/test/test_exception_snapshot.h"
@@ -137,14 +138,14 @@ TEST(MinidumpFileWriter, AddUserExtensionStream) {
const size_t kStreamSize = arraysize(kStreamData);
const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
- auto stream = base::WrapUnique(new MinidumpUserExtensionStreamDataSource(
+ auto data_source = base::WrapUnique(new test::BufferExtensionStreamDataSource(
kStreamType, kStreamData, kStreamSize));
- ASSERT_TRUE(minidump_file.AddUserExtensionStream(std::move(stream)));
+ ASSERT_TRUE(minidump_file.AddUserExtensionStream(std::move(data_source)));
// Adding the same stream type a second time should fail.
- stream = base::WrapUnique(new MinidumpUserExtensionStreamDataSource(
+ data_source = base::WrapUnique(new test::BufferExtensionStreamDataSource(
kStreamType, kStreamData, kStreamSize));
- ASSERT_FALSE(minidump_file.AddUserExtensionStream(std::move(stream)));
+ ASSERT_FALSE(minidump_file.AddUserExtensionStream(std::move(data_source)));
StringFile string_file;
ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
@@ -172,6 +173,37 @@ TEST(MinidumpFileWriter, AddUserExtensionStream) {
EXPECT_EQ(memcmp(stream_data, kStreamData, kStreamSize), 0);
}
+TEST(MinidumpFileWriter, AddEmptyUserExtensionStream) {
+ MinidumpFileWriter minidump_file;
+ const time_t kTimestamp = 0x155d2fb8;
+ minidump_file.SetTimestamp(kTimestamp);
+
+ const MinidumpStreamType kStreamType = static_cast<MinidumpStreamType>(0x4d);
+
+ auto data_source = base::WrapUnique(
+ new test::BufferExtensionStreamDataSource(kStreamType, nullptr, 0));
+ ASSERT_TRUE(minidump_file.AddUserExtensionStream(std::move(data_source)));
+
+ StringFile string_file;
+ ASSERT_TRUE(minidump_file.WriteEverything(&string_file));
+
+ const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
+ const size_t kStreamOffset = kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY);
+ const size_t kFileSize = kStreamOffset;
+
+ 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);
+}
+
TEST(MinidumpFileWriter, ThreeStreams) {
MinidumpFileWriter minidump_file;
const time_t kTimestamp = 0x155d2fb8;

Powered by Google App Engine
This is Rietveld 408576698