diff options
author | Manjunath Kudlur <keveman@gmail.com> | 2015-11-06 16:27:58 -0800 |
---|---|---|
committer | Manjunath Kudlur <keveman@gmail.com> | 2015-11-06 16:27:58 -0800 |
commit | f41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch) | |
tree | ef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/core/platform/test.cc |
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation
using data flow graphs.
Base CL: 107276108
Diffstat (limited to 'tensorflow/core/platform/test.cc')
-rw-r--r-- | tensorflow/core/platform/test.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tensorflow/core/platform/test.cc b/tensorflow/core/platform/test.cc new file mode 100644 index 0000000000..21c6905683 --- /dev/null +++ b/tensorflow/core/platform/test.cc @@ -0,0 +1,39 @@ +#include "tensorflow/core/platform/port.h" + +#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_POSIX_ANDROID) || \ + defined(PLATFORM_GOOGLE_ANDROID) +#include "testing/base/public/googletest.h" +#endif + +namespace tensorflow { +namespace testing { + +#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_POSIX_ANDROID) || \ + defined(PLATFORM_GOOGLE_ANDROID) +string TmpDir() { return FLAGS_test_tmpdir; } +int RandomSeed() { return FLAGS_test_random_seed; } +#else +string TmpDir() { + // 'bazel test' sets TEST_TMPDIR + const char* env = getenv("TEST_TMPDIR"); + if (env && env[0] != '\0') { + return env; + } + env = getenv("TMPDIR"); + if (env && env[0] != '\0') { + return env; + } + return "/tmp"; +} +int RandomSeed() { + const char* env = getenv("TEST_RANDOM_SEED"); + int result; + if (env && sscanf(env, "%d", &result) == 1) { + return result; + } + return 301; +} +#endif + +} // namespace testing +} // namespace tensorflow |