diff options
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/end2end/tests/filter_status_code.cc | 53 | ||||
-rw-r--r-- | test/core/fling/client.cc | 2 | ||||
-rw-r--r-- | test/core/iomgr/udp_server_test.cc | 23 | ||||
-rw-r--r-- | test/core/network_benchmarks/low_level_ping_pong.cc | 4 | ||||
-rw-r--r-- | test/core/security/create_jwt.cc | 5 | ||||
-rw-r--r-- | test/core/security/print_google_default_creds_token.cc | 2 | ||||
-rw-r--r-- | test/core/security/verify_jwt.cc | 2 | ||||
-rw-r--r-- | test/core/support/cpu_test.cc | 3 | ||||
-rw-r--r-- | test/core/support/spinlock_test.cc | 4 | ||||
-rw-r--r-- | test/core/support/sync_test.cc | 8 | ||||
-rw-r--r-- | test/core/support/time_test.cc | 11 | ||||
-rw-r--r-- | test/core/util/debugger_macros.cc | 2 |
12 files changed, 95 insertions, 24 deletions
diff --git a/test/core/end2end/tests/filter_status_code.cc b/test/core/end2end/tests/filter_status_code.cc index 261ddd93ec..61c658b95a 100644 --- a/test/core/end2end/tests/filter_status_code.cc +++ b/test/core/end2end/tests/filter_status_code.cc @@ -30,11 +30,14 @@ #include <grpc/support/useful.h> #include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/surface/call.h" #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" static bool g_enable_filter = false; static gpr_mu g_mu; +static grpc_call_stack* g_client_call_stack; +static grpc_call_stack* g_server_call_stack; static bool g_client_code_recv; static bool g_server_code_recv; static gpr_cv g_client_code_cv; @@ -117,6 +120,8 @@ static void test_request(grpc_end2end_test_config config) { int was_cancelled = 2; gpr_mu_lock(&g_mu); + g_client_call_stack = nullptr; + g_server_call_stack = nullptr; g_client_status_code = GRPC_STATUS_OK; g_server_status_code = GRPC_STATUS_OK; gpr_mu_unlock(&g_mu); @@ -127,6 +132,9 @@ static void test_request(grpc_end2end_test_config config) { grpc_slice_from_static_string("/foo"), get_host_override_slice("foo.test.google.fr", config), deadline, nullptr); GPR_ASSERT(c); + gpr_mu_lock(&g_mu); + g_client_call_stack = grpc_call_get_call_stack(c); + gpr_mu_unlock(&g_mu); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); @@ -168,6 +176,10 @@ static void test_request(grpc_end2end_test_config config) { CQ_EXPECT_COMPLETION(cqv, tag(101), 1); cq_verify(cqv); + gpr_mu_lock(&g_mu); + g_server_call_stack = grpc_call_get_call_stack(s); + gpr_mu_unlock(&g_mu); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -215,49 +227,62 @@ static void test_request(grpc_end2end_test_config config) { // Perform checks after test tear-down // Guards against the case that there's outstanding channel-related work on a // call prior to verification - // TODO(https://github.com/grpc/grpc/issues/13915) enable this for windows -#ifndef GPR_WINDOWS gpr_mu_lock(&g_mu); if (!g_client_code_recv) { GPR_ASSERT(gpr_cv_wait(&g_client_code_cv, &g_mu, - grpc_timeout_seconds_to_deadline(3))); + grpc_timeout_seconds_to_deadline(3)) == 0); } if (!g_server_code_recv) { - GPR_ASSERT(gpr_cv_wait(&g_client_code_cv, &g_mu, - grpc_timeout_seconds_to_deadline(3))); + GPR_ASSERT(gpr_cv_wait(&g_server_code_cv, &g_mu, + grpc_timeout_seconds_to_deadline(3)) == 0); } GPR_ASSERT(g_client_status_code == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(g_server_status_code == GRPC_STATUS_UNIMPLEMENTED); gpr_mu_unlock(&g_mu); -#endif // GPR_WINDOWS } /******************************************************************************* * Test status_code filter */ +typedef struct final_status_data { + grpc_call_stack* call; +} final_status_data; + static grpc_error* init_call_elem(grpc_call_element* elem, const grpc_call_element_args* args) { + final_status_data* data = (final_status_data*)elem->call_data; + data->call = args->call_stack; return GRPC_ERROR_NONE; } static void client_destroy_call_elem(grpc_call_element* elem, const grpc_call_final_info* final_info, grpc_closure* ignored) { + final_status_data* data = (final_status_data*)elem->call_data; gpr_mu_lock(&g_mu); - g_client_status_code = final_info->final_status; - g_client_code_recv = true; - gpr_cv_signal(&g_client_code_cv); + // Some fixtures, like proxies, will spawn intermidiate calls + // We only want the results from our explicit calls + if (data->call == g_client_call_stack) { + g_client_status_code = final_info->final_status; + g_client_code_recv = true; + gpr_cv_signal(&g_client_code_cv); + } gpr_mu_unlock(&g_mu); } static void server_destroy_call_elem(grpc_call_element* elem, const grpc_call_final_info* final_info, grpc_closure* ignored) { + final_status_data* data = (final_status_data*)elem->call_data; gpr_mu_lock(&g_mu); - g_server_status_code = final_info->final_status; - g_server_code_recv = true; - gpr_cv_signal(&g_server_code_cv); + // Some fixtures, like proxies, will spawn intermidiate calls + // We only want the results from our explicit calls + if (data->call == g_server_call_stack) { + g_server_status_code = final_info->final_status; + g_server_code_recv = true; + gpr_cv_signal(&g_server_code_cv); + } gpr_mu_unlock(&g_mu); } @@ -271,7 +296,7 @@ static void destroy_channel_elem(grpc_channel_element* elem) {} static const grpc_channel_filter test_client_filter = { grpc_call_next_op, grpc_channel_next_op, - 0, + sizeof(final_status_data), init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, client_destroy_call_elem, @@ -284,7 +309,7 @@ static const grpc_channel_filter test_client_filter = { static const grpc_channel_filter test_server_filter = { grpc_call_next_op, grpc_channel_next_op, - 0, + sizeof(final_status_data), init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, server_destroy_call_elem, diff --git a/test/core/fling/client.cc b/test/core/fling/client.cc index 69fb6dc7c7..28e62e0e83 100644 --- a/test/core/fling/client.cc +++ b/test/core/fling/client.cc @@ -186,8 +186,10 @@ int main(int argc, char** argv) { } if (!sc.name) { fprintf(stderr, "unsupported scenario '%s'. Valid are:", scenario_name); + fflush(stderr); for (i = 0; i < GPR_ARRAY_SIZE(scenarios); i++) { fprintf(stderr, " %s", scenarios[i].name); + fflush(stderr); } return 1; } diff --git a/test/core/iomgr/udp_server_test.cc b/test/core/iomgr/udp_server_test.cc index dc1248bc1c..09f0283013 100644 --- a/test/core/iomgr/udp_server_test.cc +++ b/test/core/iomgr/udp_server_test.cc @@ -51,6 +51,9 @@ static int g_number_of_bytes_read = 0; static int g_number_of_orphan_calls = 0; static int g_number_of_starts = 0; +int rcv_buf_size = 1024; +int snd_buf_size = 1024; + static void on_start(grpc_fd* emfd, void* user_data) { g_number_of_starts++; } static bool on_read(grpc_fd* emfd) { @@ -177,8 +180,9 @@ static void test_no_op_with_port(void) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_in); addr->sin_family = AF_INET; - GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read, - on_write, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, + snd_buf_size, on_start, on_read, on_write, + on_fd_orphaned)); grpc_udp_server_destroy(s, nullptr); @@ -207,8 +211,9 @@ static void test_no_op_with_port_and_socket_factory(void) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_in); addr->sin_family = AF_INET; - GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read, - on_write, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, + snd_buf_size, on_start, on_read, on_write, + on_fd_orphaned)); GPR_ASSERT(socket_factory->number_of_socket_calls == 1); GPR_ASSERT(socket_factory->number_of_bind_calls == 1); @@ -233,8 +238,9 @@ static void test_no_op_with_port_and_start(void) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_in); addr->sin_family = AF_INET; - GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read, - on_write, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, + snd_buf_size, on_start, on_read, on_write, + on_fd_orphaned)); grpc_udp_server_start(s, nullptr, 0, nullptr); GPR_ASSERT(g_number_of_starts == 1); @@ -265,8 +271,9 @@ static void test_receive(int number_of_clients) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_storage); addr->ss_family = AF_INET; - GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_start, on_read, - on_write, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, rcv_buf_size, + snd_buf_size, on_start, on_read, on_write, + on_fd_orphaned)); svrfd = grpc_udp_server_get_fd(s, 0); GPR_ASSERT(svrfd >= 0); diff --git a/test/core/network_benchmarks/low_level_ping_pong.cc b/test/core/network_benchmarks/low_level_ping_pong.cc index 96b0745f52..fb982a10fd 100644 --- a/test/core/network_benchmarks/low_level_ping_pong.cc +++ b/test/core/network_benchmarks/low_level_ping_pong.cc @@ -535,6 +535,7 @@ void print_usage(char* argv0) { fprintf(stderr, " tcp: fds are endpoints of a TCP connection\n"); fprintf(stderr, " socketpair: fds come from socketpair()\n"); fprintf(stderr, " pipe: fds come from pipe()\n"); + fflush(stderr); } typedef struct test_strategy { @@ -565,6 +566,7 @@ int create_socket(const char* socket_type, fd_pair* client_fds, create_sockets_pipe(client_fds, server_fds); } else { fprintf(stderr, "Invalid socket type %s\n", socket_type); + fflush(stderr); return -1; } return 0; @@ -657,6 +659,7 @@ int main(int argc, char** argv) { } if (msg_size <= 0) { fprintf(stderr, "msg_size must be > 0\n"); + fflush(stderr); print_usage(argv[0]); return -1; } @@ -668,6 +671,7 @@ int main(int argc, char** argv) { } if (strategy == nullptr) { fprintf(stderr, "Invalid read strategy %s\n", read_strategy); + fflush(stderr); return -1; } diff --git a/test/core/security/create_jwt.cc b/test/core/security/create_jwt.cc index 867a8ba575..56ae9c891c 100644 --- a/test/core/security/create_jwt.cc +++ b/test/core/security/create_jwt.cc @@ -39,6 +39,7 @@ void create_jwt(const char* json_key_file_path, const char* service_url, grpc_slice_unref(json_key_data); if (!grpc_auth_json_key_is_valid(&key)) { fprintf(stderr, "Could not parse json key.\n"); + fflush(stderr); exit(1); } jwt = grpc_jwt_encode_and_sign( @@ -47,6 +48,7 @@ void create_jwt(const char* json_key_file_path, const char* service_url, grpc_auth_json_key_destruct(&key); if (jwt == nullptr) { fprintf(stderr, "Could not create JWT.\n"); + fflush(stderr); exit(1); } fprintf(stdout, "%s\n", jwt); @@ -72,16 +74,19 @@ int main(int argc, char** argv) { if (json_key_file_path == nullptr) { fprintf(stderr, "Missing --json_key option.\n"); + fflush(stderr); exit(1); } if (scope != nullptr) { if (service_url != nullptr) { fprintf(stderr, "Options --scope and --service_url are mutually exclusive.\n"); + fflush(stderr); exit(1); } } else if (service_url == nullptr) { fprintf(stderr, "Need one of --service_url or --scope options.\n"); + fflush(stderr); exit(1); } diff --git a/test/core/security/print_google_default_creds_token.cc b/test/core/security/print_google_default_creds_token.cc index b3742f58a8..d71116d8f6 100644 --- a/test/core/security/print_google_default_creds_token.cc +++ b/test/core/security/print_google_default_creds_token.cc @@ -45,6 +45,7 @@ static void on_metadata_response(void* arg, grpc_error* error) { synchronizer* sync = static_cast<synchronizer*>(arg); if (error != GRPC_ERROR_NONE) { fprintf(stderr, "Fetching token failed: %s\n", grpc_error_string(error)); + fflush(stderr); } else { char* token; GPR_ASSERT(sync->md_array.size == 1); @@ -81,6 +82,7 @@ int main(int argc, char** argv) { creds = grpc_google_default_credentials_create(); if (creds == nullptr) { fprintf(stderr, "\nCould not find default credentials.\n\n"); + fflush(stderr); result = 1; goto end; } diff --git a/test/core/security/verify_jwt.cc b/test/core/security/verify_jwt.cc index e039970c67..5d32ce0cdb 100644 --- a/test/core/security/verify_jwt.cc +++ b/test/core/security/verify_jwt.cc @@ -39,6 +39,7 @@ typedef struct { static void print_usage_and_exit(gpr_cmdline* cl, const char* argv0) { char* usage = gpr_cmdline_usage_string(cl, argv0); fprintf(stderr, "%s", usage); + fflush(stderr); gpr_free(usage); gpr_cmdline_destroy(cl); exit(1); @@ -62,6 +63,7 @@ static void on_jwt_verification_done(void* user_data, GPR_ASSERT(claims == nullptr); fprintf(stderr, "Verification failed with error %s\n", grpc_jwt_verifier_status_to_string(status)); + fflush(stderr); } gpr_mu_lock(sync->mu); diff --git a/test/core/support/cpu_test.cc b/test/core/support/cpu_test.cc index 334c4318e1..87cdc0fb50 100644 --- a/test/core/support/cpu_test.cc +++ b/test/core/support/cpu_test.cc @@ -119,13 +119,16 @@ static void cpu_test(void) { } gpr_mu_unlock(&ct.mu); fprintf(stderr, "Saw cores ["); + fflush(stderr); for (i = 0; i < ct.ncores; i++) { if (ct.used[i]) { fprintf(stderr, "%d,", i); + fflush(stderr); cores_seen++; } } fprintf(stderr, "] (%d/%d)\n", cores_seen, ct.ncores); + fflush(stderr); gpr_free(ct.used); } diff --git a/test/core/support/spinlock_test.cc b/test/core/support/spinlock_test.cc index 58d5fcd42b..ea0dbbf7c6 100644 --- a/test/core/support/spinlock_test.cc +++ b/test/core/support/spinlock_test.cc @@ -95,15 +95,18 @@ static void test(const char* name, void (*body)(void* m), int timeout_s, gpr_timespec deadline = gpr_time_add( start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN)); fprintf(stderr, "%s:", name); + fflush(stderr); while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) { if (iterations < INT64_MAX / 2) iterations <<= 1; fprintf(stderr, " %ld", (long)iterations); + fflush(stderr); m = test_new(10, iterations, incr_step); test_create_threads(m, body); test_wait(m); if (m->counter != m->thread_count * m->iterations * m->incr_step) { fprintf(stderr, "counter %ld threads %d iterations %ld\n", (long)m->counter, m->thread_count, (long)m->iterations); + fflush(stderr); GPR_ASSERT(0); } test_destroy(m); @@ -111,6 +114,7 @@ static void test(const char* name, void (*body)(void* m), int timeout_s, time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start); fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec, (int)time_taken.tv_nsec); + fflush(stderr); } /* Increment m->counter on each iteration; then mark thread as done. */ diff --git a/test/core/support/sync_test.cc b/test/core/support/sync_test.cc index fb7ec44754..768f96d093 100644 --- a/test/core/support/sync_test.cc +++ b/test/core/support/sync_test.cc @@ -231,16 +231,17 @@ static void mark_thread_done(struct test* m) { */ static void test(const char* name, void (*body)(void* m), void (*extra)(void* m), int timeout_s, int incr_step) { - int64_t iterations = 1024; + int64_t iterations = 256; struct test* m; gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; gpr_timespec deadline = gpr_time_add( start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN)); fprintf(stderr, "%s:", name); + fflush(stderr); while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) { - iterations <<= 1; fprintf(stderr, " %ld", (long)iterations); + fflush(stderr); m = test_new(10, iterations, incr_step); if (extra != nullptr) { gpr_thd_id id; @@ -252,13 +253,16 @@ static void test(const char* name, void (*body)(void* m), if (m->counter != m->threads * m->iterations * m->incr_step) { fprintf(stderr, "counter %ld threads %d iterations %ld\n", (long)m->counter, m->threads, (long)m->iterations); + fflush(stderr); GPR_ASSERT(0); } test_destroy(m); + iterations <<= 1; } time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start); fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec, (int)time_taken.tv_nsec); + fflush(stderr); } /* Increment m->counter on each iteration; then mark thread as done. */ diff --git a/test/core/support/time_test.cc b/test/core/support/time_test.cc index 608169274f..b2b4dce58e 100644 --- a/test/core/support/time_test.cc +++ b/test/core/support/time_test.cc @@ -66,21 +66,28 @@ static void test_values(void) { x = gpr_inf_future(GPR_CLOCK_REALTIME); fprintf(stderr, "far future "); + fflush(stderr); i_to_s(x.tv_sec, 16, 16, &to_fp, stderr); fprintf(stderr, "\n"); GPR_ASSERT(x.tv_sec == INT64_MAX); fprintf(stderr, "far future "); + fflush(stderr); ts_to_s(x, &to_fp, stderr); fprintf(stderr, "\n"); + fflush(stderr); x = gpr_inf_past(GPR_CLOCK_REALTIME); fprintf(stderr, "far past "); + fflush(stderr); i_to_s(x.tv_sec, 16, 16, &to_fp, stderr); fprintf(stderr, "\n"); + fflush(stderr); GPR_ASSERT(x.tv_sec == INT64_MIN); fprintf(stderr, "far past "); + fflush(stderr); ts_to_s(x, &to_fp, stderr); fprintf(stderr, "\n"); + fflush(stderr); for (i = 1; i != 1000 * 1000 * 1000; i *= 10) { x = gpr_time_from_micros(i, GPR_TIMESPAN); @@ -135,15 +142,19 @@ static void test_add_sub(void) { if (gpr_time_cmp(gpr_time_from_micros(sum * k, GPR_TIMESPAN), sumt) != 0) { fprintf(stderr, "i %d j %d sum %d sumt ", i, j, sum); + fflush(stderr); ts_to_s(sumt, &to_fp, stderr); fprintf(stderr, "\n"); + fflush(stderr); GPR_ASSERT(0); } if (gpr_time_cmp(gpr_time_from_micros(diff * k, GPR_TIMESPAN), difft) != 0) { fprintf(stderr, "i %d j %d diff %d diff ", i, j, diff); + fflush(stderr); ts_to_s(sumt, &to_fp, stderr); fprintf(stderr, "\n"); + fflush(stderr); GPR_ASSERT(0); } } diff --git a/test/core/util/debugger_macros.cc b/test/core/util/debugger_macros.cc index f1e4ffd3af..bb96fc7054 100644 --- a/test/core/util/debugger_macros.cc +++ b/test/core/util/debugger_macros.cc @@ -39,6 +39,7 @@ grpc_stream* grpc_transport_stream_from_call(grpc_call* call) { grpc_subchannel_call* scc = grpc_client_channel_get_subchannel_call(el); if (scc == nullptr) { fprintf(stderr, "No subchannel-call"); + fflush(stderr); return nullptr; } cs = grpc_subchannel_call_get_call_stack(scc); @@ -46,6 +47,7 @@ grpc_stream* grpc_transport_stream_from_call(grpc_call* call) { return grpc_connected_channel_get_stream(el); } else { fprintf(stderr, "Unrecognized filter: %s", el->filter->name); + fflush(stderr); return nullptr; } } |