| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 std::string expected_data(expected->Memory.DataSize, value); | 179 std::string expected_data(expected->Memory.DataSize, value); |
| 180 std::string observed_data(&file_contents[observed->Memory.Rva], | 180 std::string observed_data(&file_contents[observed->Memory.Rva], |
| 181 observed->Memory.DataSize); | 181 observed->Memory.DataSize); |
| 182 EXPECT_EQ(expected_data, observed_data); | 182 EXPECT_EQ(expected_data, observed_data); |
| 183 } | 183 } |
| 184 | 184 |
| 185 TEST(MinidumpMemoryWriter, OneMemoryRegion) { | 185 TEST(MinidumpMemoryWriter, OneMemoryRegion) { |
| 186 MinidumpFileWriter minidump_file_writer; | 186 MinidumpFileWriter minidump_file_writer; |
| 187 MinidumpMemoryListWriter memory_list_writer; | 187 MinidumpMemoryListWriter memory_list_writer; |
| 188 | 188 |
| 189 const uint64_t kBaseAddress = 0xfedcba9876543210ull; | 189 const uint64_t kBaseAddress = 0xfedcba9876543210; |
| 190 const uint64_t kSize = 0x1000; | 190 const uint64_t kSize = 0x1000; |
| 191 const uint8_t kValue = 'm'; | 191 const uint8_t kValue = 'm'; |
| 192 | 192 |
| 193 TestMemoryWriter memory_writer(kBaseAddress, kSize, kValue); | 193 TestMemoryWriter memory_writer(kBaseAddress, kSize, kValue); |
| 194 memory_list_writer.AddMemory(&memory_writer); | 194 memory_list_writer.AddMemory(&memory_writer); |
| 195 | 195 |
| 196 minidump_file_writer.AddStream(&memory_list_writer); | 196 minidump_file_writer.AddStream(&memory_list_writer); |
| 197 | 197 |
| 198 StringFileWriter file_writer; | 198 StringFileWriter file_writer; |
| 199 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 199 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 215 &memory_list->MemoryRanges[0], | 215 &memory_list->MemoryRanges[0], |
| 216 file_writer.string(), | 216 file_writer.string(), |
| 217 kValue, | 217 kValue, |
| 218 true); | 218 true); |
| 219 } | 219 } |
| 220 | 220 |
| 221 TEST(MinidumpMemoryWriter, TwoMemoryRegions) { | 221 TEST(MinidumpMemoryWriter, TwoMemoryRegions) { |
| 222 MinidumpFileWriter minidump_file_writer; | 222 MinidumpFileWriter minidump_file_writer; |
| 223 MinidumpMemoryListWriter memory_list_writer; | 223 MinidumpMemoryListWriter memory_list_writer; |
| 224 | 224 |
| 225 const uint64_t kBaseAddress1 = 0x00c0ffeeull; | 225 const uint64_t kBaseAddress1 = 0xc0ffee; |
| 226 const uint64_t kSize1 = 0x0100; | 226 const uint64_t kSize1 = 0x0100; |
| 227 const uint8_t kValue1 = '6'; | 227 const uint8_t kValue1 = '6'; |
| 228 const uint64_t kBaseAddress2 = 0xfac00facull; | 228 const uint64_t kBaseAddress2 = 0xfac00fac; |
| 229 const uint64_t kSize2 = 0x0200; | 229 const uint64_t kSize2 = 0x0200; |
| 230 const uint8_t kValue2 = '!'; | 230 const uint8_t kValue2 = '!'; |
| 231 | 231 |
| 232 TestMemoryWriter memory_writer_1(kBaseAddress1, kSize1, kValue1); | 232 TestMemoryWriter memory_writer_1(kBaseAddress1, kSize1, kValue1); |
| 233 memory_list_writer.AddMemory(&memory_writer_1); | 233 memory_list_writer.AddMemory(&memory_writer_1); |
| 234 TestMemoryWriter memory_writer_2(kBaseAddress2, kSize2, kValue2); | 234 TestMemoryWriter memory_writer_2(kBaseAddress2, kSize2, kValue2); |
| 235 memory_list_writer.AddMemory(&memory_writer_2); | 235 memory_list_writer.AddMemory(&memory_writer_2); |
| 236 | 236 |
| 237 minidump_file_writer.AddStream(&memory_list_writer); | 237 minidump_file_writer.AddStream(&memory_list_writer); |
| 238 | 238 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 DISALLOW_COPY_AND_ASSIGN(TestMemoryStream); | 309 DISALLOW_COPY_AND_ASSIGN(TestMemoryStream); |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 TEST(MinidumpMemoryWriter, ExtraMemory) { | 312 TEST(MinidumpMemoryWriter, ExtraMemory) { |
| 313 // This tests MinidumpMemoryListWriter::AddExtraMemory(). That method adds | 313 // This tests MinidumpMemoryListWriter::AddExtraMemory(). That method adds |
| 314 // a MinidumpMemoryWriter to the MinidumpMemoryListWriter without making the | 314 // a MinidumpMemoryWriter to the MinidumpMemoryListWriter without making the |
| 315 // memory writer a child of the memory list writer. | 315 // memory writer a child of the memory list writer. |
| 316 MinidumpFileWriter minidump_file_writer; | 316 MinidumpFileWriter minidump_file_writer; |
| 317 | 317 |
| 318 const uint64_t kBaseAddress1 = 0x0000000000001000ull; | 318 const uint64_t kBaseAddress1 = 0x1000; |
| 319 const uint64_t kSize1 = 0x0400; | 319 const uint64_t kSize1 = 0x0400; |
| 320 const uint8_t kValue1 = '1'; | 320 const uint8_t kValue1 = '1'; |
| 321 TestMemoryStream test_memory_stream(kBaseAddress1, kSize1, kValue1); | 321 TestMemoryStream test_memory_stream(kBaseAddress1, kSize1, kValue1); |
| 322 | 322 |
| 323 MinidumpMemoryListWriter memory_list_writer; | 323 MinidumpMemoryListWriter memory_list_writer; |
| 324 memory_list_writer.AddExtraMemory(test_memory_stream.memory()); | 324 memory_list_writer.AddExtraMemory(test_memory_stream.memory()); |
| 325 | 325 |
| 326 minidump_file_writer.AddStream(&test_memory_stream); | 326 minidump_file_writer.AddStream(&test_memory_stream); |
| 327 | 327 |
| 328 const uint64_t kBaseAddress2 = 0x0000000000002000ull; | 328 const uint64_t kBaseAddress2 = 0x2000; |
| 329 const uint64_t kSize2 = 0x0400; | 329 const uint64_t kSize2 = 0x0400; |
| 330 const uint8_t kValue2 = 'm'; | 330 const uint8_t kValue2 = 'm'; |
| 331 | 331 |
| 332 TestMemoryWriter memory_writer(kBaseAddress2, kSize2, kValue2); | 332 TestMemoryWriter memory_writer(kBaseAddress2, kSize2, kValue2); |
| 333 memory_list_writer.AddMemory(&memory_writer); | 333 memory_list_writer.AddMemory(&memory_writer); |
| 334 | 334 |
| 335 minidump_file_writer.AddStream(&memory_list_writer); | 335 minidump_file_writer.AddStream(&memory_list_writer); |
| 336 | 336 |
| 337 StringFileWriter file_writer; | 337 StringFileWriter file_writer; |
| 338 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); | 338 ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 363 expected.Memory.Rva = memory_list->MemoryRanges[0].Memory.Rva + | 363 expected.Memory.Rva = memory_list->MemoryRanges[0].Memory.Rva + |
| 364 memory_list->MemoryRanges[0].Memory.DataSize; | 364 memory_list->MemoryRanges[0].Memory.DataSize; |
| 365 ExpectMemoryDescriptorAndContents(&expected, | 365 ExpectMemoryDescriptorAndContents(&expected, |
| 366 &memory_list->MemoryRanges[1], | 366 &memory_list->MemoryRanges[1], |
| 367 file_writer.string(), | 367 file_writer.string(), |
| 368 kValue2, | 368 kValue2, |
| 369 true); | 369 true); |
| 370 } | 370 } |
| 371 | 371 |
| 372 } // namespace | 372 } // namespace |
| OLD | NEW |