From 2a938b0006c098cba1c559afacdd311c55afa723 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 30 Nov 2018 08:53:08 -0800 Subject: Add a class to wrap grpc_test_init --- test/core/util/test_config.cc | 12 ++++++++++++ test/core/util/test_config.h | 15 +++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 6a0d444a73..115d89b6b4 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -397,3 +397,15 @@ void grpc_test_init(int argc, char** argv) { concurrently running test binary */ srand(seed()); } + +namespace grpc { +namespace testing { + +TestEnvironment::TestEnvironment(int argc, char **argv) { + grpc_test_init(argc, argv); +} + +TestEnvironment::~TestEnvironment() {} + +} // namespace testing +} // namespace grpc diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 5b3d34799e..a8a2d32aaf 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -37,6 +37,21 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); #define GRPC_TEST_PICK_PORT #endif +// Prefer TestEnvironment below. void grpc_test_init(int argc, char** argv); +namespace grpc { +namespace testing { + +// A TestEnvironment object should be alive in the main function of a test. It +// provides test init and shutdown inside. +class TestEnvironment { +public: + TestEnvironment(int argc, char **argv); + ~TestEnvironment(); +}; + +} // namespace testing +} // namespace grpc + #endif /* GRPC_TEST_CORE_UTIL_TEST_CONFIG_H */ -- cgit v1.2.3