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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 default: | 193 default: |
194 ADD_FAILURE(); | 194 ADD_FAILURE(); |
195 break; | 195 break; |
196 } | 196 } |
197 | 197 |
198 bool found = false; | 198 bool found = false; |
199 for (const std::string& annotation : all_annotations_vector) { | 199 for (const std::string& annotation : all_annotations_vector) { |
200 // Look for the expectation as a leading susbtring, because the actual | 200 // Look for the expectation as a leading susbtring, because the actual |
201 // string that dyld uses will have the contents of the | 201 // string that dyld uses will have the contents of the |
202 // DYLD_INSERT_LIBRARIES environment variable appended to it on Mac | 202 // DYLD_INSERT_LIBRARIES environment variable appended to it on OS X |
203 // OS X 10.10. | 203 // 10.10. |
204 if (annotation.substr(0, expected_annotation.length()) == | 204 if (annotation.substr(0, expected_annotation.length()) == |
205 expected_annotation) { | 205 expected_annotation) { |
206 found = true; | 206 found = true; |
207 break; | 207 break; |
208 } | 208 } |
209 } | 209 } |
210 EXPECT_TRUE(found) << expected_annotation; | 210 EXPECT_TRUE(found) << expected_annotation; |
211 } | 211 } |
212 | 212 |
213 // dyld exposes its error_string at least as far back as Mac OS X 10.4. | 213 // dyld exposes its error_string at least as far back as Mac OS X 10.4. |
214 if (test_type_ == kCrashDyld) { | 214 if (test_type_ == kCrashDyld) { |
215 const char kExpectedAnnotation[] = "could not load inserted library"; | 215 const char kExpectedAnnotation[] = "could not load inserted library"; |
216 size_t expected_annotation_length = strlen(kExpectedAnnotation); | 216 size_t expected_annotation_length = strlen(kExpectedAnnotation); |
217 bool found = false; | 217 bool found = false; |
218 for (const std::string& annotation : all_annotations_vector) { | 218 for (const std::string& annotation : all_annotations_vector) { |
219 // Look for the expectation as a leading substring, because the actual | 219 // Look for the expectation as a leading substring, because the actual |
220 // string will contain the library’s pathname and, on Mac OS X 10.9 | 220 // string will contain the library’s pathname and, on OS X 10.9 and |
221 // and later, a reason. | 221 // later, a reason. |
222 if (annotation.substr(0, expected_annotation_length) == | 222 if (annotation.substr(0, expected_annotation_length) == |
223 kExpectedAnnotation) { | 223 kExpectedAnnotation) { |
224 found = true; | 224 found = true; |
225 break; | 225 break; |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 EXPECT_TRUE(found) << kExpectedAnnotation; | 229 EXPECT_TRUE(found) << kExpectedAnnotation; |
230 } | 230 } |
231 } | 231 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 | 418 |
419 TEST(MachOImageAnnotationsReader, CrashDyld) { | 419 TEST(MachOImageAnnotationsReader, CrashDyld) { |
420 TestMachOImageAnnotationsReader test_mach_o_image_annotations_reader( | 420 TestMachOImageAnnotationsReader test_mach_o_image_annotations_reader( |
421 TestMachOImageAnnotationsReader::kCrashDyld); | 421 TestMachOImageAnnotationsReader::kCrashDyld); |
422 test_mach_o_image_annotations_reader.Run(); | 422 test_mach_o_image_annotations_reader.Run(); |
423 } | 423 } |
424 | 424 |
425 } // namespace | 425 } // namespace |
426 } // namespace test | 426 } // namespace test |
427 } // namespace crashpad | 427 } // namespace crashpad |
OLD | NEW |