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

Side by Side Diff: third_party/crashpad/crashpad/minidump/minidump_handle_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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 *handle_data_stream = 53 *handle_data_stream =
54 MinidumpWritableAtLocationDescriptor<MINIDUMP_HANDLE_DATA_STREAM>( 54 MinidumpWritableAtLocationDescriptor<MINIDUMP_HANDLE_DATA_STREAM>(
55 file_contents, directory[kDirectoryIndex].Location); 55 file_contents, directory[kDirectoryIndex].Location);
56 ASSERT_TRUE(*handle_data_stream); 56 ASSERT_TRUE(*handle_data_stream);
57 } 57 }
58 58
59 TEST(MinidumpHandleDataWriter, Empty) { 59 TEST(MinidumpHandleDataWriter, Empty) {
60 MinidumpFileWriter minidump_file_writer; 60 MinidumpFileWriter minidump_file_writer;
61 auto handle_data_writer = base::WrapUnique(new MinidumpHandleDataWriter()); 61 auto handle_data_writer = base::WrapUnique(new MinidumpHandleDataWriter());
62 minidump_file_writer.AddStream(std::move(handle_data_writer)); 62 ASSERT_TRUE(minidump_file_writer.AddStream(std::move(handle_data_writer)));
63 63
64 StringFile string_file; 64 StringFile string_file;
65 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 65 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
66 66
67 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 67 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
68 sizeof(MINIDUMP_HANDLE_DATA_STREAM), 68 sizeof(MINIDUMP_HANDLE_DATA_STREAM),
69 string_file.string().size()); 69 string_file.string().size());
70 70
71 const MINIDUMP_HANDLE_DATA_STREAM* handle_data_stream = nullptr; 71 const MINIDUMP_HANDLE_DATA_STREAM* handle_data_stream = nullptr;
72 ASSERT_NO_FATAL_FAILURE( 72 ASSERT_NO_FATAL_FAILURE(
(...skipping 12 matching lines...) Expand all
85 handle_snapshot.attributes = 0x12345678; 85 handle_snapshot.attributes = 0x12345678;
86 handle_snapshot.granted_access = 0x9abcdef0; 86 handle_snapshot.granted_access = 0x9abcdef0;
87 handle_snapshot.pointer_count = 4567; 87 handle_snapshot.pointer_count = 4567;
88 handle_snapshot.handle_count = 9876; 88 handle_snapshot.handle_count = 9876;
89 89
90 std::vector<HandleSnapshot> snapshot; 90 std::vector<HandleSnapshot> snapshot;
91 snapshot.push_back(handle_snapshot); 91 snapshot.push_back(handle_snapshot);
92 92
93 handle_data_writer->InitializeFromSnapshot(snapshot); 93 handle_data_writer->InitializeFromSnapshot(snapshot);
94 94
95 minidump_file_writer.AddStream(std::move(handle_data_writer)); 95 ASSERT_TRUE(minidump_file_writer.AddStream(std::move(handle_data_writer)));
96 96
97 StringFile string_file; 97 StringFile string_file;
98 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 98 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
99 99
100 const size_t kTypeNameStringDataLength = 100 const size_t kTypeNameStringDataLength =
101 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16); 101 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16);
102 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 102 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
103 sizeof(MINIDUMP_HANDLE_DATA_STREAM) + 103 sizeof(MINIDUMP_HANDLE_DATA_STREAM) +
104 sizeof(MINIDUMP_HANDLE_DESCRIPTOR) + sizeof(MINIDUMP_STRING) + 104 sizeof(MINIDUMP_HANDLE_DESCRIPTOR) + sizeof(MINIDUMP_STRING) +
105 kTypeNameStringDataLength, 105 kTypeNameStringDataLength,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 handle_snapshot2.granted_access = 0x0fedcba9; 143 handle_snapshot2.granted_access = 0x0fedcba9;
144 handle_snapshot2.pointer_count = 7654; 144 handle_snapshot2.pointer_count = 7654;
145 handle_snapshot2.handle_count = 6789; 145 handle_snapshot2.handle_count = 6789;
146 146
147 std::vector<HandleSnapshot> snapshot; 147 std::vector<HandleSnapshot> snapshot;
148 snapshot.push_back(handle_snapshot); 148 snapshot.push_back(handle_snapshot);
149 snapshot.push_back(handle_snapshot2); 149 snapshot.push_back(handle_snapshot2);
150 150
151 handle_data_writer->InitializeFromSnapshot(snapshot); 151 handle_data_writer->InitializeFromSnapshot(snapshot);
152 152
153 minidump_file_writer.AddStream(std::move(handle_data_writer)); 153 ASSERT_TRUE(minidump_file_writer.AddStream(std::move(handle_data_writer)));
154 154
155 StringFile string_file; 155 StringFile string_file;
156 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file)); 156 ASSERT_TRUE(minidump_file_writer.WriteEverything(&string_file));
157 157
158 const size_t kTypeNameStringDataLength = 158 const size_t kTypeNameStringDataLength =
159 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16); 159 (handle_snapshot.type_name.size() + 1) * sizeof(base::char16);
160 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) + 160 ASSERT_EQ(sizeof(MINIDUMP_HEADER) + sizeof(MINIDUMP_DIRECTORY) +
161 sizeof(MINIDUMP_HANDLE_DATA_STREAM) + 161 sizeof(MINIDUMP_HANDLE_DATA_STREAM) +
162 (sizeof(MINIDUMP_HANDLE_DESCRIPTOR) * 2) + 162 (sizeof(MINIDUMP_HANDLE_DESCRIPTOR) * 2) +
163 sizeof(MINIDUMP_STRING) + kTypeNameStringDataLength, 163 sizeof(MINIDUMP_STRING) + kTypeNameStringDataLength,
(...skipping 30 matching lines...) Expand all
194 EXPECT_EQ(handle_snapshot2.granted_access, handle_descriptor2->GrantedAccess); 194 EXPECT_EQ(handle_snapshot2.granted_access, handle_descriptor2->GrantedAccess);
195 EXPECT_EQ(handle_snapshot2.handle_count, handle_descriptor2->HandleCount); 195 EXPECT_EQ(handle_snapshot2.handle_count, handle_descriptor2->HandleCount);
196 EXPECT_EQ(handle_snapshot2.pointer_count, handle_descriptor2->PointerCount); 196 EXPECT_EQ(handle_snapshot2.pointer_count, handle_descriptor2->PointerCount);
197 197
198 EXPECT_EQ(handle_descriptor->TypeNameRva, handle_descriptor2->TypeNameRva); 198 EXPECT_EQ(handle_descriptor->TypeNameRva, handle_descriptor2->TypeNameRva);
199 } 199 }
200 200
201 } // namespace 201 } // namespace
202 } // namespace test 202 } // namespace test
203 } // namespace crashpad 203 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698