aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/client_channel
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-11-28 13:23:36 -0800
committerGravatar Yash Tibrewal <yashkt@google.com>2017-11-28 13:23:36 -0800
commit81fc8c9c336fab7a71b448f748a32d680301277c (patch)
tree5cd64fd191db0f87d59ef53768c1b6760b4f1654 /test/core/client_channel
parent3285f4c7329bf4305133be74f88dd4b10d5e2052 (diff)
Fix tests to call grpc_init and grpc_shutdown before using exec_ctx
Diffstat (limited to 'test/core/client_channel')
-rw-r--r--test/core/client_channel/parse_address_test.cc4
-rw-r--r--test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc48
-rw-r--r--test/core/client_channel/uri_fuzzer_test.cc17
-rw-r--r--test/core/client_channel/uri_parser_test.cc3
4 files changed, 44 insertions, 28 deletions
diff --git a/test/core/client_channel/parse_address_test.cc b/test/core/client_channel/parse_address_test.cc
index f64b092743..21c86d01f1 100644
--- a/test/core/client_channel/parse_address_test.cc
+++ b/test/core/client_channel/parse_address_test.cc
@@ -24,6 +24,7 @@
#include <sys/un.h>
#endif
+#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h"
@@ -90,9 +91,12 @@ static void test_grpc_parse_ipv6(const char* uri_text, const char* host,
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_grpc_parse_unix("unix:/path/name", "/path/name");
test_grpc_parse_ipv4("ipv4:192.0.2.1:12345", "192.0.2.1", 12345);
test_grpc_parse_ipv6("ipv6:[2001:db8::1]:12345", "2001:db8::1", 12345, 0);
test_grpc_parse_ipv6("ipv6:[2001:db8::1%252]:12345", "2001:db8::1", 12345, 2);
+
+ grpc_shutdown();
}
diff --git a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
index 08ce148efe..f6d7731a6d 100644
--- a/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
+++ b/test/core/client_channel/resolvers/dns_resolver_connectivity_test.cc
@@ -147,29 +147,31 @@ int main(int argc, char** argv) {
grpc_dns_lookup_ares = my_dns_lookup_ares;
grpc_channel_args* result = (grpc_channel_args*)1;
- grpc_core::ExecCtx _local_exec_ctx;
- grpc_resolver* resolver = create_resolver("dns:test");
- gpr_event ev1;
- gpr_event_init(&ev1);
- call_resolver_next_after_locking(
- resolver, &result,
- GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx));
- grpc_core::ExecCtx::Get()->Flush();
- GPR_ASSERT(wait_loop(5, &ev1));
- GPR_ASSERT(result == nullptr);
-
- gpr_event ev2;
- gpr_event_init(&ev2);
- call_resolver_next_after_locking(
- resolver, &result,
- GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx));
- grpc_core::ExecCtx::Get()->Flush();
- GPR_ASSERT(wait_loop(30, &ev2));
- GPR_ASSERT(result != nullptr);
-
- grpc_channel_args_destroy(result);
- GRPC_RESOLVER_UNREF(resolver, "test");
- GRPC_COMBINER_UNREF(g_combiner, "test");
+ {
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_resolver* resolver = create_resolver("dns:test");
+ gpr_event ev1;
+ gpr_event_init(&ev1);
+ call_resolver_next_after_locking(
+ resolver, &result,
+ GRPC_CLOSURE_CREATE(on_done, &ev1, grpc_schedule_on_exec_ctx));
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(wait_loop(5, &ev1));
+ GPR_ASSERT(result == nullptr);
+
+ gpr_event ev2;
+ gpr_event_init(&ev2);
+ call_resolver_next_after_locking(
+ resolver, &result,
+ GRPC_CLOSURE_CREATE(on_done, &ev2, grpc_schedule_on_exec_ctx));
+ grpc_core::ExecCtx::Get()->Flush();
+ GPR_ASSERT(wait_loop(30, &ev2));
+ GPR_ASSERT(result != nullptr);
+
+ grpc_channel_args_destroy(result);
+ GRPC_RESOLVER_UNREF(resolver, "test");
+ GRPC_COMBINER_UNREF(g_combiner, "test");
+ }
grpc_shutdown();
gpr_mu_destroy(&g_mu);
diff --git a/test/core/client_channel/uri_fuzzer_test.cc b/test/core/client_channel/uri_fuzzer_test.cc
index 484676e472..8f1f5e2eda 100644
--- a/test/core/client_channel/uri_fuzzer_test.cc
+++ b/test/core/client_channel/uri_fuzzer_test.cc
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/filters/client_channel/uri_parser.h"
@@ -33,12 +34,18 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
memcpy(s, data, size);
s[size] = 0;
- grpc_core::ExecCtx _local_exec_ctx;
- grpc_uri* x;
- if ((x = grpc_uri_parse(s, 1))) {
- grpc_uri_destroy(x);
+ grpc_init();
+
+ {
+ grpc_core::ExecCtx _local_exec_ctx;
+ grpc_uri* x;
+ if ((x = grpc_uri_parse(s, 1))) {
+ grpc_uri_destroy(x);
+ }
+
+ gpr_free(s);
}
- gpr_free(s);
+ grpc_shutdown();
return 0;
}
diff --git a/test/core/client_channel/uri_parser_test.cc b/test/core/client_channel/uri_parser_test.cc
index 1694f2363d..33cf82d17c 100644
--- a/test/core/client_channel/uri_parser_test.cc
+++ b/test/core/client_channel/uri_parser_test.cc
@@ -20,6 +20,7 @@
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h"
@@ -119,6 +120,7 @@ static void test_query_parts() {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
+ grpc_init();
test_succeeds("http://www.google.com", "http", "www.google.com", "", "", "");
test_succeeds("dns:///foo", "dns", "", "/foo", "", "");
test_succeeds("http://www.google.com:90", "http", "www.google.com:90", "", "",
@@ -146,5 +148,6 @@ int main(int argc, char** argv) {
test_fails("http://foo?bar#lol#");
test_query_parts();
+ grpc_shutdown();
return 0;
}