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_CORE_PLATFORM_TEST_H_ 17 #define TENSORFLOW_CORE_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/types.h" 25 26 // As of September 2016, we continue to attempt to avoid the use of gmock aka 27 // googlemock included in the test framework 28 // (https://github.com/google/googletest) to discourage over-eager use of mocks 29 // that lead to cumbersome class hierarchies and tests that might end up not 30 // testing real code in important ways. 31 #if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID) 32 #include "tensorflow/core/platform/google/build_config/gunit.h" 33 #else 34 #include <gtest/gtest.h> 35 #endif 36 37 namespace tensorflow { 38 namespace testing { 39 40 // Return a temporary directory suitable for temporary testing files. 41 string TmpDir(); 42 43 // Returns the path to TensorFlow in the directory containing data 44 // dependencies. 45 string TensorFlowSrcRoot(); 46 47 // Return a random number generator seed to use in randomized tests. 48 // Returns the same value for the lifetime of the process. 49 int RandomSeed(); 50 51 // Returns an unused port number, for use in multi-process testing. 52 // NOTE: This function is not thread-safe. 53 int PickUnusedPortOrDie(); 54 55 } // namespace testing 56 } // namespace tensorflow 57 58 #endif // TENSORFLOW_CORE_PLATFORM_TEST_H_ 59