1 /* 2 * 3 * Copyright 2015 gRPC authors. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #ifndef GRPC_TEST_CORE_UTIL_TEST_CONFIG_H 20 #define GRPC_TEST_CORE_UTIL_TEST_CONFIG_H 21 22 #include <grpc/support/time.h> 23 24 extern int64_t g_fixture_slowdown_factor; 25 extern int64_t g_poller_slowdown_factor; 26 27 /* Returns an appropriate scaling factor for timeouts. */ 28 int64_t grpc_test_slowdown_factor(); 29 30 /* Converts a given timeout (in seconds) to a deadline. */ 31 gpr_timespec grpc_timeout_seconds_to_deadline(int64_t time_s); 32 33 /* Converts a given timeout (in milliseconds) to a deadline. */ 34 gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); 35 36 #if !defined(GRPC_TEST_CUSTOM_PICK_PORT) && !defined(GRPC_PORT_ISOLATED_RUNTIME) 37 #define GRPC_TEST_PICK_PORT 38 #endif 39 40 // Prefer TestEnvironment below. 41 void grpc_test_init(int argc, char** argv); 42 43 namespace grpc { 44 namespace testing { 45 46 // A TestEnvironment object should be alive in the main function of a test. It 47 // provides test init and shutdown inside. 48 class TestEnvironment { 49 public: 50 TestEnvironment(int argc, char** argv); 51 ~TestEnvironment(); 52 }; 53 54 } // namespace testing 55 } // namespace grpc 56 57 #endif /* GRPC_TEST_CORE_UTIL_TEST_CONFIG_H */ 58