diff options
author | Yash Tibrewal <yashkt@google.com> | 2017-11-09 17:46:29 -0800 |
---|---|---|
committer | Yash Tibrewal <yashkt@google.com> | 2017-11-09 17:46:29 -0800 |
commit | 4e9265c828f0b559b5fdba04913fed46bf771399 (patch) | |
tree | 4a379fc2bdc037753cf8d81f8b86327e4bc50a42 /test/core/http | |
parent | 0ee7574732a06e8cace4e099a678f4bd5dbff679 (diff) | |
parent | d9da7387b8057f3bd99a417a5ee905377bce9296 (diff) |
Merge with master
Diffstat (limited to 'test/core/http')
-rw-r--r-- | test/core/http/BUILD | 20 | ||||
-rw-r--r-- | test/core/http/format_request_test.cc (renamed from test/core/http/format_request_test.c) | 32 | ||||
-rw-r--r-- | test/core/http/httpcli_test.cc (renamed from test/core/http/httpcli_test.c) | 56 | ||||
-rw-r--r-- | test/core/http/httpscli_test.cc (renamed from test/core/http/httpscli_test.c) | 62 | ||||
-rw-r--r-- | test/core/http/parser_test.cc (renamed from test/core/http/parser_test.c) | 49 | ||||
-rw-r--r-- | test/core/http/request_fuzzer.cc (renamed from test/core/http/request_fuzzer.c) | 4 | ||||
-rw-r--r-- | test/core/http/response_fuzzer.cc (renamed from test/core/http/response_fuzzer.c) | 4 |
7 files changed, 118 insertions, 109 deletions
diff --git a/test/core/http/BUILD b/test/core/http/BUILD index fffdac5e08..a5ae6272db 100644 --- a/test/core/http/BUILD +++ b/test/core/http/BUILD @@ -22,8 +22,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_fuzzer( name = "response_fuzzer", - srcs = ["response_fuzzer.c"], - language = "C", + srcs = ["response_fuzzer.cc"], + language = "C++", corpus = "response_corpus", deps = [ "//:gpr", @@ -34,8 +34,8 @@ grpc_fuzzer( grpc_fuzzer( name = "request_fuzzer", - srcs = ["request_fuzzer.c"], - language = "C", + srcs = ["request_fuzzer.cc"], + language = "C++", corpus = "request_corpus", deps = [ "//:gpr", @@ -64,8 +64,8 @@ load("//test/core/util:grpc_fuzzer.bzl", "grpc_fuzzer") grpc_cc_test( name = "httpcli_test", - srcs = ["httpcli_test.c"], - language = "C", + srcs = ["httpcli_test.cc"], + language = "C++", data = ["test_server.py"], deps = [ "//:gpr", @@ -78,8 +78,8 @@ grpc_cc_test( grpc_cc_test( name = "httpscli_test", - srcs = ["httpscli_test.c"], - language = "C", + srcs = ["httpscli_test.cc"], + language = "C++", data = ["test_server.py"], deps = [ "//:gpr", @@ -92,8 +92,8 @@ grpc_cc_test( grpc_cc_test( name = "parser_test", - srcs = ["parser_test.c"], - language = "C", + srcs = ["parser_test.cc"], + language = "C++", deps = [ "//:gpr", "//:grpc", diff --git a/test/core/http/format_request_test.c b/test/core/http/format_request_test.cc index 0279a1b5e3..253e59135d 100644 --- a/test/core/http/format_request_test.c +++ b/test/core/http/format_request_test.cc @@ -24,13 +24,13 @@ #include "test/core/util/test_config.h" static void test_format_get_request(void) { - grpc_http_header hdr = {"x-yz", "abc"}; + grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")}; grpc_httpcli_request req; grpc_slice slice; memset(&req, 0, sizeof(req)); - req.host = "example.com"; - req.http.path = "/index.html"; + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 1; req.http.hdrs = &hdr; @@ -49,15 +49,15 @@ static void test_format_get_request(void) { } static void test_format_post_request(void) { - grpc_http_header hdr = {"x-yz", "abc"}; + grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")}; grpc_httpcli_request req; grpc_slice slice; char body_bytes[] = "fake body"; size_t body_len = 9; memset(&req, 0, sizeof(req)); - req.host = "example.com"; - req.http.path = "/index.html"; + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 1; req.http.hdrs = &hdr; @@ -79,13 +79,13 @@ static void test_format_post_request(void) { } static void test_format_post_request_no_body(void) { - grpc_http_header hdr = {"x-yz", "abc"}; + grpc_http_header hdr = {const_cast<char*>("x-yz"), const_cast<char*>("abc")}; grpc_httpcli_request req; grpc_slice slice; memset(&req, 0, sizeof(req)); - req.host = "example.com"; - req.http.path = "/index.html"; + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 1; req.http.hdrs = &hdr; @@ -110,13 +110,13 @@ static void test_format_post_request_content_type_override(void) { char body_bytes[] = "fake%20body"; size_t body_len = 11; - hdrs[0].key = "x-yz"; - hdrs[0].value = "abc"; - hdrs[1].key = "Content-Type"; - hdrs[1].value = "application/x-www-form-urlencoded"; + hdrs[0].key = const_cast<char*>("x-yz"); + hdrs[0].value = const_cast<char*>("abc"); + hdrs[1].key = const_cast<char*>("Content-Type"); + hdrs[1].value = const_cast<char*>("application/x-www-form-urlencoded"); memset(&req, 0, sizeof(req)); - req.host = "example.com"; - req.http.path = "/index.html"; + req.host = const_cast<char*>("example.com"); + req.http.path = const_cast<char*>("/index.html"); req.http.hdr_count = 2; req.http.hdrs = hdrs; @@ -137,7 +137,7 @@ static void test_format_post_request_content_type_override(void) { grpc_slice_unref(slice); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_test_init(argc, argv); test_format_get_request(); diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.cc index de339304d9..85e4bc8a0e 100644 --- a/test/core/http/httpcli_test.c +++ b/test/core/http/httpcli_test.cc @@ -32,7 +32,7 @@ static int g_done = 0; static grpc_httpcli_context g_context; -static gpr_mu *g_mu; +static gpr_mu* g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { @@ -40,11 +40,11 @@ static grpc_millis n_seconds_time(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void on_finish(void *arg, grpc_error *error) { - const char *expect = +static void on_finish(void* arg, grpc_error* error) { + const char* expect = "<html><head><title>Hello world!</title></head>" "<body><p>This is a test</p></body></html>"; - grpc_http_response *response = arg; + grpc_http_response* response = static_cast<grpc_http_response*>(arg); GPR_ASSERT(response); GPR_ASSERT(response->status == 200); GPR_ASSERT(response->body_length == strlen(expect)); @@ -59,8 +59,8 @@ static void on_finish(void *arg, grpc_error *error) { static void test_get(int port) { grpc_httpcli_request req; - char *host; - exec_ctx = GRPC_EXEC_CTX_INIT; + char* host; + ExecCtx _local_exec_ctx; g_done = 0; gpr_log(GPR_INFO, "test_get"); @@ -70,12 +70,12 @@ static void test_get(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.http.path = "/get"; + req.http.path = const_cast<char*>("/get"); req.handshaker = &grpc_httpcli_plaintext; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get"); grpc_httpcli_get( &g_context, &g_pops, resource_quota, &req, n_seconds_time(15), GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx), @@ -83,7 +83,7 @@ static void test_get(int port) { grpc_resource_quota_unref_internal(resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops), &worker, n_seconds_time(1)))); @@ -98,8 +98,8 @@ static void test_get(int port) { static void test_post(int port) { grpc_httpcli_request req; - char *host; - exec_ctx = GRPC_EXEC_CTX_INIT; + char* host; + ExecCtx _local_exec_ctx; g_done = 0; gpr_log(GPR_INFO, "test_post"); @@ -109,12 +109,12 @@ static void test_post(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.http.path = "/post"; + req.http.path = const_cast<char*>("/post"); req.handshaker = &grpc_httpcli_plaintext; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post"); grpc_httpcli_post( &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15), GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx), @@ -122,7 +122,7 @@ static void test_post(int port) { grpc_resource_quota_unref_internal(resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops), &worker, n_seconds_time(1)))); @@ -135,23 +135,24 @@ static void test_post(int port) { grpc_http_response_destroy(&response); } -static void destroy_pops(void *p, grpc_error *error) { - grpc_pollset_destroy(grpc_polling_entity_pollset(p)); +static void destroy_pops(void* p, grpc_error* error) { + grpc_pollset_destroy( + grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p))); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; - exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_subprocess *server; - char *me = argv[0]; - char *lslash = strrchr(me, '/'); - char *args[4]; + ExecCtx _local_exec_ctx; + gpr_subprocess* server; + char* me = argv[0]; + char* lslash = strrchr(me, '/'); + char* args[4]; int port = grpc_pick_unused_port_or_die(); int arg_shift = 0; /* figure out where we are */ - char *root; + char* root; if (lslash) { - root = gpr_malloc((size_t)(lslash - me + 1)); + root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1))); memcpy(root, me, (size_t)(lslash - me)); root[lslash - me] = 0; } else { @@ -168,9 +169,9 @@ int main(int argc, char **argv) { } /* start the server */ - args[1 + arg_shift] = "--port"; + args[1 + arg_shift] = const_cast<char*>("--port"); gpr_asprintf(&args[2 + arg_shift], "%d", port); - server = gpr_subprocess_create(3 + arg_shift, (const char **)args); + server = gpr_subprocess_create(3 + arg_shift, (const char**)args); GPR_ASSERT(server); gpr_free(args[0]); if (arg_shift) gpr_free(args[1]); @@ -183,7 +184,8 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); grpc_httpcli_context_init(&g_context); - grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size()); + grpc_pollset* pollset = + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollset, &g_mu); g_pops = grpc_polling_entity_create_from_pollset(pollset); diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.cc index dde2fbfd66..d948bb5e31 100644 --- a/test/core/http/httpscli_test.c +++ b/test/core/http/httpscli_test.cc @@ -32,7 +32,7 @@ static int g_done = 0; static grpc_httpcli_context g_context; -static gpr_mu *g_mu; +static gpr_mu* g_mu; static grpc_polling_entity g_pops; static grpc_millis n_seconds_time(int seconds) { @@ -40,11 +40,11 @@ static grpc_millis n_seconds_time(int seconds) { grpc_timeout_seconds_to_deadline(seconds)); } -static void on_finish(void *arg, grpc_error *error) { - const char *expect = +static void on_finish(void* arg, grpc_error* error) { + const char* expect = "<html><head><title>Hello world!</title></head>" "<body><p>This is a test</p></body></html>"; - grpc_http_response *response = arg; + grpc_http_response* response = static_cast<grpc_http_response*>(arg); GPR_ASSERT(response); GPR_ASSERT(response->status == 200); GPR_ASSERT(response->body_length == strlen(expect)); @@ -59,8 +59,8 @@ static void on_finish(void *arg, grpc_error *error) { static void test_get(int port) { grpc_httpcli_request req; - char *host; - exec_ctx = GRPC_EXEC_CTX_INIT; + char* host; + ExecCtx _local_exec_ctx; g_done = 0; gpr_log(GPR_INFO, "test_get"); @@ -70,13 +70,13 @@ static void test_get(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.ssl_host_override = "foo.test.google.fr"; - req.http.path = "/get"; + req.ssl_host_override = const_cast<char*>("foo.test.google.fr"); + req.http.path = const_cast<char*>("/get"); req.handshaker = &grpc_httpcli_ssl; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_get"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_get"); grpc_httpcli_get( &g_context, &g_pops, resource_quota, &req, n_seconds_time(15), GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx), @@ -84,7 +84,7 @@ static void test_get(int port) { grpc_resource_quota_unref_internal(resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops), &worker, n_seconds_time(1)))); @@ -99,8 +99,8 @@ static void test_get(int port) { static void test_post(int port) { grpc_httpcli_request req; - char *host; - exec_ctx = GRPC_EXEC_CTX_INIT; + char* host; + ExecCtx _local_exec_ctx; g_done = 0; gpr_log(GPR_INFO, "test_post"); @@ -110,13 +110,13 @@ static void test_post(int port) { memset(&req, 0, sizeof(req)); req.host = host; - req.ssl_host_override = "foo.test.google.fr"; - req.http.path = "/post"; + req.ssl_host_override = const_cast<char*>("foo.test.google.fr"); + req.http.path = const_cast<char*>("/post"); req.handshaker = &grpc_httpcli_ssl; grpc_http_response response; memset(&response, 0, sizeof(response)); - grpc_resource_quota *resource_quota = grpc_resource_quota_create("test_post"); + grpc_resource_quota* resource_quota = grpc_resource_quota_create("test_post"); grpc_httpcli_post( &g_context, &g_pops, resource_quota, &req, "hello", 5, n_seconds_time(15), GRPC_CLOSURE_CREATE(on_finish, &response, grpc_schedule_on_exec_ctx), @@ -124,7 +124,7 @@ static void test_post(int port) { grpc_resource_quota_unref_internal(resource_quota); gpr_mu_lock(g_mu); while (!g_done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; GPR_ASSERT(GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(grpc_polling_entity_pollset(&g_pops), &worker, n_seconds_time(1)))); @@ -137,23 +137,24 @@ static void test_post(int port) { grpc_http_response_destroy(&response); } -static void destroy_pops(void *p, grpc_error *error) { - grpc_pollset_destroy(grpc_polling_entity_pollset(p)); +static void destroy_pops(void* p, grpc_error* error) { + grpc_pollset_destroy( + grpc_polling_entity_pollset(static_cast<grpc_polling_entity*>(p))); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_closure destroyed; - exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_subprocess *server; - char *me = argv[0]; - char *lslash = strrchr(me, '/'); - char *args[5]; + ExecCtx _local_exec_ctx; + gpr_subprocess* server; + char* me = argv[0]; + char* lslash = strrchr(me, '/'); + char* args[5]; int port = grpc_pick_unused_port_or_die(); int arg_shift = 0; /* figure out where we are */ - char *root; + char* root; if (lslash) { - root = gpr_malloc((size_t)(lslash - me + 1)); + root = static_cast<char*>(gpr_malloc((size_t)(lslash - me + 1))); memcpy(root, me, (size_t)(lslash - me)); root[lslash - me] = 0; } else { @@ -170,10 +171,10 @@ int main(int argc, char **argv) { } /* start the server */ - args[1 + arg_shift] = "--port"; + args[1 + arg_shift] = const_cast<char*>("--port"); gpr_asprintf(&args[2 + arg_shift], "%d", port); - args[3 + arg_shift] = "--ssl"; - server = gpr_subprocess_create(4 + arg_shift, (const char **)args); + args[3 + arg_shift] = const_cast<char*>("--ssl"); + server = gpr_subprocess_create(4 + arg_shift, (const char**)args); GPR_ASSERT(server); gpr_free(args[0]); if (arg_shift) gpr_free(args[1]); @@ -186,7 +187,8 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); grpc_httpcli_context_init(&g_context); - grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size()); + grpc_pollset* pollset = + static_cast<grpc_pollset*>(gpr_zalloc(grpc_pollset_size())); grpc_pollset_init(pollset, &g_mu); g_pops = grpc_polling_entity_create_from_pollset(pollset); diff --git a/test/core/http/parser_test.c b/test/core/http/parser_test.cc index a7044c03bc..d0d2559cdf 100644 --- a/test/core/http/parser_test.c +++ b/test/core/http/parser_test.cc @@ -29,14 +29,16 @@ #include "test/core/util/test_config.h" static void test_request_succeeds(grpc_slice_split_mode split_mode, - char *request_text, char *expect_method, + const char* request_text, + const char* expect_method, grpc_http_version expect_version, - char *expect_path, char *expect_body, ...) { + const char* expect_path, + const char* expect_body, ...) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(request_text); size_t num_slices; size_t i; - grpc_slice *slices; + grpc_slice* slices; va_list args; grpc_http_request request; memset(&request, 0, sizeof(request)); @@ -68,12 +70,12 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode, va_start(args, expect_body); i = 0; for (;;) { - char *expect_key; - char *expect_value; - expect_key = va_arg(args, char *); + char* expect_key; + char* expect_value; + expect_key = va_arg(args, char*); if (!expect_key) break; GPR_ASSERT(i < request.hdr_count); - expect_value = va_arg(args, char *); + expect_value = va_arg(args, char*); GPR_ASSERT(expect_value); GPR_ASSERT(0 == strcmp(expect_key, request.hdrs[i].key)); GPR_ASSERT(0 == strcmp(expect_value, request.hdrs[i].value)); @@ -87,13 +89,14 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode, gpr_free(slices); } -static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text, - int expect_status, char *expect_body, ...) { +static void test_succeeds(grpc_slice_split_mode split_mode, + const char* response_text, int expect_status, + const char* expect_body, ...) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(response_text); size_t num_slices; size_t i; - grpc_slice *slices; + grpc_slice* slices; va_list args; grpc_http_response response; memset(&response, 0, sizeof(response)); @@ -122,12 +125,12 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text, va_start(args, expect_body); i = 0; for (;;) { - char *expect_key; - char *expect_value; - expect_key = va_arg(args, char *); + char* expect_key; + char* expect_value; + expect_key = va_arg(args, char*); if (!expect_key) break; GPR_ASSERT(i < response.hdr_count); - expect_value = va_arg(args, char *); + expect_value = va_arg(args, char*); GPR_ASSERT(expect_value); GPR_ASSERT(0 == strcmp(expect_key, response.hdrs[i].key)); GPR_ASSERT(0 == strcmp(expect_value, response.hdrs[i].value)); @@ -141,13 +144,14 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text, gpr_free(slices); } -static void test_fails(grpc_slice_split_mode split_mode, char *response_text) { +static void test_fails(grpc_slice_split_mode split_mode, + const char* response_text) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(response_text); size_t num_slices; size_t i; - grpc_slice *slices; - grpc_error *error = GRPC_ERROR_NONE; + grpc_slice* slices; + grpc_error* error = GRPC_ERROR_NONE; grpc_http_response response; memset(&response, 0, sizeof(response)); @@ -174,13 +178,13 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) { } static void test_request_fails(grpc_slice_split_mode split_mode, - char *request_text) { + const char* request_text) { grpc_http_parser parser; grpc_slice input_slice = grpc_slice_from_copied_string(request_text); size_t num_slices; size_t i; - grpc_slice *slices; - grpc_error *error = GRPC_ERROR_NONE; + grpc_slice* slices; + grpc_error* error = GRPC_ERROR_NONE; grpc_http_request request; memset(&request, 0, sizeof(request)); @@ -206,7 +210,7 @@ static void test_request_fails(grpc_slice_split_mode split_mode, gpr_free(slices); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { size_t i; const grpc_slice_split_mode split_modes[] = {GRPC_SLICE_SPLIT_IDENTITY, GRPC_SLICE_SPLIT_ONE_BYTE}; @@ -286,7 +290,8 @@ int main(int argc, char **argv) { test_request_fails(split_modes[i], "GET / HTTP/1.2\r\n"); test_request_fails(split_modes[i], "GET / HTTP/1.0\n"); - tmp1 = gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH); + tmp1 = + static_cast<char*>(gpr_malloc(2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH)); memset(tmp1, 'a', 2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1); tmp1[2 * GRPC_HTTP_PARSER_MAX_HEADER_LENGTH - 1] = 0; gpr_asprintf(&tmp2, "HTTP/1.0 200 OK\r\nxyz: %s\r\n\r\n", tmp1); diff --git a/test/core/http/request_fuzzer.c b/test/core/http/request_fuzzer.cc index aefe9eb0f9..dfdb5792ac 100644 --- a/test/core/http/request_fuzzer.c +++ b/test/core/http/request_fuzzer.cc @@ -27,12 +27,12 @@ bool squelch = true; bool leak_check = true; -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_http_parser parser; grpc_http_request request; memset(&request, 0, sizeof(request)); grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request); - grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL)); GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser)); grpc_slice_unref(slice); diff --git a/test/core/http/response_fuzzer.c b/test/core/http/response_fuzzer.cc index d5bb67500d..89ee676b49 100644 --- a/test/core/http/response_fuzzer.c +++ b/test/core/http/response_fuzzer.cc @@ -26,12 +26,12 @@ bool squelch = true; bool leak_check = true; -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { grpc_http_parser parser; grpc_http_response response; memset(&response, 0, sizeof(response)); grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); - grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char*)data, size); GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL)); GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser)); grpc_slice_unref(slice); |