OLD | NEW |
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 30 matching lines...) Expand all Loading... |
41 end += sizeof(MinidumpSimpleStringDictionary); | 41 end += sizeof(MinidumpSimpleStringDictionary); |
42 } | 42 } |
43 const size_t kFileSize = end; | 43 const size_t kFileSize = end; |
44 | 44 |
45 if (!simple_annotations) { | 45 if (!simple_annotations) { |
46 ASSERT_EQ(kFileSize, file_contents.size()); | 46 ASSERT_EQ(kFileSize, file_contents.size()); |
47 } else { | 47 } else { |
48 EXPECT_GE(file_contents.size(), kFileSize); | 48 EXPECT_GE(file_contents.size(), kFileSize); |
49 } | 49 } |
50 | 50 |
| 51 const MINIDUMP_DIRECTORY* directory; |
51 const MINIDUMP_HEADER* header = | 52 const MINIDUMP_HEADER* header = |
52 reinterpret_cast<const MINIDUMP_HEADER*>(&file_contents[0]); | 53 MinidumpHeaderAtStart(file_contents, &directory); |
| 54 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0)); |
| 55 ASSERT_TRUE(directory); |
53 | 56 |
54 ASSERT_NO_FATAL_FAILURE(VerifyMinidumpHeader(header, 1, 0)); | 57 ASSERT_EQ(kMinidumpStreamTypeCrashpadInfo, directory[0].StreamType); |
55 | 58 ASSERT_EQ(sizeof(MinidumpCrashpadInfo), directory[0].Location.DataSize); |
56 const MINIDUMP_DIRECTORY* directory = | 59 ASSERT_EQ(kCrashpadInfoStreamOffset, directory[0].Location.Rva); |
57 reinterpret_cast<const MINIDUMP_DIRECTORY*>( | |
58 &file_contents[kDirectoryOffset]); | |
59 | |
60 ASSERT_EQ(kMinidumpStreamTypeCrashpadInfo, directory->StreamType); | |
61 ASSERT_EQ(sizeof(MinidumpCrashpadInfo), directory->Location.DataSize); | |
62 ASSERT_EQ(kCrashpadInfoStreamOffset, directory->Location.Rva); | |
63 | 60 |
64 *crashpad_info = reinterpret_cast<const MinidumpCrashpadInfo*>( | 61 *crashpad_info = reinterpret_cast<const MinidumpCrashpadInfo*>( |
65 &file_contents[kCrashpadInfoStreamOffset]); | 62 &file_contents[kCrashpadInfoStreamOffset]); |
66 | 63 |
67 if (simple_annotations) { | 64 if (simple_annotations) { |
68 ASSERT_GE((*crashpad_info)->simple_annotations.DataSize, | 65 ASSERT_GE((*crashpad_info)->simple_annotations.DataSize, |
69 sizeof(MinidumpSimpleStringDictionary)); | 66 sizeof(MinidumpSimpleStringDictionary)); |
70 ASSERT_EQ(kSimpleAnnotationsOffset, | 67 ASSERT_EQ(kSimpleAnnotationsOffset, |
71 (*crashpad_info)->simple_annotations.Rva); | 68 (*crashpad_info)->simple_annotations.Rva); |
72 *simple_annotations = | 69 *simple_annotations = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 const MinidumpSimpleStringDictionary* simple_annotations; | 126 const MinidumpSimpleStringDictionary* simple_annotations; |
130 | 127 |
131 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( | 128 ASSERT_NO_FATAL_FAILURE(GetCrashpadInfoStream( |
132 file_writer.string(), &crashpad_info, &simple_annotations)); | 129 file_writer.string(), &crashpad_info, &simple_annotations)); |
133 | 130 |
134 EXPECT_EQ(sizeof(*crashpad_info), crashpad_info->size); | 131 EXPECT_EQ(sizeof(*crashpad_info), crashpad_info->size); |
135 EXPECT_EQ(1u, crashpad_info->version); | 132 EXPECT_EQ(1u, crashpad_info->version); |
136 | 133 |
137 ASSERT_EQ(2u, simple_annotations->count); | 134 ASSERT_EQ(2u, simple_annotations->count); |
138 | 135 |
139 EXPECT_EQ( | 136 EXPECT_EQ(kKey1, |
140 kKey1, | 137 MinidumpUTF8StringAtRVAAsString( |
141 MinidumpUTF8StringAtRVA(file_writer, simple_annotations->entries[0].key)); | 138 file_writer.string(), simple_annotations->entries[0].key)); |
142 EXPECT_EQ(kValue1, | 139 EXPECT_EQ(kValue1, |
143 MinidumpUTF8StringAtRVA(file_writer, | 140 MinidumpUTF8StringAtRVAAsString( |
144 simple_annotations->entries[0].value)); | 141 file_writer.string(), simple_annotations->entries[0].value)); |
145 EXPECT_EQ( | 142 EXPECT_EQ(kKey0, |
146 kKey0, | 143 MinidumpUTF8StringAtRVAAsString( |
147 MinidumpUTF8StringAtRVA(file_writer, simple_annotations->entries[1].key)); | 144 file_writer.string(), simple_annotations->entries[1].key)); |
148 EXPECT_EQ(kValue0, | 145 EXPECT_EQ(kValue0, |
149 MinidumpUTF8StringAtRVA(file_writer, | 146 MinidumpUTF8StringAtRVAAsString( |
150 simple_annotations->entries[1].value)); | 147 file_writer.string(), simple_annotations->entries[1].value)); |
151 } | 148 } |
152 | 149 |
153 } // namespace | 150 } // namespace |
154 } // namespace test | 151 } // namespace test |
155 } // namespace crashpad | 152 } // namespace crashpad |
OLD | NEW |