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

Side by Side Diff: minidump/test/minidump_file_writer_test_util.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,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/test/minidump_file_writer_test_util.h" 15 #include "minidump/test/minidump_file_writer_test_util.h"
16 16
17 #include "gtest/gtest.h" 17 #include "gtest/gtest.h"
18 #include "minidump/test/minidump_writable_test_util.h"
18 19
19 namespace crashpad { 20 namespace crashpad {
20 namespace test { 21 namespace test {
21 22
23 const MINIDUMP_HEADER* MinidumpHeaderAtStart(
24 const std::string& file_contents,
25 const MINIDUMP_DIRECTORY** directory) {
26 MINIDUMP_LOCATION_DESCRIPTOR location_descriptor;
27 location_descriptor.DataSize = sizeof(MINIDUMP_HEADER);
28 location_descriptor.Rva = 0;
29
30 const MINIDUMP_HEADER* header =
31 MinidumpWritableAtLocationDescriptor<MINIDUMP_HEADER>(
32 file_contents, location_descriptor);
33
34 if (header) {
35 if (header->Signature != MINIDUMP_SIGNATURE) {
36 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_SIGNATURE), header->Signature);
37 return nullptr;
38 }
39 if (header->Version != MINIDUMP_VERSION) {
40 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_VERSION), header->Version);
41 return nullptr;
42 }
43
44 location_descriptor.DataSize =
45 header->NumberOfStreams * sizeof(MINIDUMP_DIRECTORY);
46 location_descriptor.Rva = header->StreamDirectoryRva;
47 *directory = MinidumpWritableAtLocationDescriptor<MINIDUMP_DIRECTORY>(
48 file_contents, location_descriptor);
49 } else {
50 *directory = nullptr;
51 }
52
53 return header;
54 }
55
22 void VerifyMinidumpHeader(const MINIDUMP_HEADER* header, 56 void VerifyMinidumpHeader(const MINIDUMP_HEADER* header,
23 uint32_t streams, 57 uint32_t streams,
24 uint32_t timestamp) { 58 uint32_t timestamp) {
59 ASSERT_TRUE(header);
25 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_SIGNATURE), header->Signature); 60 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_SIGNATURE), header->Signature);
26 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_VERSION), header->Version); 61 EXPECT_EQ(static_cast<uint32_t>(MINIDUMP_VERSION), header->Version);
27 ASSERT_EQ(streams, header->NumberOfStreams); 62 ASSERT_EQ(streams, header->NumberOfStreams);
28 ASSERT_EQ(streams ? sizeof(MINIDUMP_HEADER) : 0u, header->StreamDirectoryRva); 63 ASSERT_EQ(streams ? sizeof(MINIDUMP_HEADER) : 0u, header->StreamDirectoryRva);
29 EXPECT_EQ(0u, header->CheckSum); 64 EXPECT_EQ(0u, header->CheckSum);
30 EXPECT_EQ(timestamp, header->TimeDateStamp); 65 EXPECT_EQ(timestamp, header->TimeDateStamp);
31 EXPECT_EQ(MiniDumpNormal, header->Flags); 66 EXPECT_EQ(MiniDumpNormal, header->Flags);
32 } 67 }
33 68
34 } // namespace test 69 } // namespace test
35 } // namespace crashpad 70 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/test/minidump_file_writer_test_util.h ('k') | minidump/test/minidump_string_writer_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698