Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(18)

Unified Diff: src/common/linux/synth_elf_unittest.cc

Issue 546002: Support generic Elf notes, with unit tests (Closed)
Patch Set: Created 12 years ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/common/linux/synth_elf.cc ('K') | « src/common/linux/synth_elf.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/common/linux/synth_elf_unittest.cc
diff --git a/src/common/linux/synth_elf_unittest.cc b/src/common/linux/synth_elf_unittest.cc
index 94ff505228e466fe2ac838c14e87a373f34d9bee..3715b6e608b3da297164376ba271890d9dbd35ea 100644
--- a/src/common/linux/synth_elf_unittest.cc
+++ b/src/common/linux/synth_elf_unittest.cc
@@ -42,6 +42,7 @@
using google_breakpad::ElfClass32;
using google_breakpad::ElfClass64;
using google_breakpad::synth_elf::ELF;
+using google_breakpad::synth_elf::Notes;
using google_breakpad::synth_elf::Section;
using google_breakpad::synth_elf::StringTable;
using google_breakpad::synth_elf::SymbolTable;
@@ -369,4 +370,44 @@ TYPED_TEST(BasicElf, BasicLE) {
EXPECT_EQ(0U, phdr->p_align);
}
+class ElfNotesTest : public Test {};
+
+TEST_F(ElfNotesTest, Empty) {
+ Notes notes(kLittleEndian);
+ string contents;
+ ASSERT_TRUE(notes.GetContents(&contents));
+ EXPECT_EQ(0U, contents.size());
+}
+
+TEST_F(ElfNotesTest, Notes) {
+ Notes notes(kLittleEndian);
+ notes.AddNote(1, "Linux", reinterpret_cast<const uint8_t *>("\x42\x02\0\0"),
+ 4);
+ notes.AddNote(2, "a", reinterpret_cast<const uint8_t *>("foobar"),
+ sizeof("foobar") - 1);
+
+ const uint8_t kExpectedNotesContents[] = {
+ // Note 1
+ 0x06, 0x00, 0x00, 0x00, // name size, including terminating zero
+ 0x04, 0x00, 0x00, 0x00, // desc size
+ 0x01, 0x00, 0x00, 0x00, // type
+ 'L', 'i', 'n', 'u', 'x', 0x00, 0x00, 0x00, // padded "Linux"
+ 0x42, 0x02, 0x00, 0x00, // desc
+ // Note 2
+ 0x02, 0x00, 0x00, 0x00, // name size
+ 0x06, 0x00, 0x00, 0x00, // desc size
+ 0x02, 0x00, 0x00, 0x00, // type
+ 'a', 0x00, 0x00, 0x00, // padded "a"
+ 'f', 'o', 'o', 'b', 'a', 'r', 0x00, 0x00, // padded "foobar"
+ };
+ const size_t kExpectedNotesSize = sizeof(kExpectedNotesContents);
+ EXPECT_EQ(kExpectedNotesSize, notes.Size());
+
+ string notes_contents;
+ ASSERT_TRUE(notes.GetContents(&notes_contents));
+ EXPECT_EQ(0, memcmp(kExpectedNotesContents,
+ notes_contents.data(),
+ notes_contents.size()));
+}
+
#endif // defined(__i386__) || defined(__x86_64__)
« src/common/linux/synth_elf.cc ('K') | « src/common/linux/synth_elf.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1004:630ec63f810e-tainted