OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (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 |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #include "minidump/test/minidump_writable_test_util.h" |
| 16 |
| 17 #include <string> |
| 18 |
| 19 #include "gtest/gtest.h" |
| 20 |
| 21 namespace crashpad { |
| 22 namespace test { |
| 23 |
| 24 const void* MinidumpWritableAtRVAInternal(const std::string& file_contents, |
| 25 RVA rva) { |
| 26 if (rva >= file_contents.size()) { |
| 27 EXPECT_LT(rva, file_contents.size()); |
| 28 return nullptr; |
| 29 } |
| 30 |
| 31 return &file_contents[rva]; |
| 32 } |
| 33 |
| 34 const void* MinidumpWritableAtLocationDescriptorInternal( |
| 35 const std::string& file_contents, |
| 36 const MINIDUMP_LOCATION_DESCRIPTOR& location, |
| 37 size_t expected_minimum_size) { |
| 38 if (location.DataSize == 0) { |
| 39 EXPECT_EQ(0u, location.Rva); |
| 40 return nullptr; |
| 41 } else if (location.DataSize < expected_minimum_size) { |
| 42 EXPECT_GE(location.DataSize, expected_minimum_size); |
| 43 return nullptr; |
| 44 } |
| 45 |
| 46 RVA end = location.Rva + location.DataSize; |
| 47 if (end > file_contents.size()) { |
| 48 EXPECT_LE(end, file_contents.size()); |
| 49 return nullptr; |
| 50 } |
| 51 |
| 52 const void* rv = MinidumpWritableAtRVAInternal(file_contents, location.Rva); |
| 53 |
| 54 return rv; |
| 55 } |
| 56 |
| 57 } // namespace test |
| 58 } // namespace crashpad |
OLD | NEW |