MCPcopy Create free account
hub / github.com/apache/impala / GetTestDataDirectory

Function GetTestDataDirectory

be/src/kudu/util/test_util.cc:260–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260string GetTestDataDirectory() {
261 const ::testing::TestInfo* const test_info =
262 ::testing::UnitTest::GetInstance()->current_test_info();
263 CHECK(test_info) << "Must be running in a gtest unit test to call this function";
264 string dir;
265 CHECK_OK(Env::Default()->GetTestDirectory(&dir));
266
267 // The directory name includes some strings for specific reasons:
268 // - program name: identifies the directory to the test invoker
269 // - timestamp and pid: disambiguates with prior runs of the same test
270 // - iteration: identifies the iteration when using --gtest_repeat
271 //
272 // e.g. "env-test.TestEnv.TestReadFully.1409169025392361-23600-0"
273 //
274 // If the test is sharded, the shard index is also included so that the test
275 // invoker can more easily identify all directories belonging to each shard.
276 string shard_index_infix;
277 const char* shard_index = getenv("GTEST_SHARD_INDEX");
278 if (shard_index && shard_index[0] != '\0') {
279 shard_index_infix = Substitute("$0.", shard_index);
280 }
281 dir += Substitute("/$0.$1$2.$3.$4-$5-$6",
282 StringReplace(google::ProgramInvocationShortName(), "/", "_", true),
283 shard_index_infix,
284 StringReplace(test_info->test_case_name(), "/", "_", true),
285 StringReplace(test_info->name(), "/", "_", true),
286 kTestBeganAtMicros,
287 getpid(),
288 testIteration);
289 Status s = Env::Default()->CreateDir(dir);
290 CHECK(s.IsAlreadyPresent() || s.ok())
291 << "Could not create directory " << dir << ": " << s.ToString();
292 if (s.ok()) {
293 string metadata;
294
295 StrAppend(&metadata, Substitute("PID=$0\n", getpid()));
296
297 StrAppend(&metadata, Substitute("PPID=$0\n", getppid()));
298
299 char* jenkins_build_id = getenv("BUILD_ID");
300 if (jenkins_build_id) {
301 StrAppend(&metadata, Substitute("BUILD_ID=$0\n", jenkins_build_id));
302 }
303
304 CHECK_OK(WriteStringToFile(Env::Default(), metadata,
305 Substitute("$0/test_metadata", dir)));
306 }
307 return dir;
308}
309
310string GetTestSocketPath(const string& name) {
311 string dir;

Callers 6

ConfigureTlsContextFunction · 0.85
TEST_PFunction · 0.85
TEST_FFunction · 0.85
KuduTestMethod · 0.85

Calls 10

DefaultClass · 0.85
SubstituteFunction · 0.85
StringReplaceFunction · 0.85
StrAppendFunction · 0.85
GetTestDirectoryMethod · 0.80
CreateDirMethod · 0.80
WriteStringToFileFunction · 0.70
nameMethod · 0.45
okMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected