diff options
author | Craig Tiller <ctiller@google.com> | 2016-04-03 20:27:18 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-04-03 20:27:18 -0700 |
commit | db1baa24cb90b4fd76c95fa2616014a45a27b148 (patch) | |
tree | 857d2441f32f0fbcb4c5a96be8d78be3eb337da2 | |
parent | 4e5b4f5c623d87048d1aae0cb60ae46f1410eca2 (diff) |
Fix things
-rw-r--r-- | src/core/lib/transport/transport.h | 2 | ||||
-rw-r--r-- | test/core/end2end/fuzzers/server_fuzzer.c | 21 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 460e4dcedc..22f53e5179 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -50,7 +50,7 @@ typedef struct grpc_transport grpc_transport; for a stream. */ typedef struct grpc_stream grpc_stream; -/*#define GRPC_STREAM_REFCOUNT_DEBUG*/ +#define GRPC_STREAM_REFCOUNT_DEBUG typedef struct grpc_stream_refcount { gpr_refcount refs; diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c index 95c4090a92..370d7425e0 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.c +++ b/test/core/end2end/fuzzers/server_fuzzer.c @@ -42,11 +42,11 @@ static void discard_write(gpr_slice slice) {} static void *tag(int n) { return (void *)(uintptr_t)n; } static int detag(void *p) { return (int)(uintptr_t)p; } -static void dont_log(gpr_log_func_args *args) {} +//static void dont_log(gpr_log_func_args *args) {} int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_test_only_set_metadata_hash_seed(0); - gpr_set_log_function(dont_log); + //gpr_set_log_function(dont_log); grpc_init(); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -67,11 +67,16 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_server_setup_transport(&exec_ctx, server, transport, NULL); grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); - grpc_call *call1; + grpc_call *call1 = NULL; grpc_call_details call_details1; grpc_metadata_array request_metadata1; + grpc_call_details_init(&call_details1); + grpc_metadata_array_init(&request_metadata1); + int requested_calls = 0; + grpc_server_request_call(server, &call1, &call_details1, &request_metadata1, cq, cq, tag(1)); + requested_calls++; while (1) { grpc_exec_ctx_flush(&exec_ctx); @@ -85,11 +90,21 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case GRPC_OP_COMPLETE: switch (detag(ev.tag)) { case 1: + requested_calls--; abort(); } } } + done: + if (call1 != NULL) grpc_call_destroy(call1); + grpc_server_shutdown_and_notify(server, cq, tag(0xdead)); + for (int i=0; i<=requested_calls; i++) + GPR_ASSERT(grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL).type == GRPC_OP_COMPLETE); + grpc_completion_queue_shutdown(cq); + GPR_ASSERT(grpc_completion_queue_next(cq, gpr_inf_past(GPR_CLOCK_REALTIME), NULL).type == GRPC_QUEUE_SHUTDOWN); + grpc_server_destroy(server); + grpc_completion_queue_destroy(cq); grpc_shutdown(); return 0; } |