| 43 | namespace snappy { |
| 44 | |
| 45 | string ReadTestDataFile(const string& base, size_t size_limit) { |
| 46 | string contents; |
| 47 | const char* srcdir = getenv("srcdir"); // This is set by Automake. |
| 48 | string prefix; |
| 49 | if (srcdir) { |
| 50 | prefix = string(srcdir) + "/"; |
| 51 | } |
| 52 | file::GetContents(prefix + "testdata/" + base, &contents, file::Defaults() |
| 53 | ).CheckSuccess(); |
| 54 | if (size_limit > 0) { |
| 55 | contents = contents.substr(0, size_limit); |
| 56 | } |
| 57 | return contents; |
| 58 | } |
| 59 | |
| 60 | string ReadTestDataFile(const string& base) { |
| 61 | return ReadTestDataFile(base, 0); |
no test coverage detected