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

Side by Side Diff: third_party/crashpad/crashpad/minidump/minidump_exception_writer_test.cc

Issue 2773813002: Update Crashpad to 8e37886d418dd042c3c7bfadac99214739ee4d98 (Closed)
Patch Set: Update Crashpad to 8e37886d418dd042c3c7bfadac99214739ee4d98 Created 3 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
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 TEST(MinidumpExceptionWriter, Minimal) { 95 TEST(MinidumpExceptionWriter, Minimal) {
96 MinidumpFileWriter minidump_file_writer; 96 MinidumpFileWriter minidump_file_writer;
97 auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter()); 97 auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter());
98 98
99 const uint32_t kSeed = 100; 99 const uint32_t kSeed = 100;
100 100
101 auto context_x86_writer = base::WrapUnique(new MinidumpContextX86Writer()); 101 auto context_x86_writer = base::WrapUnique(new MinidumpContextX86Writer());
102 InitializeMinidumpContextX86(context_x86_writer->context(), kSeed); 102 InitializeMinidumpContextX86(context_x86_writer->context(), kSeed);
103 exception_writer->SetContext(std::move(context_x86_writer)); 103 exception_writer->SetContext(std::move(context_x86_writer));
104 104
105 minidump_file_writer.AddStream(std::move(exception_writer)); 105 ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
106 106
107 StringFile string_file; 107 StringFile string_file;
108 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 108 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
109 109
110 const MINIDUMP_EXCEPTION_STREAM* observed_exception_stream = nullptr; 110 const MINIDUMP_EXCEPTION_STREAM* observed_exception_stream = nullptr;
111 ASSERT_NO_FATAL_FAILURE( 111 ASSERT_NO_FATAL_FAILURE(
112 GetExceptionStream(string_file.string(), &observed_exception_stream)); 112 GetExceptionStream(string_file.string(), &observed_exception_stream));
113 113
114 MINIDUMP_EXCEPTION_STREAM expected_exception_stream = {}; 114 MINIDUMP_EXCEPTION_STREAM expected_exception_stream = {};
115 expected_exception_stream.ThreadContext.DataSize = sizeof(MinidumpContextX86); 115 expected_exception_stream.ThreadContext.DataSize = sizeof(MinidumpContextX86);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 std::vector<uint64_t> exception_information(EXCEPTION_MAXIMUM_PARAMETERS, 154 std::vector<uint64_t> exception_information(EXCEPTION_MAXIMUM_PARAMETERS,
155 0x5a5a5a5a5a5a5a5a); 155 0x5a5a5a5a5a5a5a5a);
156 exception_writer->SetExceptionInformation(exception_information); 156 exception_writer->SetExceptionInformation(exception_information);
157 157
158 exception_information.clear(); 158 exception_information.clear();
159 exception_information.push_back(kExceptionInformation0); 159 exception_information.push_back(kExceptionInformation0);
160 exception_information.push_back(kExceptionInformation1); 160 exception_information.push_back(kExceptionInformation1);
161 exception_information.push_back(kExceptionInformation2); 161 exception_information.push_back(kExceptionInformation2);
162 exception_writer->SetExceptionInformation(exception_information); 162 exception_writer->SetExceptionInformation(exception_information);
163 163
164 minidump_file_writer.AddStream(std::move(exception_writer)); 164 ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
165 165
166 StringFile string_file; 166 StringFile string_file;
167 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 167 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
168 168
169 const MINIDUMP_EXCEPTION_STREAM* observed_exception_stream = nullptr; 169 const MINIDUMP_EXCEPTION_STREAM* observed_exception_stream = nullptr;
170 ASSERT_NO_FATAL_FAILURE( 170 ASSERT_NO_FATAL_FAILURE(
171 GetExceptionStream(string_file.string(), &observed_exception_stream)); 171 GetExceptionStream(string_file.string(), &observed_exception_stream));
172 172
173 MINIDUMP_EXCEPTION_STREAM expected_exception_stream = {}; 173 MINIDUMP_EXCEPTION_STREAM expected_exception_stream = {};
174 expected_exception_stream.ThreadId = kThreadID; 174 expected_exception_stream.ThreadId = kThreadID;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 InitializeCPUContextX86(exception_snapshot.MutableContext(), kSeed); 228 InitializeCPUContextX86(exception_snapshot.MutableContext(), kSeed);
229 229
230 MinidumpThreadIDMap thread_id_map; 230 MinidumpThreadIDMap thread_id_map;
231 thread_id_map[kThreadID] = expect_exception.ThreadId; 231 thread_id_map[kThreadID] = expect_exception.ThreadId;
232 232
233 auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter()); 233 auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter());
234 exception_writer->InitializeFromSnapshot(&exception_snapshot, thread_id_map); 234 exception_writer->InitializeFromSnapshot(&exception_snapshot, thread_id_map);
235 235
236 MinidumpFileWriter minidump_file_writer; 236 MinidumpFileWriter minidump_file_writer;
237 minidump_file_writer.AddStream(std::move(exception_writer)); 237 ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
238 238
239 StringFile string_file; 239 StringFile string_file;
240 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 240 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
241 241
242 const MINIDUMP_EXCEPTION_STREAM* exception = nullptr; 242 const MINIDUMP_EXCEPTION_STREAM* exception = nullptr;
243 ASSERT_NO_FATAL_FAILURE(GetExceptionStream(string_file.string(), &exception)); 243 ASSERT_NO_FATAL_FAILURE(GetExceptionStream(string_file.string(), &exception));
244 244
245 const MinidumpContextX86* observed_context = nullptr; 245 const MinidumpContextX86* observed_context = nullptr;
246 ASSERT_NO_FATAL_FAILURE(ExpectExceptionStream(&expect_exception, 246 ASSERT_NO_FATAL_FAILURE(ExpectExceptionStream(&expect_exception,
247 exception, 247 exception,
248 string_file.string(), 248 string_file.string(),
249 &observed_context)); 249 &observed_context));
250 250
251 ASSERT_NO_FATAL_FAILURE( 251 ASSERT_NO_FATAL_FAILURE(
252 ExpectMinidumpContextX86(kSeed, observed_context, true)); 252 ExpectMinidumpContextX86(kSeed, observed_context, true));
253 } 253 }
254 254
255 TEST(MinidumpExceptionWriterDeathTest, NoContext) { 255 TEST(MinidumpExceptionWriterDeathTest, NoContext) {
256 MinidumpFileWriter minidump_file_writer; 256 MinidumpFileWriter minidump_file_writer;
257 auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter()); 257 auto exception_writer = base::WrapUnique(new MinidumpExceptionWriter());
258 258
259 minidump_file_writer.AddStream(std::move(exception_writer)); 259 ASSERT_TRUE(minidump_file_writer.AddStream(std::move(exception_writer)));
260 260
261 StringFile string_file; 261 StringFile string_file;
262 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file), 262 ASSERT_DEATH_CHECK(minidump_file_writer.WriteEverything(&string_file),
263 "context_"); 263 "context_");
264 } 264 }
265 265
266 TEST(MinidumpExceptionWriterDeathTest, TooMuchInformation) { 266 TEST(MinidumpExceptionWriterDeathTest, TooMuchInformation) {
267 MinidumpExceptionWriter exception_writer; 267 MinidumpExceptionWriter exception_writer;
268 std::vector<uint64_t> exception_information(EXCEPTION_MAXIMUM_PARAMETERS + 1, 268 std::vector<uint64_t> exception_information(EXCEPTION_MAXIMUM_PARAMETERS + 1,
269 0x5a5a5a5a5a5a5a5a); 269 0x5a5a5a5a5a5a5a5a);
270 ASSERT_DEATH_CHECK( 270 ASSERT_DEATH_CHECK(
271 exception_writer.SetExceptionInformation(exception_information), 271 exception_writer.SetExceptionInformation(exception_information),
272 "kMaxParameters"); 272 "kMaxParameters");
273 } 273 }
274 274
275 } // namespace 275 } // namespace
276 } // namespace test 276 } // namespace test
277 } // namespace crashpad 277 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698