From 818644c2a946a9d73262ca67b17b98d54856377f Mon Sep 17 00:00:00 2001 From: Derek Murray Date: Thu, 25 Feb 2016 11:12:03 -0800 Subject: Changed testing::SrcDir() to testing::TensorFlowSourceRoot() and fixed it. Also fixed some compiler warnings. Change: 115582482 --- tensorflow/core/platform/posix/test.cc | 14 +++++++++++++- tensorflow/core/platform/test.cc | 1 - tensorflow/core/platform/test.h | 5 +++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tensorflow/core/platform/posix/test.cc b/tensorflow/core/platform/posix/test.cc index 26218a4953..6f6d41f74f 100644 --- a/tensorflow/core/platform/posix/test.cc +++ b/tensorflow/core/platform/posix/test.cc @@ -45,7 +45,7 @@ class PosixSubProcess : public SubProcess { // We are in the child process. const char* path = argv_[0].c_str(); const char** argv = new const char*[argv_.size()]; - for (int i = 1; i < argv_.size(); ++i) { + for (size_t i = 1; i < argv_.size(); ++i) { argv[i - 1] = argv_[i].c_str(); } argv[argv_.size() - 1] = nullptr; @@ -177,5 +177,17 @@ int PickUnusedPortOrDie() { return 0; } +string TensorFlowSrcRoot() { + // 'bazel test' sets TEST_SRCDIR + const char* env = getenv("TEST_SRCDIR"); + if (env && env[0] != '\0') { + return strings::StrCat(env, "/tensorflow"); + } else { + LOG(WARNING) << "TEST_SRCDIR environment variable not set: " + << "using $PWD/tensorflow as TensorFlowSrcRoot() for tests."; + return "tensorflow"; + } +} + } // namespace testing } // namespace tensorflow diff --git a/tensorflow/core/platform/test.cc b/tensorflow/core/platform/test.cc index 020c50765f..5ac3b3e629 100644 --- a/tensorflow/core/platform/test.cc +++ b/tensorflow/core/platform/test.cc @@ -25,7 +25,6 @@ namespace testing { #if defined(PLATFORM_GOOGLE) || defined(__ANDROID__) string TmpDir() { return FLAGS_test_tmpdir; } -string SrcDir() { return FLAGS_test_srcdir; } int RandomSeed() { return FLAGS_test_random_seed; } #else string TmpDir() { diff --git a/tensorflow/core/platform/test.h b/tensorflow/core/platform/test.h index 73f2f1e272..9f63d8c777 100644 --- a/tensorflow/core/platform/test.h +++ b/tensorflow/core/platform/test.h @@ -35,8 +35,9 @@ namespace testing { // Return a temporary directory suitable for temporary testing files. string TmpDir(); -// Returns the source directory containing data dependencies. -string SrcDir(); +// Returns the path to TensorFlow in the directory containing data +// dependencies. +string TensorFlowSrcRoot(); // Return a random number generator seed to use in randomized tests. // Returns the same value for the lifetime of the process. -- cgit v1.2.3