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 #ifndef TENSORFLOW_PLATFORM_TEST_H_
     17 #define TENSORFLOW_PLATFORM_TEST_H_
     18 
     19 #include <memory>
     20 #include <vector>
     21 
     22 #include "tensorflow/core/platform/macros.h"
     23 #include "tensorflow/core/platform/platform.h"
     24 #include "tensorflow/core/platform/subprocess.h"
     25 #include "tensorflow/core/platform/types.h"
     26 
     27 // As of September 2016, we continue to attempt to avoid the use of gmock aka
     28 // googlemock included in the test framework
     29 // (https://github.com/google/googletest) to discourage over-eager use of mocks
     30 // that lead to cumbersome class hierarchies and tests that might end up not
     31 // testing real code in important ways.
     32 #if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID)
     33 #include "tensorflow/core/platform/google/build_config/gunit.h"
     34 #else
     35 #include <gtest/gtest.h>
     36 #endif
     37 
     38 namespace tensorflow {
     39 namespace testing {
     40 
     41 // Return a temporary directory suitable for temporary testing files.
     42 string TmpDir();
     43 
     44 // Returns the path to TensorFlow in the directory containing data
     45 // dependencies.
     46 string TensorFlowSrcRoot();
     47 
     48 // Return a random number generator seed to use in randomized tests.
     49 // Returns the same value for the lifetime of the process.
     50 int RandomSeed();
     51 
     52 // Returns an object that represents a child process that will be
     53 // launched with the given command-line arguments `argv`. The process
     54 // must be explicitly started by calling the Start() method on the
     55 // returned object.
     56 std::unique_ptr<SubProcess> CreateSubProcess(const std::vector<string>& argv);
     57 
     58 // Returns an unused port number, for use in multi-process testing.
     59 // NOTE: This function is not thread-safe.
     60 int PickUnusedPortOrDie();
     61 
     62 }  // namespace testing
     63 }  // namespace tensorflow
     64 
     65 #endif  // TENSORFLOW_PLATFORM_TEST_H_
     66