| OLD | NEW |
| 1 // Copyright 2015 The Crashpad Authors. All rights reserved. | 1 // Copyright 2015 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 header.Signature = MINIDUMP_SIGNATURE; | 53 header.Signature = MINIDUMP_SIGNATURE; |
| 54 header.Version = MINIDUMP_VERSION; | 54 header.Version = MINIDUMP_VERSION; |
| 55 | 55 |
| 56 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); | 56 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); |
| 57 | 57 |
| 58 ProcessSnapshotMinidump process_snapshot; | 58 ProcessSnapshotMinidump process_snapshot; |
| 59 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); | 59 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); |
| 60 | 60 |
| 61 UUID client_id; | 61 UUID client_id; |
| 62 process_snapshot.ClientID(&client_id); | 62 process_snapshot.ClientID(&client_id); |
| 63 EXPECT_EQ(UUID(), client_id); | 63 EXPECT_EQ(client_id, UUID()); |
| 64 | 64 |
| 65 EXPECT_TRUE(process_snapshot.AnnotationsSimpleMap().empty()); | 65 EXPECT_TRUE(process_snapshot.AnnotationsSimpleMap().empty()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Writes |string| to |writer| as a MinidumpUTF8String, and returns the file | 68 // Writes |string| to |writer| as a MinidumpUTF8String, and returns the file |
| 69 // offst of the beginning of the string. | 69 // offst of the beginning of the string. |
| 70 RVA WriteString(FileWriterInterface* writer, const std::string& string) { | 70 RVA WriteString(FileWriterInterface* writer, const std::string& string) { |
| 71 RVA rva = static_cast<RVA>(writer->SeekGet()); | 71 RVA rva = static_cast<RVA>(writer->SeekGet()); |
| 72 | 72 |
| 73 uint32_t string_size = static_cast<uint32_t>(string.size()); | 73 uint32_t string_size = static_cast<uint32_t>(string.size()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 header.Version = MINIDUMP_VERSION; | 160 header.Version = MINIDUMP_VERSION; |
| 161 header.NumberOfStreams = 1; | 161 header.NumberOfStreams = 1; |
| 162 EXPECT_TRUE(string_file.SeekSet(0)); | 162 EXPECT_TRUE(string_file.SeekSet(0)); |
| 163 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); | 163 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); |
| 164 | 164 |
| 165 ProcessSnapshotMinidump process_snapshot; | 165 ProcessSnapshotMinidump process_snapshot; |
| 166 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); | 166 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); |
| 167 | 167 |
| 168 UUID actual_client_id; | 168 UUID actual_client_id; |
| 169 process_snapshot.ClientID(&actual_client_id); | 169 process_snapshot.ClientID(&actual_client_id); |
| 170 EXPECT_EQ(client_id, actual_client_id); | 170 EXPECT_EQ(actual_client_id, client_id); |
| 171 | 171 |
| 172 EXPECT_TRUE(process_snapshot.AnnotationsSimpleMap().empty()); | 172 EXPECT_TRUE(process_snapshot.AnnotationsSimpleMap().empty()); |
| 173 } | 173 } |
| 174 | 174 |
| 175 TEST(ProcessSnapshotMinidump, AnnotationsSimpleMap) { | 175 TEST(ProcessSnapshotMinidump, AnnotationsSimpleMap) { |
| 176 StringFile string_file; | 176 StringFile string_file; |
| 177 | 177 |
| 178 MINIDUMP_HEADER header = {}; | 178 MINIDUMP_HEADER header = {}; |
| 179 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); | 179 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); |
| 180 | 180 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 202 header.Version = MINIDUMP_VERSION; | 202 header.Version = MINIDUMP_VERSION; |
| 203 header.NumberOfStreams = 1; | 203 header.NumberOfStreams = 1; |
| 204 EXPECT_TRUE(string_file.SeekSet(0)); | 204 EXPECT_TRUE(string_file.SeekSet(0)); |
| 205 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); | 205 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); |
| 206 | 206 |
| 207 ProcessSnapshotMinidump process_snapshot; | 207 ProcessSnapshotMinidump process_snapshot; |
| 208 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); | 208 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); |
| 209 | 209 |
| 210 UUID client_id; | 210 UUID client_id; |
| 211 process_snapshot.ClientID(&client_id); | 211 process_snapshot.ClientID(&client_id); |
| 212 EXPECT_EQ(UUID(), client_id); | 212 EXPECT_EQ(client_id, UUID()); |
| 213 | 213 |
| 214 const auto annotations_simple_map = process_snapshot.AnnotationsSimpleMap(); | 214 const auto annotations_simple_map = process_snapshot.AnnotationsSimpleMap(); |
| 215 EXPECT_EQ(dictionary, annotations_simple_map); | 215 EXPECT_EQ(annotations_simple_map, dictionary); |
| 216 } | 216 } |
| 217 | 217 |
| 218 TEST(ProcessSnapshotMinidump, Modules) { | 218 TEST(ProcessSnapshotMinidump, Modules) { |
| 219 StringFile string_file; | 219 StringFile string_file; |
| 220 | 220 |
| 221 MINIDUMP_HEADER header = {}; | 221 MINIDUMP_HEADER header = {}; |
| 222 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); | 222 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); |
| 223 | 223 |
| 224 MINIDUMP_MODULE minidump_module = {}; | 224 MINIDUMP_MODULE minidump_module = {}; |
| 225 uint32_t minidump_module_count = 3; | 225 uint32_t minidump_module_count = 3; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 header.Signature = MINIDUMP_SIGNATURE; | 306 header.Signature = MINIDUMP_SIGNATURE; |
| 307 header.Version = MINIDUMP_VERSION; | 307 header.Version = MINIDUMP_VERSION; |
| 308 header.NumberOfStreams = 2; | 308 header.NumberOfStreams = 2; |
| 309 EXPECT_TRUE(string_file.SeekSet(0)); | 309 EXPECT_TRUE(string_file.SeekSet(0)); |
| 310 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); | 310 EXPECT_TRUE(string_file.Write(&header, sizeof(header))); |
| 311 | 311 |
| 312 ProcessSnapshotMinidump process_snapshot; | 312 ProcessSnapshotMinidump process_snapshot; |
| 313 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); | 313 EXPECT_TRUE(process_snapshot.Initialize(&string_file)); |
| 314 | 314 |
| 315 std::vector<const ModuleSnapshot*> modules = process_snapshot.Modules(); | 315 std::vector<const ModuleSnapshot*> modules = process_snapshot.Modules(); |
| 316 ASSERT_EQ(minidump_module_count, modules.size()); | 316 ASSERT_EQ(modules.size(), minidump_module_count); |
| 317 | 317 |
| 318 auto annotations_simple_map = modules[0]->AnnotationsSimpleMap(); | 318 auto annotations_simple_map = modules[0]->AnnotationsSimpleMap(); |
| 319 EXPECT_EQ(dictionary_0, annotations_simple_map); | 319 EXPECT_EQ(annotations_simple_map, dictionary_0); |
| 320 | 320 |
| 321 auto annotations_vector = modules[0]->AnnotationsVector(); | 321 auto annotations_vector = modules[0]->AnnotationsVector(); |
| 322 EXPECT_TRUE(annotations_vector.empty()); | 322 EXPECT_TRUE(annotations_vector.empty()); |
| 323 | 323 |
| 324 annotations_simple_map = modules[1]->AnnotationsSimpleMap(); | 324 annotations_simple_map = modules[1]->AnnotationsSimpleMap(); |
| 325 EXPECT_TRUE(annotations_simple_map.empty()); | 325 EXPECT_TRUE(annotations_simple_map.empty()); |
| 326 | 326 |
| 327 annotations_vector = modules[1]->AnnotationsVector(); | 327 annotations_vector = modules[1]->AnnotationsVector(); |
| 328 EXPECT_TRUE(annotations_vector.empty()); | 328 EXPECT_TRUE(annotations_vector.empty()); |
| 329 | 329 |
| 330 annotations_simple_map = modules[2]->AnnotationsSimpleMap(); | 330 annotations_simple_map = modules[2]->AnnotationsSimpleMap(); |
| 331 EXPECT_EQ(dictionary_2, annotations_simple_map); | 331 EXPECT_EQ(annotations_simple_map, dictionary_2); |
| 332 | 332 |
| 333 annotations_vector = modules[2]->AnnotationsVector(); | 333 annotations_vector = modules[2]->AnnotationsVector(); |
| 334 EXPECT_EQ(list_annotations_2, annotations_vector); | 334 EXPECT_EQ(annotations_vector, list_annotations_2); |
| 335 } | 335 } |
| 336 | 336 |
| 337 } // namespace | 337 } // namespace |
| 338 } // namespace test | 338 } // namespace test |
| 339 } // namespace crashpad | 339 } // namespace crashpad |
| OLD | NEW |