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

Unified Diff: minidump/test/minidump_file_writer_test_util.cc

Issue 664283002: Refactor minidump test utilities for MinidumpWritable, … (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « minidump/test/minidump_file_writer_test_util.h ('k') | minidump/test/minidump_string_writer_test_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: minidump/test/minidump_file_writer_test_util.cc
diff --git a/minidump/test/minidump_file_writer_test_util.cc b/minidump/test/minidump_file_writer_test_util.cc
index 6757692f241f358a60dae8c6427dde356c15643a..e87c0997cdb0bf28c70771ce761c392d69da00d0 100644
--- a/minidump/test/minidump_file_writer_test_util.cc
+++ b/minidump/test/minidump_file_writer_test_util.cc
@@ -15,13 +15,48 @@
#include "minidump/test/minidump_file_writer_test_util.h"
#include "gtest/gtest.h"
+#include "minidump/test/minidump_writable_test_util.h"
namespace crashpad {
namespace test {
+const MINIDUMP_HEADER* MinidumpHeaderAtStart(
+ const std::string& file_contents,
+ const MINIDUMP_DIRECTORY** directory) {
+ MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
+ location_descriptor.DataSize = sizeof(MINIDUMP_HEADER);
+ location_descriptor.Rva = 0;
+
+ const MINIDUMP_HEADER* header =
+ MinidumpWritableAtLocationDescriptor<MINIDUMP_HEADER>(
+ file_contents, location_descriptor);
+
+ if (header) {
+ if (header->Signature != MINIDUMP_SIGNATURE) {
+ EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_SIGNATURE), header->Signature);
+ return nullptr;
+ }
+ if (header->Version != MINIDUMP_VERSION) {
+ EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_VERSION), header->Version);
+ return nullptr;
+ }
+
+ location_descriptor.DataSize =
+ header->NumberOfStreams * sizeof(MINIDUMP_DIRECTORY);
+ location_descriptor.Rva = header->StreamDirectoryRva;
+ *directory = MinidumpWritableAtLocationDescriptor<MINIDUMP_DIRECTORY>(
+ file_contents, location_descriptor);
+ } else {
+ *directory = nullptr;
+ }
+
+ return header;
+}
+
void VerifyMinidumpHeader(const MINIDUMP_HEADER* header,
uint32_t streams,
uint32_t timestamp) {
+ ASSERT_TRUE(header);
EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_SIGNATURE), header->Signature);
EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_VERSION), header->Version);
ASSERT_EQ(streams, header->NumberOfStreams);
« no previous file with comments | « minidump/test/minidump_file_writer_test_util.h ('k') | minidump/test/minidump_string_writer_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698