mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-29 02:35:31 +01:00
Breakpad Linux dumper: Add unit tests for google_breakpad::Module.
Adjust Module's interface a bit to facilitate testing: - Make AssignSourceIds something a client can call --- it's perfectly well-defined, so this is an okay change. - Add GetFunctions, GetFiles and FindExistingfile member functions, which the test harness will use to get results to examine. a=jimblandy, r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@466 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
6ed5383245
commit
52cb2c6f42
4 changed files with 350 additions and 12 deletions
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include "common/linux/module.h"
|
||||
|
||||
namespace google_breakpad {
|
||||
|
|
@ -62,6 +63,11 @@ void Module::AddFunctions(vector<Function *>::iterator begin,
|
|||
functions_.insert(functions_.end(), begin, end);
|
||||
}
|
||||
|
||||
void Module::GetFunctions(vector<Function *> *vec,
|
||||
vector<Function *>::iterator i) {
|
||||
vec->insert(i, functions_.begin(), functions_.end());
|
||||
}
|
||||
|
||||
Module::File *Module::FindFile(const string &name) {
|
||||
// A tricky bit here. The key of each map entry needs to be a
|
||||
// pointer to the entry's File's name string. This means that we
|
||||
|
|
@ -90,6 +96,17 @@ Module::File *Module::FindFile(const char *name) {
|
|||
return FindFile(name_string);
|
||||
}
|
||||
|
||||
Module::File *Module::FindExistingFile(const string &name) {
|
||||
FileByNameMap::iterator it = files_.find(&name);
|
||||
return (it == files_.end()) ? NULL : it->second;
|
||||
}
|
||||
|
||||
void Module::GetFiles(vector<File *> *vec) {
|
||||
vec->clear();
|
||||
for (FileByNameMap::iterator it = files_.begin(); it != files_.end(); it++)
|
||||
vec->push_back(it->second);
|
||||
}
|
||||
|
||||
void Module::AssignSourceIds() {
|
||||
// First, give every source file an id of -1.
|
||||
for (FileByNameMap::iterator file_it = files_.begin();
|
||||
|
|
@ -129,8 +146,9 @@ bool Module::Write(FILE *stream) {
|
|||
name_.c_str()))
|
||||
return ReportError();
|
||||
|
||||
// Write out files.
|
||||
AssignSourceIds();
|
||||
|
||||
// Write out files.
|
||||
for (FileByNameMap::iterator file_it = files_.begin();
|
||||
file_it != files_.end(); file_it++) {
|
||||
File *file = file_it->second;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue