Supports truncated test data in zippy benchmark.
R=sesse git-svn-id: https://snappy.googlecode.com/svn/trunk@74 03e5f5b5-db94-4691-08a0-1a8bf15f6143
This commit is contained in:
@@ -42,21 +42,25 @@ DEFINE_bool(run_microbenchmarks, true,
|
||||
|
||||
namespace snappy {
|
||||
|
||||
string ReadTestDataFile(const string& base) {
|
||||
string ReadTestDataFile(const string& base, size_t size_limit) {
|
||||
string contents;
|
||||
const char* srcdir = getenv("srcdir"); // This is set by Automake.
|
||||
string prefix;
|
||||
if (srcdir) {
|
||||
file::ReadFileToString(string(srcdir) + "/testdata/" + base,
|
||||
&contents,
|
||||
file::Defaults()).CheckSuccess();
|
||||
} else {
|
||||
file::ReadFileToString("testdata/" + base,
|
||||
&contents,
|
||||
file::Defaults()).CheckSuccess();
|
||||
prefix = string(srcdir) + "/";
|
||||
}
|
||||
file::GetContents(prefix + "testdata/" + base, &contents, file::Defaults()
|
||||
).CheckSuccess();
|
||||
if (size_limit > 0) {
|
||||
contents = contents.substr(0, size_limit);
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
string ReadTestDataFile(const string& base) {
|
||||
return ReadTestDataFile(base, 0);
|
||||
}
|
||||
|
||||
string StringPrintf(const char* format, ...) {
|
||||
char buf[4096];
|
||||
va_list ap;
|
||||
|
||||
Reference in New Issue
Block a user