diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-11-16 19:31:28 -0800 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2017-11-16 19:31:28 -0800 |
commit | 177039b2f89e73ad0d048da021f939f3a153c4e2 (patch) | |
tree | c7f10f04cd9a0872863e2b181162bc9928160cd8 /test/core/util | |
parent | 995aa91bbbc68deb6dfd7c667cfee3af2bedec08 (diff) | |
parent | 82c8f945302f128495e261b853ac49f1dfbe69a1 (diff) |
Merge master
Diffstat (limited to 'test/core/util')
-rw-r--r-- | test/core/util/BUILD | 1 | ||||
-rw-r--r-- | test/core/util/debugger_macros.cc | 6 | ||||
-rw-r--r-- | test/core/util/fuzzer_corpus_test.cc | 11 | ||||
-rw-r--r-- | test/core/util/memory_counters.cc | 8 | ||||
-rw-r--r-- | test/core/util/mock_endpoint.cc | 8 | ||||
-rw-r--r-- | test/core/util/parse_hexstring.cc | 2 | ||||
-rw-r--r-- | test/core/util/passthru_endpoint.cc | 14 | ||||
-rw-r--r-- | test/core/util/port.cc | 10 | ||||
-rw-r--r-- | test/core/util/port_server_client.cc | 10 | ||||
-rw-r--r-- | test/core/util/reconnect_server.cc | 18 | ||||
-rw-r--r-- | test/core/util/slice_splitter.cc | 2 | ||||
-rw-r--r-- | test/core/util/test_config.cc | 18 | ||||
-rw-r--r-- | test/core/util/test_tcp_server.cc | 10 | ||||
-rw-r--r-- | test/core/util/trickle_endpoint.cc | 11 |
14 files changed, 69 insertions, 60 deletions
diff --git a/test/core/util/BUILD b/test/core/util/BUILD index bc6fe9dd64..2437923435 100644 --- a/test/core/util/BUILD +++ b/test/core/util/BUILD @@ -103,6 +103,7 @@ grpc_cc_library( grpc_cc_library( name = "fuzzer_corpus_test", + testonly = 1, srcs = ["fuzzer_corpus_test.cc"], deps = [ ":gpr_test_util", diff --git a/test/core/util/debugger_macros.cc b/test/core/util/debugger_macros.cc index d344c3fb74..f1e4ffd3af 100644 --- a/test/core/util/debugger_macros.cc +++ b/test/core/util/debugger_macros.cc @@ -37,16 +37,16 @@ grpc_stream* grpc_transport_stream_from_call(grpc_call* call) { grpc_call_element* el = grpc_call_stack_element(cs, cs->count - 1); if (el->filter == &grpc_client_channel_filter) { grpc_subchannel_call* scc = grpc_client_channel_get_subchannel_call(el); - if (scc == NULL) { + if (scc == nullptr) { fprintf(stderr, "No subchannel-call"); - return NULL; + return nullptr; } cs = grpc_subchannel_call_get_call_stack(scc); } else if (el->filter == &grpc_connected_filter) { return grpc_connected_channel_get_stream(el); } else { fprintf(stderr, "Unrecognized filter: %s", el->filter->name); - return NULL; + return nullptr; } } } diff --git a/test/core/util/fuzzer_corpus_test.cc b/test/core/util/fuzzer_corpus_test.cc index a5e99a1bac..d7aea54262 100644 --- a/test/core/util/fuzzer_corpus_test.cc +++ b/test/core/util/fuzzer_corpus_test.cc @@ -32,6 +32,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); extern "C" bool squelch; extern "C" bool leak_check; +// In some distros, gflags is in the namespace google, and in some others, +// in gflags. This hack is enabling us to find both. +namespace google {} +namespace gflags {} +using namespace google; +using namespace gflags; + DEFINE_string(file, "", "Use this file as test data"); DEFINE_string(directory, "", "Use this directory as test data"); @@ -65,7 +72,7 @@ class ExampleGenerator struct dirent* ep; dp = opendir(FLAGS_directory.c_str()); - if (dp != NULL) { + if (dp != nullptr) { while ((ep = readdir(dp)) != nullptr) { if (ep->d_type == DT_REG) { examples_.push_back(FLAGS_directory + "/" + ep->d_name); @@ -129,7 +136,7 @@ INSTANTIATE_TEST_CASE_P( int main(int argc, char** argv) { grpc_test_init(argc, argv); - ::gflags::ParseCommandLineFlags(&argc, &argv, true); + ParseCommandLineFlags(&argc, &argv, true); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/test/core/util/memory_counters.cc b/test/core/util/memory_counters.cc index ff85a63803..32d7b89c9a 100644 --- a/test/core/util/memory_counters.cc +++ b/test/core/util/memory_counters.cc @@ -43,7 +43,7 @@ static void guard_free(void* vptr); static void* guard_malloc(size_t size) { size_t* ptr; - if (!size) return NULL; + if (!size) return nullptr; NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size); NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1); @@ -55,12 +55,12 @@ static void* guard_malloc(size_t size) { static void* guard_realloc(void* vptr, size_t size) { size_t* ptr = (size_t*)vptr; - if (vptr == NULL) { + if (vptr == nullptr) { return guard_malloc(size); } if (size == 0) { guard_free(vptr); - return NULL; + return nullptr; } --ptr; NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)size); @@ -81,7 +81,7 @@ static void guard_free(void* vptr) { g_old_allocs.free_fn(ptr); } -struct gpr_allocation_functions g_guard_allocs = {guard_malloc, NULL, +struct gpr_allocation_functions g_guard_allocs = {guard_malloc, nullptr, guard_realloc, guard_free}; void grpc_memory_counters_init() { diff --git a/test/core/util/mock_endpoint.cc b/test/core/util/mock_endpoint.cc index fd9e82c30b..4b35a581b1 100644 --- a/test/core/util/mock_endpoint.cc +++ b/test/core/util/mock_endpoint.cc @@ -78,7 +78,7 @@ static void me_shutdown(grpc_endpoint* ep, grpc_error* why) { GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING( "Endpoint Shutdown", &why, 1)); - m->on_read = NULL; + m->on_read = nullptr; } gpr_mu_unlock(&m->mu); grpc_resource_user_shutdown(m->resource_user); @@ -127,17 +127,17 @@ grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), grpc_slice_buffer_init(&m->read_buffer); gpr_mu_init(&m->mu); m->on_write = on_write; - m->on_read = NULL; + m->on_read = nullptr; return &m->base; } void grpc_mock_endpoint_put_read(grpc_endpoint* ep, grpc_slice slice) { grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; gpr_mu_lock(&m->mu); - if (m->on_read != NULL) { + if (m->on_read != nullptr) { grpc_slice_buffer_add(m->on_read_out, slice); GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE); - m->on_read = NULL; + m->on_read = nullptr; } else { grpc_slice_buffer_add(&m->read_buffer, slice); } diff --git a/test/core/util/parse_hexstring.cc b/test/core/util/parse_hexstring.cc index 6dee0f163a..622642a298 100644 --- a/test/core/util/parse_hexstring.cc +++ b/test/core/util/parse_hexstring.cc @@ -21,7 +21,7 @@ grpc_slice parse_hexstring(const char* hexstring) { size_t nibbles = 0; - const char* p = 0; + const char* p = nullptr; uint8_t* out; uint8_t temp; grpc_slice slice; diff --git a/test/core/util/passthru_endpoint.cc b/test/core/util/passthru_endpoint.cc index bb8cbb62bf..5f127cb960 100644 --- a/test/core/util/passthru_endpoint.cc +++ b/test/core/util/passthru_endpoint.cc @@ -49,7 +49,7 @@ struct passthru_endpoint { int halves; grpc_passthru_endpoint_stats* stats; grpc_passthru_endpoint_stats - dummy_stats; // used if constructor stats == NULL + dummy_stats; // used if constructor stats == nullptr bool shutdown; half client; half server; @@ -85,12 +85,12 @@ static void me_write(grpc_endpoint* ep, grpc_slice_buffer* slices, gpr_atm_no_barrier_fetch_add(&m->parent->stats->num_writes, (gpr_atm)1); if (m->parent->shutdown) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown"); - } else if (m->on_read != NULL) { + } else if (m->on_read != nullptr) { for (size_t i = 0; i < slices->count; i++) { grpc_slice_buffer_add(m->on_read_out, grpc_slice_copy(slices->slices[i])); } GRPC_CLOSURE_SCHED(m->on_read, GRPC_ERROR_NONE); - m->on_read = NULL; + m->on_read = nullptr; } else { for (size_t i = 0; i < slices->count; i++) { grpc_slice_buffer_add(&m->read_buffer, @@ -117,14 +117,14 @@ static void me_shutdown(grpc_endpoint* ep, grpc_error* why) { GRPC_CLOSURE_SCHED( m->on_read, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1)); - m->on_read = NULL; + m->on_read = nullptr; } m = other_half(m); if (m->on_read) { GRPC_CLOSURE_SCHED( m->on_read, GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING("Shutdown", &why, 1)); - m->on_read = NULL; + m->on_read = nullptr; } gpr_mu_unlock(&m->parent->mu); grpc_resource_user_shutdown(m->resource_user); @@ -179,7 +179,7 @@ static void half_init(half* m, passthru_endpoint* parent, m->base.vtable = &vtable; m->parent = parent; grpc_slice_buffer_init(&m->read_buffer); - m->on_read = NULL; + m->on_read = nullptr; char* name; gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name, (intptr_t)parent); @@ -194,7 +194,7 @@ void grpc_passthru_endpoint_create(grpc_endpoint** client, passthru_endpoint* m = (passthru_endpoint*)gpr_malloc(sizeof(*m)); m->halves = 2; m->shutdown = 0; - m->stats = stats == NULL ? &m->dummy_stats : stats; + m->stats = stats == nullptr ? &m->dummy_stats : stats; memset(m->stats, 0, sizeof(*m->stats)); half_init(&m->client, m, resource_quota, "client"); half_init(&m->server, m, resource_quota, "server"); diff --git a/test/core/util/port.cc b/test/core/util/port.cc index c5bebe08e7..9d02b673ed 100644 --- a/test/core/util/port.cc +++ b/test/core/util/port.cc @@ -36,7 +36,7 @@ #include "src/core/lib/iomgr/sockaddr_utils.h" #include "test/core/util/port_server_client.h" -static int* chosen_ports = NULL; +static int* chosen_ports = nullptr; static size_t num_chosen_ports = 0; static int free_chosen_port(int port) { @@ -71,7 +71,7 @@ static void free_chosen_ports(void) { } static void chose_port(int port) { - if (chosen_ports == NULL) { + if (chosen_ports == nullptr) { atexit(free_chosen_ports); } num_chosen_ports++; @@ -123,9 +123,9 @@ void grpc_recycle_unused_port(int port) { } void grpc_set_pick_port_functions(grpc_pick_port_functions functions) { - GPR_ASSERT(functions.pick_unused_port_fn != NULL); - GPR_ASSERT(functions.pick_unused_port_or_die_fn != NULL); - GPR_ASSERT(functions.recycle_unused_port_fn != NULL); + GPR_ASSERT(functions.pick_unused_port_fn != nullptr); + GPR_ASSERT(functions.pick_unused_port_or_die_fn != nullptr); + GPR_ASSERT(functions.recycle_unused_port_fn != nullptr); g_pick_port_functions = functions; } diff --git a/test/core/util/port_server_client.cc b/test/core/util/port_server_client.cc index 8e61145a26..7efa951862 100644 --- a/test/core/util/port_server_client.cc +++ b/test/core/util/port_server_client.cc @@ -52,7 +52,7 @@ static void freed_port_from_server(void* arg, grpc_error* error) { pr->done = 1; GRPC_LOG_IF_ERROR( "pollset_kick", - grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), NULL)); + grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr)); gpr_mu_unlock(pr->mu); } @@ -93,7 +93,7 @@ void grpc_free_port_using_server(int port) { grpc_core::ExecCtx::Get()->Flush(); gpr_mu_lock(pr.mu); while (!pr.done) { - grpc_pollset_worker* worker = NULL; + grpc_pollset_worker* worker = nullptr; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work( @@ -150,7 +150,7 @@ static void got_port_from_server(void* arg, grpc_error* error) { pr->port = 0; GRPC_LOG_IF_ERROR( "pollset_kick", - grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), NULL)); + grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr)); gpr_mu_unlock(pr->mu); return; } @@ -186,7 +186,7 @@ static void got_port_from_server(void* arg, grpc_error* error) { pr->port = port; GRPC_LOG_IF_ERROR( "pollset_kick", - grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), NULL)); + grpc_pollset_kick(grpc_polling_entity_pollset(&pr->pops), nullptr)); gpr_mu_unlock(pr->mu); } @@ -225,7 +225,7 @@ int grpc_pick_port_using_server(void) { grpc_core::ExecCtx::Get()->Flush(); gpr_mu_lock(pr.mu); while (pr.port == -1) { - grpc_pollset_worker* worker = NULL; + grpc_pollset_worker* worker = nullptr; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work( diff --git a/test/core/util/reconnect_server.cc b/test/core/util/reconnect_server.cc index 0e4145831c..bcafc4e898 100644 --- a/test/core/util/reconnect_server.cc +++ b/test/core/util/reconnect_server.cc @@ -70,10 +70,10 @@ static void on_connect(void* arg, grpc_endpoint* tcp, grpc_endpoint_destroy(tcp); if (peer) { last_colon = strrchr(peer, ':'); - if (server->peer == NULL) { + if (server->peer == nullptr) { server->peer = peer; } else { - if (last_colon == NULL) { + if (last_colon == nullptr) { gpr_log(GPR_ERROR, "peer does not contain a ':'"); } else if (strncmp(server->peer, peer, (size_t)(last_colon - peer)) != 0) { @@ -84,8 +84,8 @@ static void on_connect(void* arg, grpc_endpoint* tcp, } new_tail = static_cast<timestamp_list*>(gpr_malloc(sizeof(timestamp_list))); new_tail->timestamp = now; - new_tail->next = NULL; - if (server->tail == NULL) { + new_tail->next = nullptr; + if (server->tail == nullptr) { server->head = new_tail; server->tail = new_tail; } else { @@ -97,9 +97,9 @@ static void on_connect(void* arg, grpc_endpoint* tcp, void reconnect_server_init(reconnect_server* server) { test_tcp_server_init(&server->tcp_server, on_connect, server); - server->head = NULL; - server->tail = NULL; - server->peer = NULL; + server->head = nullptr; + server->tail = nullptr; + server->peer = nullptr; server->max_reconnect_backoff_ms = 0; } @@ -118,9 +118,9 @@ void reconnect_server_clear_timestamps(reconnect_server* server) { gpr_free(server->head); server->head = new_head; } - server->tail = NULL; + server->tail = nullptr; gpr_free(server->peer); - server->peer = NULL; + server->peer = nullptr; } void reconnect_server_destroy(reconnect_server* server) { diff --git a/test/core/util/slice_splitter.cc b/test/core/util/slice_splitter.cc index e25e1d862a..7225b6dc03 100644 --- a/test/core/util/slice_splitter.cc +++ b/test/core/util/slice_splitter.cc @@ -105,7 +105,7 @@ void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, } grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices) { - uint8_t* out = NULL; + uint8_t* out = nullptr; size_t length = 0; size_t capacity = 0; size_t i; diff --git a/test/core/util/test_config.cc b/test/core/util/test_config.cc index 3106fb01ea..9ebb52d83e 100644 --- a/test/core/util/test_config.cc +++ b/test/core/util/test_config.cc @@ -203,7 +203,7 @@ static void install_crash_handler() { #define SIGNAL_NAMES_LENGTH 32 static const char* const signal_names[] = { - NULL, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", + nullptr, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD", "SIGCONT", "SIGSTOP", "SIGTSTP", "SIGTTIN", "SIGTTOU", "SIGURG", @@ -263,15 +263,15 @@ static void install_crash_handler() { memset(&sa, 0, sizeof(sa)); ss.ss_size = sizeof(g_alt_stack); ss.ss_sp = g_alt_stack; - GPR_ASSERT(sigaltstack(&ss, NULL) == 0); + GPR_ASSERT(sigaltstack(&ss, nullptr) == 0); sa.sa_flags = (int)(SA_SIGINFO | SA_ONSTACK | SA_RESETHAND); sa.sa_sigaction = crash_handler; - GPR_ASSERT(sigaction(SIGILL, &sa, NULL) == 0); - GPR_ASSERT(sigaction(SIGABRT, &sa, NULL) == 0); - GPR_ASSERT(sigaction(SIGBUS, &sa, NULL) == 0); - GPR_ASSERT(sigaction(SIGSEGV, &sa, NULL) == 0); - GPR_ASSERT(sigaction(SIGTERM, &sa, NULL) == 0); - GPR_ASSERT(sigaction(SIGQUIT, &sa, NULL) == 0); + GPR_ASSERT(sigaction(SIGILL, &sa, nullptr) == 0); + GPR_ASSERT(sigaction(SIGABRT, &sa, nullptr) == 0); + GPR_ASSERT(sigaction(SIGBUS, &sa, nullptr) == 0); + GPR_ASSERT(sigaction(SIGSEGV, &sa, nullptr) == 0); + GPR_ASSERT(sigaction(SIGTERM, &sa, nullptr) == 0); + GPR_ASSERT(sigaction(SIGQUIT, &sa, nullptr) == 0); } #else static void install_crash_handler() {} @@ -380,7 +380,7 @@ void grpc_test_init(int argc, char** argv) { install_crash_handler(); { /* poll-cv poll strategy runs much more slowly than anything else */ char* s = gpr_getenv("GRPC_POLL_STRATEGY"); - if (s != NULL && 0 == strcmp(s, "poll-cv")) { + if (s != nullptr && 0 == strcmp(s, "poll-cv")) { g_poller_slowdown_factor = 5; } gpr_free(s); diff --git a/test/core/util/test_tcp_server.cc b/test/core/util/test_tcp_server.cc index 6418a7dfaa..71e6f3af2c 100644 --- a/test/core/util/test_tcp_server.cc +++ b/test/core/util/test_tcp_server.cc @@ -41,7 +41,7 @@ static void on_server_destroyed(void* data, grpc_error* error) { void test_tcp_server_init(test_tcp_server* server, grpc_tcp_server_cb on_connect, void* user_data) { grpc_init(); - server->tcp_server = NULL; + server->tcp_server = nullptr; GRPC_CLOSURE_INIT(&server->shutdown_complete, on_server_destroyed, server, grpc_schedule_on_exec_ctx); server->shutdown = 0; @@ -61,8 +61,8 @@ void test_tcp_server_start(test_tcp_server* server, int port) { addr->sin_port = htons((uint16_t)port); memset(&addr->sin_addr, 0, sizeof(addr->sin_addr)); - grpc_error* error = grpc_tcp_server_create(&server->shutdown_complete, NULL, - &server->tcp_server); + grpc_error* error = grpc_tcp_server_create(&server->shutdown_complete, + nullptr, &server->tcp_server); GPR_ASSERT(error == GRPC_ERROR_NONE); error = grpc_tcp_server_add_port(server->tcp_server, &resolved_addr, &port_added); @@ -75,7 +75,7 @@ void test_tcp_server_start(test_tcp_server* server, int port) { } void test_tcp_server_poll(test_tcp_server* server, int seconds) { - grpc_pollset_worker* worker = NULL; + grpc_pollset_worker* worker = nullptr; grpc_core::ExecCtx _local_exec_ctx; grpc_millis deadline = grpc_timespec_to_millis_round_up( grpc_timeout_seconds_to_deadline(seconds)); @@ -95,7 +95,7 @@ void test_tcp_server_destroy(test_tcp_server* server) { gpr_timespec shutdown_deadline; grpc_closure do_nothing_cb; grpc_tcp_server_unref(server->tcp_server); - GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, NULL, + GRPC_CLOSURE_INIT(&do_nothing_cb, do_nothing, nullptr, grpc_schedule_on_exec_ctx); shutdown_deadline = gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), gpr_time_from_seconds(5, GPR_TIMESPAN)); diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc index 763e684237..f95ed62463 100644 --- a/test/core/util/trickle_endpoint.cc +++ b/test/core/util/trickle_endpoint.cc @@ -52,10 +52,11 @@ static void te_read(grpc_endpoint* ep, grpc_slice_buffer* slices, } static void maybe_call_write_cb_locked(trickle_endpoint* te) { - if (te->write_cb != NULL && (te->error != GRPC_ERROR_NONE || - te->write_buffer.length <= WRITE_BUFFER_SIZE)) { + if (te->write_cb != nullptr && + (te->error != GRPC_ERROR_NONE || + te->write_buffer.length <= WRITE_BUFFER_SIZE)) { GRPC_CLOSURE_SCHED(te->write_cb, GRPC_ERROR_REF(te->error)); - te->write_cb = NULL; + te->write_cb = nullptr; } } @@ -63,7 +64,7 @@ static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb) { trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); - GPR_ASSERT(te->write_cb == NULL); + GPR_ASSERT(te->write_cb == nullptr); if (te->write_buffer.length == 0) { te->last_write = gpr_now(GPR_CLOCK_MONOTONIC); } @@ -154,7 +155,7 @@ grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap, te->base.vtable = &vtable; te->wrapped = wrap; te->bytes_per_second = bytes_per_second; - te->write_cb = NULL; + te->write_cb = nullptr; gpr_mu_init(&te->mu); grpc_slice_buffer_init(&te->write_buffer); grpc_slice_buffer_init(&te->writing_buffer); |