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

Side by Side Diff: util/mac/mach_o_image_reader_test.cc

Issue 586393003: 10.6 runtime compatibility for MachOImageReader test (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 EXPECT_FALSE( 274 EXPECT_FALSE(
275 actual_image->GetSectionByName("NoSuchSegment", "NoSuchSection", NULL)); 275 actual_image->GetSectionByName("NoSuchSegment", "NoSuchSection", NULL));
276 276
277 // Make sure that there’s a __TEXT segment so that this can do a valid test of 277 // Make sure that there’s a __TEXT segment so that this can do a valid test of
278 // a section that doesn’t exist within a segment that does. 278 // a section that doesn’t exist within a segment that does.
279 EXPECT_TRUE(actual_image->GetSegmentByName(SEG_TEXT)); 279 EXPECT_TRUE(actual_image->GetSegmentByName(SEG_TEXT));
280 EXPECT_FALSE(actual_image->GetSectionByName(SEG_TEXT, "NoSuchSection", NULL)); 280 EXPECT_FALSE(actual_image->GetSectionByName(SEG_TEXT, "NoSuchSection", NULL));
281 281
282 // Similarly, make sure that a section name that exists in one segment isn’t 282 // Similarly, make sure that a section name that exists in one segment isn’t
283 // accidentally found during a lookup for that section in a different segment. 283 // accidentally found during a lookup for that section in a different segment.
284 EXPECT_TRUE(actual_image->GetSectionByName(SEG_TEXT, SECT_TEXT, NULL)); 284 //
285 // If the image has no sections (unexpected), then any section lookup should
286 // fail, and these initial values of test_segment and test_section are fine
287 // for the EXPECT_FALSE checks on GetSectionByName() below.
288 std::string test_segment = SEG_DATA;
289 std::string test_section = SECT_TEXT;
290
291 const process_types::section* section =
292 actual_image->GetSectionAtIndex(1, NULL, NULL);
293 if (section) {
294 // Use the name of the first section in the image as the section that
295 // shouldn’t appear in a different segment. If the first section is in the
296 // __TEXT segment (as it is normally), then a section by the same name
297 // wouldn’t be expected in the __DATA segment. But if the first section is
298 // in any other segment, then it wouldn’t be expected in the __TEXT segment.
299 if (MachOImageSegmentReader::SegmentNameString(section->segname) ==
300 SEG_TEXT) {
Robert Sesek 2014/09/22 16:35:47 nit: indent +4
301 test_segment = SEG_DATA;
302 } else {
303 test_segment = SEG_TEXT;
304 }
305 test_section =
306 MachOImageSegmentReader::SectionNameString(section->sectname);
307
308 // It should be possible to look up the first section by name.
309 EXPECT_EQ(section, actual_image->GetSectionByName(
310 section->segname, section->sectname, NULL));
311 }
285 EXPECT_FALSE( 312 EXPECT_FALSE(
286 actual_image->GetSectionByName("NoSuchSegment", SECT_TEXT, NULL)); 313 actual_image->GetSectionByName("NoSuchSegment", test_section, NULL));
287 EXPECT_FALSE(actual_image->GetSectionByName(SEG_DATA, SECT_TEXT, NULL)); 314 EXPECT_FALSE(
315 actual_image->GetSectionByName(test_segment, test_section, NULL));
288 316
289 // The __LINKEDIT segment normally does exist but doesn’t have any sections. 317 // The __LINKEDIT segment normally does exist but doesn’t have any sections.
290 EXPECT_FALSE( 318 EXPECT_FALSE(
291 actual_image->GetSectionByName(SEG_LINKEDIT, "NoSuchSection", NULL)); 319 actual_image->GetSectionByName(SEG_LINKEDIT, "NoSuchSection", NULL));
292 EXPECT_FALSE(actual_image->GetSectionByName(SEG_LINKEDIT, SECT_TEXT, NULL)); 320 EXPECT_FALSE(actual_image->GetSectionByName(SEG_LINKEDIT, SECT_TEXT, NULL));
293 } 321 }
294 322
295 // In some cases, the expected slide value for an image is unknown, because no 323 // In some cases, the expected slide value for an image is unknown, because no
296 // reasonable API to return it is provided. When this happens, use kSlideUnknown 324 // reasonable API to return it is provided. When this happens, use kSlideUnknown
297 // to avoid checking the actual slide value against anything. 325 // to avoid checking the actual slide value against anything.
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 expected_uuid.InitializeFromBytes(dyld_image->imageUUID); 653 expected_uuid.InitializeFromBytes(dyld_image->imageUUID);
626 UUID actual_uuid; 654 UUID actual_uuid;
627 image_reader.UUID(&actual_uuid); 655 image_reader.UUID(&actual_uuid);
628 EXPECT_EQ(expected_uuid, actual_uuid); 656 EXPECT_EQ(expected_uuid, actual_uuid);
629 } 657 }
630 } 658 }
631 #endif 659 #endif
632 } 660 }
633 661
634 } // namespace 662 } // namespace
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698