aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar yang-g <yangg@google.com>2018-11-30 08:53:08 -0800
committerGravatar yang-g <yangg@google.com>2018-11-30 08:53:08 -0800
commit2a938b0006c098cba1c559afacdd311c55afa723 (patch)
tree9e1e6ea5479c696d9b49ec3f36553bfa6bc1b536 /test/core
parent7ef8fc826c52b0c4abeaead633d464197fc0bdf8 (diff)
Add a class to wrap grpc_test_init
Diffstat (limited to 'test/core')
-rw-r--r--test/core/util/test_config.cc12
-rw-r--r--test/core/util/test_config.h15
2 files changed, 27 insertions, 0 deletions
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 */