aboutsummaryrefslogtreecommitdiff
path: root/src/common/linux/file_id_unittest.cc
diff options
context:
space:
mode:
authorted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-04-04 16:24:52 +0000
committerted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-04-04 16:24:52 +0000
commitb6e66b294fe5d851ffbb57c1527acccf2f53a4b5 (patch)
treed9393dd09c9dff808df5053667fd6a7f20d69226 /src/common/linux/file_id_unittest.cc
parentSupport generic Elf notes, with unit tests (diff)
downloadbreakpad-b6e66b294fe5d851ffbb57c1527acccf2f53a4b5.tar.xz
Try to find a build-id through PT_NOTE program headers
A=Mike Hommey <mh@glandium.org> R=ted at https://breakpad.appspot.com/544003/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1143 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/linux/file_id_unittest.cc')
-rw-r--r--src/common/linux/file_id_unittest.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/common/linux/file_id_unittest.cc b/src/common/linux/file_id_unittest.cc
index e2e13747..bcd030dc 100644
--- a/src/common/linux/file_id_unittest.cc
+++ b/src/common/linux/file_id_unittest.cc
@@ -175,6 +175,41 @@ TYPED_TEST(FileIDTest, BuildID) {
EXPECT_STREQ(expected_identifier_string, identifier_string);
}
+TYPED_TEST(FileIDTest, BuildIDPH) {
+ const uint8_t kExpectedIdentifier[sizeof(MDGUID)] =
+ {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
+ char expected_identifier_string[] =
+ "00000000-0000-0000-0000-000000000000";
+ FileID::ConvertIdentifierToString(kExpectedIdentifier,
+ expected_identifier_string,
+ sizeof(expected_identifier_string));
+
+ uint8_t identifier[sizeof(MDGUID)];
+ char identifier_string[sizeof(expected_identifier_string)];
+
+ ELF elf(EM_386, TypeParam::kClass, kLittleEndian);
+ Section text(kLittleEndian);
+ text.Append(4096, 0);
+ elf.AddSection(".text", text, SHT_PROGBITS);
+ Notes notes(kLittleEndian);
+ notes.AddNote(0, "Linux",
+ reinterpret_cast<const uint8_t *>("\0x42\0x02\0\0"), 4);
+ notes.AddNote(NT_GNU_BUILD_ID, "GNU", kExpectedIdentifier,
+ sizeof(kExpectedIdentifier));
+ int note_idx = elf.AddSection(".note", notes, SHT_NOTE);
+ elf.AddSegment(note_idx, note_idx, PT_NOTE);
+ elf.Finish();
+ this->GetElfContents(elf);
+
+ EXPECT_TRUE(FileID::ElfFileIdentifierFromMappedFile(this->elfdata,
+ identifier));
+
+ FileID::ConvertIdentifierToString(identifier, identifier_string,
+ sizeof(identifier_string));
+ EXPECT_STREQ(expected_identifier_string, identifier_string);
+}
+
// Test to make sure two files with different text sections produce
// different hashes when not using a build id.
TYPED_TEST(FileIDTest, UniqueHashes) {