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

Side by Side Diff: third_party/crashpad/crashpad/minidump/minidump_memory_info_writer_test.cc

Issue 2773813002: Update Crashpad to 8e37886d418dd042c3c7bfadac99214739ee4d98 (Closed)
Patch Set: Update Crashpad to 8e37886d418dd042c3c7bfadac99214739ee4d98 Created 3 years, 9 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 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
53 *memory_info_list = 53 *memory_info_list =
54 MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_INFO_LIST>( 54 MinidumpWritableAtLocationDescriptor<MINIDUMP_MEMORY_INFO_LIST>(
55 file_contents, directory[kDirectoryIndex].Location); 55 file_contents, directory[kDirectoryIndex].Location);
56 ASSERT_TRUE(*memory_info_list); 56 ASSERT_TRUE(*memory_info_list);
57 } 57 }
58 58
59 TEST(MinidumpMemoryInfoWriter, Empty) { 59 TEST(MinidumpMemoryInfoWriter, Empty) {
60 MinidumpFileWriter minidump_file_writer; 60 MinidumpFileWriter minidump_file_writer;
61 auto memory_info_list_writer = 61 auto memory_info_list_writer =
62 base::WrapUnique(new MinidumpMemoryInfoListWriter()); 62 base::WrapUnique(new MinidumpMemoryInfoListWriter());
63 minidump_file_writer.AddStream(std::move(memory_info_list_writer)); 63 ASSERT_TRUE(
64 minidump_file_writer.AddStream(std::move(memory_info_list_writer)));
64 65
65 StringFile string_file; 66 StringFile string_file;
66 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 67 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
67 68
68 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 69 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
69 sizeof(MINIDUMP_MEMORY_INFO_LIST), 70 sizeof(MINIDUMP_MEMORY_INFO_LIST),
70 string_file.string().size()); 71 string_file.string().size());
71 72
72 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr; 73 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr;
73 ASSERT_NO_FATAL_FAILURE( 74 ASSERT_NO_FATAL_FAILURE(
(...skipping 16 matching lines...) Expand all
90 mmi.RegionSize = 0x6000; 91 mmi.RegionSize = 0x6000;
91 mmi.State = MEM_COMMIT; 92 mmi.State = MEM_COMMIT;
92 mmi.Protect = PAGE_NOACCESS; 93 mmi.Protect = PAGE_NOACCESS;
93 mmi.Type = MEM_PRIVATE; 94 mmi.Type = MEM_PRIVATE;
94 memory_map_region->SetMindumpMemoryInfo(mmi); 95 memory_map_region->SetMindumpMemoryInfo(mmi);
95 96
96 std::vector<const MemoryMapRegionSnapshot*> memory_map; 97 std::vector<const MemoryMapRegionSnapshot*> memory_map;
97 memory_map.push_back(memory_map_region.get()); 98 memory_map.push_back(memory_map_region.get());
98 memory_info_list_writer->InitializeFromSnapshot(memory_map); 99 memory_info_list_writer->InitializeFromSnapshot(memory_map);
99 100
100 minidump_file_writer.AddStream(std::move(memory_info_list_writer)); 101 ASSERT_TRUE(
102 minidump_file_writer.AddStream(std::move(memory_info_list_writer)));
101 103
102 StringFile string_file; 104 StringFile string_file;
103 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 105 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
104 106
105 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 107 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
106 sizeof(MINIDUMP_MEMORY_INFO_LIST) + 108 sizeof(MINIDUMP_MEMORY_INFO_LIST) +
107 sizeof(MINIDUMP_MEMORY_INFO), 109 sizeof(MINIDUMP_MEMORY_INFO),
108 string_file.string().size()); 110 string_file.string().size());
109 111
110 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr; 112 const MINIDUMP_MEMORY_INFO_LIST* memory_info_list = nullptr;
111 ASSERT_NO_FATAL_FAILURE( 113 ASSERT_NO_FATAL_FAILURE(
112 GetMemoryInfoListStream(string_file.string(), &memory_info_list)); 114 GetMemoryInfoListStream(string_file.string(), &memory_info_list));
113 115
114 EXPECT_EQ(1u, memory_info_list->NumberOfEntries); 116 EXPECT_EQ(1u, memory_info_list->NumberOfEntries);
115 const MINIDUMP_MEMORY_INFO* memory_info = 117 const MINIDUMP_MEMORY_INFO* memory_info =
116 reinterpret_cast<const MINIDUMP_MEMORY_INFO*>(&memory_info_list[1]); 118 reinterpret_cast<const MINIDUMP_MEMORY_INFO*>(&memory_info_list[1]);
117 EXPECT_EQ(mmi.BaseAddress, memory_info->BaseAddress); 119 EXPECT_EQ(mmi.BaseAddress, memory_info->BaseAddress);
118 EXPECT_EQ(mmi.AllocationBase, memory_info->AllocationBase); 120 EXPECT_EQ(mmi.AllocationBase, memory_info->AllocationBase);
119 EXPECT_EQ(mmi.AllocationProtect, memory_info->AllocationProtect); 121 EXPECT_EQ(mmi.AllocationProtect, memory_info->AllocationProtect);
120 EXPECT_EQ(mmi.RegionSize, memory_info->RegionSize); 122 EXPECT_EQ(mmi.RegionSize, memory_info->RegionSize);
121 EXPECT_EQ(mmi.State, memory_info->State); 123 EXPECT_EQ(mmi.State, memory_info->State);
122 EXPECT_EQ(mmi.Protect, memory_info->Protect); 124 EXPECT_EQ(mmi.Protect, memory_info->Protect);
123 EXPECT_EQ(mmi.Type, memory_info->Type); 125 EXPECT_EQ(mmi.Type, memory_info->Type);
124 } 126 }
125 127
126 } // namespace 128 } // namespace
127 } // namespace test 129 } // namespace test
128 } // namespace crashpad 130 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698