diff options
author | ncteisen <ncteisen@gmail.com> | 2017-11-20 10:50:38 -0500 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2017-11-20 10:56:04 -0500 |
commit | 993e9f06921123a9220031398ecfbf52a6114dce (patch) | |
tree | f15a85d3446e8a8495e8fb5b02a1f7c4aa26c6fc /test/core | |
parent | 46f9175ba3a27958a1655707d6014de1ba3ce4d5 (diff) | |
parent | 9addd2eef21a96e52135dc9369566d8452412763 (diff) |
Merge branch 'master' of https://github.com/grpc/grpc into no-more-extern-c
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/iomgr/timer_list_test.cc | 13 | ||||
-rw-r--r-- | test/core/transport/connectivity_state_test.cc | 3 | ||||
-rw-r--r-- | test/core/util/BUILD | 2 | ||||
-rw-r--r-- | test/core/util/tracer_util.cc | 31 | ||||
-rw-r--r-- | test/core/util/tracer_util.h | 32 |
5 files changed, 74 insertions, 7 deletions
diff --git a/test/core/iomgr/timer_list_test.cc b/test/core/iomgr/timer_list_test.cc index dc965ef7dc..d74ea4fc96 100644 --- a/test/core/iomgr/timer_list_test.cc +++ b/test/core/iomgr/timer_list_test.cc @@ -28,11 +28,12 @@ #include <grpc/support/log.h> #include "src/core/lib/debug/trace.h" #include "test/core/util/test_config.h" +#include "test/core/util/tracer_util.h" #define MAX_CB 30 -extern "C" grpc_tracer_flag grpc_timer_trace; -extern "C" grpc_tracer_flag grpc_timer_check_trace; +extern grpc_core::TraceFlag grpc_timer_trace; +extern grpc_core::TraceFlag grpc_timer_check_trace; static int cb_called[MAX_CB][2]; @@ -48,8 +49,8 @@ static void add_test(void) { gpr_log(GPR_INFO, "add_test"); grpc_timer_list_init(&exec_ctx); - grpc_timer_trace.value = 1; - grpc_timer_check_trace.value = 1; + grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_trace); + grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_check_trace); memset(cb_called, 0, sizeof(cb_called)); grpc_millis start = grpc_exec_ctx_now(&exec_ctx); @@ -117,8 +118,8 @@ void destruction_test(void) { exec_ctx.now_is_valid = true; exec_ctx.now = 0; grpc_timer_list_init(&exec_ctx); - grpc_timer_trace.value = 1; - grpc_timer_check_trace.value = 1; + grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_trace); + grpc_core::testing::grpc_tracer_enable_flag(&grpc_timer_check_trace); memset(cb_called, 0, sizeof(cb_called)); grpc_timer_init( diff --git a/test/core/transport/connectivity_state_test.cc b/test/core/transport/connectivity_state_test.cc index 7a22ec848d..11046e126e 100644 --- a/test/core/transport/connectivity_state_test.cc +++ b/test/core/transport/connectivity_state_test.cc @@ -23,6 +23,7 @@ #include <grpc/support/log.h> #include "test/core/util/test_config.h" +#include "test/core/util/tracer_util.h" #define THE_ARG ((void*)(size_t)0xcafebabe) @@ -136,7 +137,7 @@ static void test_subscribe_with_failure_then_destroy(void) { int main(int argc, char** argv) { grpc_test_init(argc, argv); - grpc_connectivity_state_trace.value = 1; + grpc_core::testing::grpc_tracer_enable_flag(&grpc_connectivity_state_trace); test_connectivity_state_name(); test_check(); test_subscribe_then_unsubscribe(); diff --git a/test/core/util/BUILD b/test/core/util/BUILD index 2437923435..6443553466 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -57,6 +57,7 @@ grpc_cc_library( "reconnect_server.cc", "slice_splitter.cc", "test_tcp_server.cc", + "tracer_util.cc", "trickle_endpoint.cc", ], hdrs = [ @@ -69,6 +70,7 @@ grpc_cc_library( "reconnect_server.h", "slice_splitter.h", "test_tcp_server.h", + "tracer_util.h", "trickle_endpoint.h", ], language = "C++", diff --git a/test/core/util/tracer_util.cc b/test/core/util/tracer_util.cc new file mode 100644 index 0000000000..34a132daa7 --- /dev/null +++ b/test/core/util/tracer_util.cc @@ -0,0 +1,31 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "test/core/util/test_config.h" + +#include "src/core/lib/debug/trace.h" + +namespace grpc_core { +namespace testing { + +void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag) { + flag->set_enabled(1); +} + +} // namespace testing +} // namespace grpc_core diff --git a/test/core/util/tracer_util.h b/test/core/util/tracer_util.h new file mode 100644 index 0000000000..0b432ffa46 --- /dev/null +++ b/test/core/util/tracer_util.h @@ -0,0 +1,32 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_TEST_CORE_UTIL_TRACER_UTIL_H +#define GRPC_TEST_CORE_UTIL_TRACER_UTIL_H + +namespace grpc_core { +class TraceFlag; + +namespace testing { +// enables the TraceFlag passed to it. Used for testing purposes. +void grpc_tracer_enable_flag(grpc_core::TraceFlag* flag); + +} // namespace testing +} // namespace grpc_core + +#endif /* GRPC_TEST_CORE_UTIL_TRACER_UTIL_H */ |