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

Side by Side Diff: minidump/minidump_thread_writer_test.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 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 26 matching lines...) Expand all
37 const MINIDUMP_MEMORY_LIST** memory_list) { 37 const MINIDUMP_MEMORY_LIST** memory_list) {
38 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER); 38 const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
39 const uint32_t kExpectedStreams = memory_list ? 2 : 1; 39 const uint32_t kExpectedStreams = memory_list ? 2 : 1;
40 const size_t kThreadListStreamOffset = 40 const size_t kThreadListStreamOffset =
41 kDirectoryOffset + kExpectedStreams * sizeof(MINIDUMP_DIRECTORY); 41 kDirectoryOffset + kExpectedStreams * sizeof(MINIDUMP_DIRECTORY);
42 const size_t kThreadsOffset = 42 const size_t kThreadsOffset =
43 kThreadListStreamOffset + sizeof(MINIDUMP_THREAD_LIST); 43 kThreadListStreamOffset + sizeof(MINIDUMP_THREAD_LIST);
44 44
45 ASSERT_GE(file_contents.size(), kThreadsOffset); 45 ASSERT_GE(file_contents.size(), kThreadsOffset);
46 46
47 const MINIDUMP_DIRECTORY* directory;
47 const MINIDUMP_HEADER* header = 48 const MINIDUMP_HEADER* header =
48 reinterpret_cast<const MINIDUMP_HEADER*>(&file_contents[0]); 49 MinidumpHeaderAtStart(file_contents, &directory);
49
50 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, kExpectedStreams, 0)); 50 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, kExpectedStreams, 0));
51 51 ASSERT_TRUE(directory);
52 const MINIDUMP_DIRECTORY* directory =
53 reinterpret_cast<const MINIDUMP_DIRECTORY*>(
54 &file_contents[kDirectoryOffset]);
55 52
56 ASSERT_EQ(kMinidumpStreamTypeThreadList, directory[0].StreamType); 53 ASSERT_EQ(kMinidumpStreamTypeThreadList, directory[0].StreamType);
57 ASSERT_GE(directory[0].Location.DataSize, sizeof(MINIDUMP_THREAD_LIST)); 54 ASSERT_GE(directory[0].Location.DataSize, sizeof(MINIDUMP_THREAD_LIST));
58 ASSERT_EQ(kThreadListStreamOffset, directory[0].Location.Rva); 55 ASSERT_EQ(kThreadListStreamOffset, directory[0].Location.Rva);
59 56
60 *thread_list = reinterpret_cast<const MINIDUMP_THREAD_LIST*>( 57 *thread_list = reinterpret_cast<const MINIDUMP_THREAD_LIST*>(
61 &file_contents[kThreadListStreamOffset]); 58 &file_contents[kThreadListStreamOffset]);
62 59
63 ASSERT_EQ(sizeof(MINIDUMP_THREAD_LIST) + 60 ASSERT_EQ(sizeof(MINIDUMP_THREAD_LIST) +
64 (*thread_list)->NumberOfThreads * sizeof(MINIDUMP_THREAD), 61 (*thread_list)->NumberOfThreads * sizeof(MINIDUMP_THREAD),
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 thread_list_writer.AddThread(&thread_writer); 478 thread_list_writer.AddThread(&thread_writer);
482 minidump_file_writer.AddStream(&thread_list_writer); 479 minidump_file_writer.AddStream(&thread_list_writer);
483 480
484 StringFileWriter file_writer; 481 StringFileWriter file_writer;
485 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "context_"); 482 ASSERT_DEATH(minidump_file_writer.WriteEverything(&file_writer), "context_");
486 } 483 }
487 484
488 } // namespace 485 } // namespace
489 } // namespace test 486 } // namespace test
490 } // namespace crashpad 487 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_system_info_writer_test.cc ('k') | minidump/test/minidump_file_writer_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698