Home | History | Annotate | Download | only in platform
      1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #include "tensorflow/core/platform/types.h"
     17 
     18 #if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID)
     19 #include "tensorflow/core/platform/google/build_config/googletest.h"
     20 #endif
     21 
     22 #include <cstdlib>
     23 #include <iostream>
     24 
     25 namespace tensorflow {
     26 namespace testing {
     27 
     28 #if defined(PLATFORM_GOOGLE)
     29 string TmpDir() { return FLAGS_test_tmpdir; }
     30 int RandomSeed() { return FLAGS_test_random_seed; }
     31 #else
     32 string TmpDir() {
     33   // 'bazel test' sets TEST_TMPDIR
     34   const char* env = getenv("TEST_TMPDIR");
     35   if (env && env[0] != '\0') {
     36     return env;
     37   }
     38   env = getenv("TMPDIR");
     39   if (env && env[0] != '\0') {
     40     return env;
     41   }
     42   return "/tmp";
     43 }
     44 string SrcDir() {
     45   // Bazel makes data dependencies available via a relative path.
     46   return "";
     47 }
     48 int RandomSeed() {
     49   const char* env = getenv("TEST_RANDOM_SEED");
     50   int result;
     51   if (env && sscanf(env, "%d", &result) == 1) {
     52     return result;
     53   }
     54   return 301;
     55 }
     56 #endif
     57 
     58 }  // namespace testing
     59 }  // namespace tensorflow
     60