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

Side by Side Diff: minidump/minidump_memory_writer_test_util.cc

Issue 637503006: Add MinidumpThreadWriter, MinidumpThreadListWriter, and their test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@minidump_memory_writer_test_util
Patch Set: Address review feedback Created 6 years, 2 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
« no previous file with comments | « minidump/minidump_memory_writer_test_util.h ('k') | minidump/minidump_thread_writer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 bool rv = true; 57 bool rv = true;
58 if (size_ > 0) { 58 if (size_ > 0) {
59 std::string data(size_, value_); 59 std::string data(size_, value_);
60 rv = file_writer->Write(&data[0], size_); 60 rv = file_writer->Write(&data[0], size_);
61 EXPECT_TRUE(rv); 61 EXPECT_TRUE(rv);
62 } 62 }
63 63
64 return rv; 64 return rv;
65 } 65 }
66 66
67 void ExpectMinidumpMemoryDescriptorAndContents( 67 void ExpectMinidumpMemoryDescriptor(
68 const MINIDUMP_MEMORY_DESCRIPTOR* expected, 68 const MINIDUMP_MEMORY_DESCRIPTOR* expected,
69 const MINIDUMP_MEMORY_DESCRIPTOR* observed, 69 const MINIDUMP_MEMORY_DESCRIPTOR* observed) {
70 const std::string& file_contents,
71 uint8_t value,
72 bool at_eof) {
73 EXPECT_EQ(expected->StartOfMemoryRange, observed->StartOfMemoryRange); 70 EXPECT_EQ(expected->StartOfMemoryRange, observed->StartOfMemoryRange);
74 EXPECT_EQ(expected->Memory.DataSize, observed->Memory.DataSize); 71 EXPECT_EQ(expected->Memory.DataSize, observed->Memory.DataSize);
75 if (expected->Memory.Rva != 0) { 72 if (expected->Memory.Rva != 0) {
76 const uint32_t kMemoryAlignment = 16; 73 const uint32_t kMemoryAlignment = 16;
77 EXPECT_EQ( 74 EXPECT_EQ(
78 (expected->Memory.Rva + kMemoryAlignment - 1) & ~(kMemoryAlignment - 1), 75 (expected->Memory.Rva + kMemoryAlignment - 1) & ~(kMemoryAlignment - 1),
79 observed->Memory.Rva); 76 observed->Memory.Rva);
80 } 77 }
78 }
79
80 void ExpectMinidumpMemoryDescriptorAndContents(
81 const MINIDUMP_MEMORY_DESCRIPTOR* expected,
82 const MINIDUMP_MEMORY_DESCRIPTOR* observed,
83 const std::string& file_contents,
84 uint8_t value,
85 bool at_eof) {
86 ExpectMinidumpMemoryDescriptor(expected, observed);
87
81 if (at_eof) { 88 if (at_eof) {
82 EXPECT_EQ(file_contents.size(), 89 EXPECT_EQ(file_contents.size(),
83 observed->Memory.Rva + observed->Memory.DataSize); 90 observed->Memory.Rva + observed->Memory.DataSize);
84 } else { 91 } else {
85 EXPECT_GE(file_contents.size(), 92 EXPECT_GE(file_contents.size(),
86 observed->Memory.Rva + observed->Memory.DataSize); 93 observed->Memory.Rva + observed->Memory.DataSize);
87 } 94 }
88 95
89 std::string expected_data(expected->Memory.DataSize, value); 96 std::string expected_data(expected->Memory.DataSize, value);
90 std::string observed_data(&file_contents[observed->Memory.Rva], 97 std::string observed_data(&file_contents[observed->Memory.Rva],
91 observed->Memory.DataSize); 98 observed->Memory.DataSize);
92 EXPECT_EQ(expected_data, observed_data); 99 EXPECT_EQ(expected_data, observed_data);
93 } 100 }
94 101
95 } // namespace test 102 } // namespace test
96 } // namespace crashpad 103 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/minidump_memory_writer_test_util.h ('k') | minidump/minidump_thread_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698