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

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

Issue 510002: Provide a ReadSymbolData function from dump_symbols.cc (Closed)
Patch Set: Created 12 years, 2 months 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/dump_symbols.h ('K') | « src/common/linux/dump_symbols.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/dump_symbols_unittest.cc
===================================================================
--- a/src/common/linux/dump_symbols_unittest.cc
+++ b/src/common/linux/dump_symbols_unittest.cc
@@ -32,37 +32,38 @@
// dump_symbols_unittest.cc:
// Unittests for google_breakpad::DumpSymbols
#include <elf.h>
#include <link.h>
#include <stdio.h>
#include <sstream>
-#include <string>
#include <vector>
#include "breakpad_googletest_includes.h"
#include "common/linux/synth_elf.h"
+#include "common/module.h"
#include "common/using_std_string.h"
namespace google_breakpad {
-bool WriteSymbolFileInternal(const uint8_t* obj_file,
- const string &obj_filename,
- const string &debug_dir,
- bool cfi,
- std::ostream &sym_stream);
+bool ReadSymbolDataInternal(const uint8_t* obj_file,
+ const string &obj_filename,
+ const string &debug_dir,
+ bool cfi,
+ Module** module);
}
using google_breakpad::synth_elf::ELF;
using google_breakpad::synth_elf::StringTable;
using google_breakpad::synth_elf::SymbolTable;
using google_breakpad::test_assembler::kLittleEndian;
using google_breakpad::test_assembler::Section;
-using google_breakpad::WriteSymbolFileInternal;
+using google_breakpad::Module;
+using google_breakpad::ReadSymbolDataInternal;
using std::stringstream;
using std::vector;
using ::testing::Test;
class DumpSymbols : public Test {
public:
void GetElfContents(ELF& elf) {
string contents;
@@ -76,22 +77,22 @@ class DumpSymbols : public Test {
vector<uint8_t> elfdata_v;
uint8_t* elfdata;
};
TEST_F(DumpSymbols, Invalid) {
Elf32_Ehdr header;
memset(&header, 0, sizeof(header));
- stringstream s;
- EXPECT_FALSE(WriteSymbolFileInternal(reinterpret_cast<uint8_t*>(&header),
+ Module* module;
+ EXPECT_FALSE(ReadSymbolDataInternal(reinterpret_cast<uint8_t*>(&header),
"foo",
"",
true,
- s));
+ &module));
}
TEST_F(DumpSymbols, SimplePublic32) {
ELF elf(EM_386, ELFCLASS32, kLittleEndian);
// Zero out text section for simplicity.
Section text(kLittleEndian);
text.Append(4096, 0);
elf.AddSection(".text", text, SHT_PROGBITS);
@@ -108,25 +109,29 @@ TEST_F(DumpSymbols, SimplePublic32) {
SHF_ALLOC, // flags
0, // addr
index, // link
sizeof(Elf32_Sym)); // entsize
elf.Finish();
GetElfContents(elf);
+ Module* module;
+ EXPECT_TRUE(ReadSymbolDataInternal(elfdata,
+ "foo",
+ "",
+ true,
+ &module));
+
stringstream s;
- ASSERT_TRUE(WriteSymbolFileInternal(elfdata,
- "foo",
- "",
- true,
- s));
+ module->Write(s, true);
EXPECT_EQ("MODULE Linux x86 000000000000000000000000000000000 foo\n"
"PUBLIC 1000 0 superfunc\n",
s.str());
+ delete module;
}
TEST_F(DumpSymbols, SimplePublic64) {
ELF elf(EM_X86_64, ELFCLASS64, kLittleEndian);
// Zero out text section for simplicity.
Section text(kLittleEndian);
text.Append(4096, 0);
elf.AddSection(".text", text, SHT_PROGBITS);
@@ -143,18 +148,21 @@ TEST_F(DumpSymbols, SimplePublic64) {
SHF_ALLOC, // flags
0, // addr
index, // link
sizeof(Elf64_Sym)); // entsize
elf.Finish();
GetElfContents(elf);
+ Module* module;
+ EXPECT_TRUE(ReadSymbolDataInternal(elfdata,
+ "foo",
+ "",
+ true,
+ &module));
+
stringstream s;
- ASSERT_TRUE(WriteSymbolFileInternal(elfdata,
- "foo",
- "",
- true,
- s));
+ module->Write(s, true);
EXPECT_EQ("MODULE Linux x86_64 000000000000000000000000000000000 foo\n"
"PUBLIC 1000 0 superfunc\n",
s.str());
}
« src/common/linux/dump_symbols.h ('K') | « src/common/linux/dump_symbols.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