Index: minidump/minidump_crashpad_info_writer_test.cc |
diff --git a/minidump/minidump_crashpad_info_writer_test.cc b/minidump/minidump_crashpad_info_writer_test.cc |
index b59301be728eac967ee57fc5ef4db6eaaaafc61f..e61f3bb2c8721826dd32cf3faff8ebca50e1c5a5 100644 |
--- a/minidump/minidump_crashpad_info_writer_test.cc |
+++ b/minidump/minidump_crashpad_info_writer_test.cc |
@@ -17,11 +17,10 @@ |
#include <dbghelp.h> |
#include "gtest/gtest.h" |
+#include "minidump/minidump_crashpad_module_writer.h" |
#include "minidump/minidump_extensions.h" |
#include "minidump/minidump_file_writer.h" |
-#include "minidump/minidump_simple_string_dictionary_writer.h" |
#include "minidump/test/minidump_file_writer_test_util.h" |
-#include "minidump/test/minidump_string_writer_test_util.h" |
#include "minidump/test/minidump_writable_test_util.h" |
#include "util/file/string_file_writer.h" |
@@ -29,26 +28,9 @@ namespace crashpad { |
namespace test { |
namespace { |
-void GetCrashpadInfoStream( |
- const std::string& file_contents, |
- const MinidumpCrashpadInfo** crashpad_info, |
- const MinidumpSimpleStringDictionary** simple_annotations) { |
- const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); |
- const size_t kCrashpadInfoStreamOffset = |
- kDirectoryOffset + sizeof(MINIDUMP_DIRECTORY); |
- size_t end = kCrashpadInfoStreamOffset + sizeof(MinidumpCrashpadInfo); |
- const size_t kSimpleAnnotationsOffset = simple_annotations ? end : 0; |
- if (simple_annotations) { |
- end += sizeof(MinidumpSimpleStringDictionary); |
- } |
- const size_t kFileSize = end; |
- |
- if (!simple_annotations) { |
- ASSERT_EQ(kFileSize, file_contents.size()); |
- } else { |
- EXPECT_GE(file_contents.size(), kFileSize); |
- } |
- |
+void GetCrashpadInfoStream(const std::string& file_contents, |
+ const MinidumpCrashpadInfo** crashpad_info, |
+ const MinidumpModuleCrashpadInfoList** module_list) { |
const MINIDUMP_DIRECTORY* directory; |
const MINIDUMP_HEADER* header = |
MinidumpHeaderAtStart(file_contents, &directory); |
@@ -56,23 +38,14 @@ void GetCrashpadInfoStream( |
ASSERT_TRUE(directory); |
ASSERT_EQ(kMinidumpStreamTypeCrashpadInfo, directory[0].StreamType); |
- EXPECT_EQ(kCrashpadInfoStreamOffset, directory[0].Location.Rva); |
*crashpad_info = MinidumpWritableAtLocationDescriptor<MinidumpCrashpadInfo>( |
file_contents, directory[0].Location); |
ASSERT_TRUE(*crashpad_info); |
- if (simple_annotations) { |
- EXPECT_EQ(kSimpleAnnotationsOffset, |
- (*crashpad_info)->simple_annotations.Rva); |
- *simple_annotations = |
- MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( |
- file_contents, (*crashpad_info)->simple_annotations); |
- ASSERT_TRUE(*simple_annotations); |
- } else { |
- ASSERT_EQ(0u, (*crashpad_info)->simple_annotations.DataSize); |
- ASSERT_EQ(0u, (*crashpad_info)->simple_annotations.Rva); |
- } |
+ *module_list = |
+ MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfoList>( |
+ file_contents, (*crashpad_info)->module_list); |
} |
TEST(MinidumpCrashpadInfoWriter, Empty) { |
@@ -85,66 +58,51 @@ TEST(MinidumpCrashpadInfoWriter, Empty) { |
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
const MinidumpCrashpadInfo* crashpad_info; |
+ const MinidumpModuleCrashpadInfoList* module_list; |
- ASSERT_NO_FATAL_FAILURE( |
- GetCrashpadInfoStream(file_writer.string(), &crashpad_info, nullptr)); |
+ ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( |
+ file_writer.string(), &crashpad_info, &module_list)); |
- EXPECT_EQ(sizeof(*crashpad_info), crashpad_info->size); |
- EXPECT_EQ(1u, crashpad_info->version); |
- EXPECT_EQ(0u, crashpad_info->simple_annotations.DataSize); |
- EXPECT_EQ(0u, crashpad_info->simple_annotations.Rva); |
+ EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); |
+ EXPECT_FALSE(module_list); |
} |
-TEST(MinidumpCrashpadInfoWriter, SimpleAnnotations) { |
+TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) { |
+ const uint32_t kMinidumpModuleListIndex = 3; |
+ |
MinidumpFileWriter minidump_file_writer; |
MinidumpCrashpadInfoWriter crashpad_info_writer; |
minidump_file_writer.AddStream(&crashpad_info_writer); |
- MinidumpSimpleStringDictionaryWriter simple_annotations_writer; |
- |
- // Set a key and value before adding the simple_annotations_writer to |
- // crashpad_info_writer, and another one after. |
- const char kKey0[] = "k0"; |
- const char kValue0[] = "v"; |
- const char kKey1[] = "KEY1"; |
- const char kValue1[] = ""; |
- MinidumpSimpleStringDictionaryEntryWriter entry_0; |
- entry_0.SetKeyValue(kKey0, kValue0); |
- simple_annotations_writer.AddEntry(&entry_0); |
- |
- crashpad_info_writer.SetSimpleAnnotations(&simple_annotations_writer); |
- |
- MinidumpSimpleStringDictionaryEntryWriter entry_1; |
- entry_1.SetKeyValue(kKey1, kValue1); |
- simple_annotations_writer.AddEntry(&entry_1); |
+ MinidumpModuleCrashpadInfoListWriter module_list_writer; |
+ MinidumpModuleCrashpadInfoWriter module_writer; |
+ module_writer.SetMinidumpModuleListIndex(kMinidumpModuleListIndex); |
+ module_list_writer.AddModule(&module_writer); |
+ crashpad_info_writer.SetModuleList(&module_list_writer); |
StringFileWriter file_writer; |
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
const MinidumpCrashpadInfo* crashpad_info; |
- const MinidumpSimpleStringDictionary* simple_annotations; |
+ const MinidumpModuleCrashpadInfoList* module_list; |
ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( |
- file_writer.string(), &crashpad_info, &simple_annotations)); |
- |
- EXPECT_EQ(sizeof(*crashpad_info), crashpad_info->size); |
- EXPECT_EQ(1u, crashpad_info->version); |
- |
- ASSERT_EQ(2u, simple_annotations->count); |
- |
- EXPECT_EQ(kKey1, |
- MinidumpUTF8StringAtRVAAsString( |
- file_writer.string(), simple_annotations->entries[0].key)); |
- EXPECT_EQ(kValue1, |
- MinidumpUTF8StringAtRVAAsString( |
- file_writer.string(), simple_annotations->entries[0].value)); |
- EXPECT_EQ(kKey0, |
- MinidumpUTF8StringAtRVAAsString( |
- file_writer.string(), simple_annotations->entries[1].key)); |
- EXPECT_EQ(kValue0, |
- MinidumpUTF8StringAtRVAAsString( |
- file_writer.string(), simple_annotations->entries[1].value)); |
+ file_writer.string(), &crashpad_info, &module_list)); |
+ |
+ EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); |
+ ASSERT_TRUE(module_list); |
+ ASSERT_EQ(1u, module_list->count); |
+ |
+ const MinidumpModuleCrashpadInfo* module = |
+ MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( |
+ file_writer.string(), module_list->modules[0]); |
+ ASSERT_TRUE(module); |
+ |
+ EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); |
+ EXPECT_EQ(kMinidumpModuleListIndex, module->minidump_module_list_index); |
+ EXPECT_EQ(0u, module->simple_annotations.DataSize); |
+ EXPECT_EQ(0u, module->simple_annotations.Rva); |
} |
} // namespace |