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

Side by Side Diff: minidump/minidump_crashpad_info_writer_test.cc

Issue 1000263003: Add MinidumpCrashpadInfo::report_id (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: 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_crashpad_info_writer.cc ('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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 73 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
74 74
75 const MinidumpCrashpadInfo* crashpad_info = nullptr; 75 const MinidumpCrashpadInfo* crashpad_info = nullptr;
76 const MinidumpSimpleStringDictionary* simple_annotations = nullptr; 76 const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
77 const MinidumpModuleCrashpadInfoList* module_list = nullptr; 77 const MinidumpModuleCrashpadInfoList* module_list = nullptr;
78 78
79 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( 79 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
80 string_file.string(), &crashpad_info, &simple_annotations, &module_list)); 80 string_file.string(), &crashpad_info, &simple_annotations, &module_list));
81 81
82 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); 82 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version);
83 EXPECT_EQ(UUID(), crashpad_info->report_id);
83 EXPECT_EQ(UUID(), crashpad_info->client_id); 84 EXPECT_EQ(UUID(), crashpad_info->client_id);
84 EXPECT_FALSE(simple_annotations); 85 EXPECT_FALSE(simple_annotations);
85 EXPECT_FALSE(module_list); 86 EXPECT_FALSE(module_list);
86 } 87 }
87 88
88 TEST(MinidumpCrashpadInfoWriter, ClientID) { 89 TEST(MinidumpCrashpadInfoWriter, ReportAndClientID) {
89 MinidumpFileWriter minidump_file_writer; 90 MinidumpFileWriter minidump_file_writer;
90 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); 91 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter());
91 92
93 UUID report_id;
94 ASSERT_TRUE(
95 report_id.InitializeFromString("01234567-89ab-cdef-0123-456789abcdef"));
96 crashpad_info_writer->SetReportID(report_id);
97
92 UUID client_id; 98 UUID client_id;
93 ASSERT_TRUE( 99 ASSERT_TRUE(
94 client_id.InitializeFromString("00112233-4455-6677-8899-aabbccddeeff")); 100 client_id.InitializeFromString("00112233-4455-6677-8899-aabbccddeeff"));
95 crashpad_info_writer->SetClientID(client_id); 101 crashpad_info_writer->SetClientID(client_id);
96 102
97 EXPECT_TRUE(crashpad_info_writer->IsUseful()); 103 EXPECT_TRUE(crashpad_info_writer->IsUseful());
98 104
99 minidump_file_writer.AddStream(crashpad_info_writer.Pass()); 105 minidump_file_writer.AddStream(crashpad_info_writer.Pass());
100 106
101 StringFile string_file; 107 StringFile string_file;
102 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 108 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
103 109
104 const MinidumpCrashpadInfo* crashpad_info = nullptr; 110 const MinidumpCrashpadInfo* crashpad_info = nullptr;
105 const MinidumpSimpleStringDictionary* simple_annotations = nullptr; 111 const MinidumpSimpleStringDictionary* simple_annotations = nullptr;
106 const MinidumpModuleCrashpadInfoList* module_list = nullptr; 112 const MinidumpModuleCrashpadInfoList* module_list = nullptr;
107 113
108 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( 114 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
109 string_file.string(), &crashpad_info, &simple_annotations, &module_list)); 115 string_file.string(), &crashpad_info, &simple_annotations, &module_list));
110 116
111 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version); 117 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, crashpad_info->version);
118 EXPECT_EQ(report_id, crashpad_info->report_id);
112 EXPECT_EQ(client_id, crashpad_info->client_id); 119 EXPECT_EQ(client_id, crashpad_info->client_id);
113 EXPECT_FALSE(simple_annotations); 120 EXPECT_FALSE(simple_annotations);
114 EXPECT_FALSE(module_list); 121 EXPECT_FALSE(module_list);
115 } 122 }
116 123
117 TEST(MinidumpCrashpadInfoWriter, SimpleAnnotations) { 124 TEST(MinidumpCrashpadInfoWriter, SimpleAnnotations) {
118 MinidumpFileWriter minidump_file_writer; 125 MinidumpFileWriter minidump_file_writer;
119 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); 126 auto crashpad_info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter());
120 127
121 const char kKey[] = 128 const char kKey[] =
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ASSERT_TRUE(module); 208 ASSERT_TRUE(module);
202 209
203 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version); 210 EXPECT_EQ(MinidumpModuleCrashpadInfo::kVersion, module->version);
204 EXPECT_EQ(0u, module->list_annotations.DataSize); 211 EXPECT_EQ(0u, module->list_annotations.DataSize);
205 EXPECT_EQ(0u, module->list_annotations.Rva); 212 EXPECT_EQ(0u, module->list_annotations.Rva);
206 EXPECT_EQ(0u, module->simple_annotations.DataSize); 213 EXPECT_EQ(0u, module->simple_annotations.DataSize);
207 EXPECT_EQ(0u, module->simple_annotations.Rva); 214 EXPECT_EQ(0u, module->simple_annotations.Rva);
208 } 215 }
209 216
210 TEST(MinidumpCrashpadInfoWriter, InitializeFromSnapshot) { 217 TEST(MinidumpCrashpadInfoWriter, InitializeFromSnapshot) {
218 UUID report_id;
219 ASSERT_TRUE(
220 report_id.InitializeFromString("fedcba98-7654-3210-fedc-ba9876543210"));
221
211 UUID client_id; 222 UUID client_id;
212 ASSERT_TRUE( 223 ASSERT_TRUE(
213 client_id.InitializeFromString("fedcba98-7654-3210-0123-456789abcdef")); 224 client_id.InitializeFromString("fedcba98-7654-3210-0123-456789abcdef"));
214 225
215 const char kKey[] = "version"; 226 const char kKey[] = "version";
216 const char kValue[] = "40.0.2214.111"; 227 const char kValue[] = "40.0.2214.111";
217 const char kEntry[] = "This is a simple annotation in a list."; 228 const char kEntry[] = "This is a simple annotation in a list.";
218 229
219 // Test with a useless module, one that doesn’t carry anything that would 230 // Test with a useless module, one that doesn’t carry anything that would
220 // require MinidumpCrashpadInfo or any child object. 231 // require MinidumpCrashpadInfo or any child object.
221 auto process_snapshot = make_scoped_ptr(new TestProcessSnapshot()); 232 auto process_snapshot = make_scoped_ptr(new TestProcessSnapshot());
222 233
223 auto module_snapshot = make_scoped_ptr(new TestModuleSnapshot()); 234 auto module_snapshot = make_scoped_ptr(new TestModuleSnapshot());
224 process_snapshot->AddModule(module_snapshot.Pass()); 235 process_snapshot->AddModule(module_snapshot.Pass());
225 236
226 auto info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter()); 237 auto info_writer = make_scoped_ptr(new MinidumpCrashpadInfoWriter());
227 info_writer->InitializeFromSnapshot(process_snapshot.get()); 238 info_writer->InitializeFromSnapshot(process_snapshot.get());
228 EXPECT_FALSE(info_writer->IsUseful()); 239 EXPECT_FALSE(info_writer->IsUseful());
229 240
230 // Try again with a useful module. 241 // Try again with a useful module.
231 process_snapshot.reset(new TestProcessSnapshot()); 242 process_snapshot.reset(new TestProcessSnapshot());
232 243
244 process_snapshot->SetReportID(report_id);
233 process_snapshot->SetClientID(client_id); 245 process_snapshot->SetClientID(client_id);
234 246
235 std::map<std::string, std::string> annotations_simple_map; 247 std::map<std::string, std::string> annotations_simple_map;
236 annotations_simple_map[kKey] = kValue; 248 annotations_simple_map[kKey] = kValue;
237 process_snapshot->SetAnnotationsSimpleMap(annotations_simple_map); 249 process_snapshot->SetAnnotationsSimpleMap(annotations_simple_map);
238 250
239 module_snapshot.reset(new TestModuleSnapshot()); 251 module_snapshot.reset(new TestModuleSnapshot());
240 std::vector<std::string> annotations_list(1, std::string(kEntry)); 252 std::vector<std::string> annotations_list(1, std::string(kEntry));
241 module_snapshot->SetAnnotationsVector(annotations_list); 253 module_snapshot->SetAnnotationsVector(annotations_list);
242 process_snapshot->AddModule(module_snapshot.Pass()); 254 process_snapshot->AddModule(module_snapshot.Pass());
243 255
244 info_writer.reset(new MinidumpCrashpadInfoWriter()); 256 info_writer.reset(new MinidumpCrashpadInfoWriter());
245 info_writer->InitializeFromSnapshot(process_snapshot.get()); 257 info_writer->InitializeFromSnapshot(process_snapshot.get());
246 EXPECT_TRUE(info_writer->IsUseful()); 258 EXPECT_TRUE(info_writer->IsUseful());
247 259
248 MinidumpFileWriter minidump_file_writer; 260 MinidumpFileWriter minidump_file_writer;
249 minidump_file_writer.AddStream(info_writer.Pass()); 261 minidump_file_writer.AddStream(info_writer.Pass());
250 262
251 StringFile string_file; 263 StringFile string_file;
252 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 264 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
253 265
254 const MinidumpCrashpadInfo* info = nullptr; 266 const MinidumpCrashpadInfo* info = nullptr;
255 const MinidumpSimpleStringDictionary* simple_annotations; 267 const MinidumpSimpleStringDictionary* simple_annotations;
256 const MinidumpModuleCrashpadInfoList* module_list; 268 const MinidumpModuleCrashpadInfoList* module_list;
257 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( 269 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream(
258 string_file.string(), &info, &simple_annotations, &module_list)); 270 string_file.string(), &info, &simple_annotations, &module_list));
259 271
260 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, info->version); 272 EXPECT_EQ(MinidumpCrashpadInfo::kVersion, info->version);
261 273
274 EXPECT_EQ(report_id, info->report_id);
262 EXPECT_EQ(client_id, info->client_id); 275 EXPECT_EQ(client_id, info->client_id);
263 276
264 ASSERT_TRUE(simple_annotations); 277 ASSERT_TRUE(simple_annotations);
265 ASSERT_EQ(1u, simple_annotations->count); 278 ASSERT_EQ(1u, simple_annotations->count);
266 EXPECT_EQ(kKey, 279 EXPECT_EQ(kKey,
267 MinidumpUTF8StringAtRVAAsString( 280 MinidumpUTF8StringAtRVAAsString(
268 string_file.string(), simple_annotations->entries[0].key)); 281 string_file.string(), simple_annotations->entries[0].key));
269 EXPECT_EQ(kValue, 282 EXPECT_EQ(kValue,
270 MinidumpUTF8StringAtRVAAsString( 283 MinidumpUTF8StringAtRVAAsString(
271 string_file.string(), simple_annotations->entries[0].value)); 284 string_file.string(), simple_annotations->entries[0].value));
(...skipping 21 matching lines...) Expand all
293 306
294 const MinidumpSimpleStringDictionary* module_simple_annotations = 307 const MinidumpSimpleStringDictionary* module_simple_annotations =
295 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>( 308 MinidumpWritableAtLocationDescriptor<MinidumpSimpleStringDictionary>(
296 string_file.string(), module->simple_annotations); 309 string_file.string(), module->simple_annotations);
297 EXPECT_FALSE(module_simple_annotations); 310 EXPECT_FALSE(module_simple_annotations);
298 } 311 }
299 312
300 } // namespace 313 } // namespace
301 } // namespace test 314 } // namespace test
302 } // namespace crashpad 315 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_crashpad_info_writer.cc ('k') | minidump/minidump_extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698