diff options
author | snappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143> | 2013-04-09 15:33:30 +0000 |
---|---|---|
committer | snappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143> | 2013-04-09 15:33:30 +0000 |
commit | 19a58fe3eb730b82932527293ea3734c924a179d (patch) | |
tree | dfba6ee89f5af5d2a20d228b6ce4b276819ab787 /snappy-test.cc | |
parent | 2be83699adf1cb58e43f9dd9f7cf8fe136fd797a (diff) | |
download | snappy-19a58fe3eb730b82932527293ea3734c924a179d.tar.gz |
Supports truncated test data in zippy benchmark.
R=sesse
git-svn-id: http://snappy.googlecode.com/svn/trunk@74 03e5f5b5-db94-4691-08a0-1a8bf15f6143
Diffstat (limited to 'snappy-test.cc')
-rw-r--r-- | snappy-test.cc | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/snappy-test.cc b/snappy-test.cc index 3f4003d..4619410 100644 --- a/snappy-test.cc +++ b/snappy-test.cc @@ -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; |