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

Side by Side Diff: minidump/minidump_crashpad_info_writer_test.cc

Issue 978463003: minidump: Reorganize MinidumpModuleCrashpadInfo to improve linking between structures (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Minor update Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « minidump/minidump.gyp ('k') | minidump/minidump_extensions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) { 134 TEST(MinidumpCrashpadInfoWriter, CrashpadModuleList) {
135 const uint32_t kMinidumpModuleListIndex = 3; 135 const uint32_t kMinidumpModuleListIndex = 3;
136 136
137 MinidumpFileWriter minidump_file_writer; 137 MinidumpFileWriter minidump_file_writer;
138 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); 138 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter());
139 139
140 auto module_list_writer = 140 auto module_list_writer =
141 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter()); 141 make_scoped_ptr(new MinidumpModuleCrashpadInfoListWriter());
142 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter()); 142 auto module_writer = make_scoped_ptr(new MinidumpModuleCrashpadInfoWriter());
143 module_writer->SetMinidumpModuleListIndex(kMinidumpModuleListIndex); 143 module_list_writer->AddModule(module_writer.Pass(), kMinidumpModuleListIndex);
144 module_list_writer->AddModule(module_writer.Pass());
145 crashpad_info_writer->SetModuleList(module_list_writer.Pass()); 144 crashpad_info_writer->SetModuleList(module_list_writer.Pass());
146 145
147 EXPECT_TRUE(crashpad_info_writer->IsUseful()); 146 EXPECT_TRUE(crashpad_info_writer->IsUseful());
148 147
149 minidump_file_writer.AddStream(crashpad_info_writer.Pass()); 148 minidump_file_writer.AddStream(crashpad_info_writer.Pass());
150 149
151 StringFile string_file; 150 StringFile string_file;
152 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 151 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
153 152
154 const MinidumpCrashpadInfo* crashpad_info = nullptr; 153 const MinidumpCrashpadInfo* crashpad_info = nullptr;
155 const MinidumpSimpleStringDictionary* simple_annotations = nullptr; 154 const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
156 const MinidumpModuleCrashpadInfoList* module_list = nullptr; 155 const MinidumpModuleCrashpadInfoList* module_list = nullptr;
157 156
158 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( 157 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
159 string_file.string(), &crashpad_info, &simple_annotations, &module_list)); 158 string_file.string(), &crashpad_info, &simple_annotations, &module_list));
160 159
161 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); 160 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version);
162 EXPECT_FALSE(simple_annotations); 161 EXPECT_FALSE(simple_annotations);
163 162
164 ASSERT_TRUE(module_list); 163 ASSERT_TRUE(module_list);
165 ASSERT_EQ(1u, module_list->count); 164 ASSERT_EQ(1u, module_list->count);
166 165
166 EXPECT_EQ(kMinidumpModuleListIndex,
167 module_list->modules[0].minidump_module_list_index);
167 const MinidumpModuleCrashpadInfo* module = 168 const MinidumpModuleCrashpadInfo* module =
168 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 169 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
169 string_file.string(), module_list->children[0]); 170 string_file.string(), module_list->modules[0].location);
170 ASSERT_TRUE(module); 171 ASSERT_TRUE(module);
171 172
172 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); 173 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version);
173 EXPECT_EQ(kMinidumpModuleListIndex, module->minidump_module_list_index);
174 EXPECT_EQ(0u, module->list_annotations.DataSize); 174 EXPECT_EQ(0u, module->list_annotations.DataSize);
175 EXPECT_EQ(0u, module->list_annotations.Rva); 175 EXPECT_EQ(0u, module->list_annotations.Rva);
176 EXPECT_EQ(0u, module->simple_annotations.DataSize); 176 EXPECT_EQ(0u, module->simple_annotations.DataSize);
177 EXPECT_EQ(0u, module->simple_annotations.Rva); 177 EXPECT_EQ(0u, module->simple_annotations.Rva);
178 } 178 }
179 179
180 TEST(MinidumpCrashpadInfoWriter, InitializeFromSnapshot) { 180 TEST(MinidumpCrashpadInfoWriter, InitializeFromSnapshot) {
181 const char kKey[] = "version"; 181 const char kKey[] = "version";
182 const char kValue[] = "40.0.2214.111"; 182 const char kValue[] = "40.0.2214.111";
183 const char kEntry[] = "This is a simple annotation in a list."; 183 const char kEntry[] = "This is a simple annotation in a list.";
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 EXPECT_EQ(kKey, 228 EXPECT_EQ(kKey,
229 MinidumpUTF8StringAtRVAAsString( 229 MinidumpUTF8StringAtRVAAsString(
230 string_file.string(), simple_annotations->entries[0].key)); 230 string_file.string(), simple_annotations->entries[0].key));
231 EXPECT_EQ(kValue, 231 EXPECT_EQ(kValue,
232 MinidumpUTF8StringAtRVAAsString( 232 MinidumpUTF8StringAtRVAAsString(
233 string_file.string(), simple_annotations->entries[0].value)); 233 string_file.string(), simple_annotations->entries[0].value));
234 234
235 ASSERT_TRUE(module_list); 235 ASSERT_TRUE(module_list);
236 ASSERT_EQ(1u, module_list->count); 236 ASSERT_EQ(1u, module_list->count);
237 237
238 EXPECT_EQ(0u, module_list->modules[0].minidump_module_list_index);
238 const MinidumpModuleCrashpadInfo* module = 239 const MinidumpModuleCrashpadInfo* module =
239 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>( 240 MinidumpWritableAtLocationDescriptor<MinidumpModuleCrashpadInfo>(
240 string_file.string(), module_list->children[0]); 241 string_file.string(), module_list->modules[0].location);
241 ASSERT_TRUE(module); 242 ASSERT_TRUE(module);
242 243
243 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); 244 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version);
244 EXPECT_EQ(0u, module->minidump_module_list_index);
245 245
246 const MinidumpRVAList* list_annotations = 246 const MinidumpRVAList* list_annotations =
247 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>( 247 MinidumpWritableAtLocationDescriptor<MinidumpRVAList>(
248 string_file.string(), module->list_annotations); 248 string_file.string(), module->list_annotations);
249 ASSERT_TRUE(list_annotations); 249 ASSERT_TRUE(list_annotations);
250 250
251 ASSERT_EQ(1u, list_annotations->count); 251 ASSERT_EQ(1u, list_annotations->count);
252 EXPECT_EQ(kEntry, 252 EXPECT_EQ(kEntry,
253 MinidumpUTF8StringAtRVAAsString(string_file.string(), 253 MinidumpUTF8StringAtRVAAsString(string_file.string(),
254 list_annotations->children[0])); 254 list_annotations->children[0]));
255 255
256 const MinidumpSimpleStringDictionary* module_simple_annotations = 256 const MinidumpSimpleStringDictionary* module_simple_annotations =
257 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 257 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
258 string_file.string(), module->simple_annotations); 258 string_file.string(), module->simple_annotations);
259 EXPECT_FALSE(module_simple_annotations); 259 EXPECT_FALSE(module_simple_annotations);
260 } 260 }
261 261
262 } // namespace 262 } // namespace
263 } // namespace test 263 } // namespace test
264 } // namespace crashpad 264 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump.gyp ('k') | minidump/minidump_extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698