diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index 13695ae03df..5aceac6cac6 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -111,7 +111,9 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, gpr_event_init(&a.done_write); a.validator = validator; grpc_server_register_completion_queue(a.server, a.cq, NULL); - a.registered_method = grpc_server_register_method(a.server, GRPC_BAD_CLIENT_REGISTERED_METHOD, GRPC_BAD_CLIENT_REGISTERED_HOST); + a.registered_method = + grpc_server_register_method(a.server, GRPC_BAD_CLIENT_REGISTERED_METHOD, + GRPC_BAD_CLIENT_REGISTERED_HOST); grpc_server_start(a.server); transport = grpc_create_chttp2_transport(&exec_ctx, NULL, sfd.server, 0); server_setup_transport(&a, transport); diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h index e782c27fa1e..2dd100a3db0 100644 --- a/test/core/bad_client/bad_client.h +++ b/test/core/bad_client/bad_client.h @@ -40,9 +40,9 @@ #define GRPC_BAD_CLIENT_REGISTERED_METHOD "/registered/bar" #define GRPC_BAD_CLIENT_REGISTERED_HOST "localhost" -typedef void (*grpc_bad_client_server_side_validator)( - grpc_server *server, grpc_completion_queue *cq, - void *registered_method); +typedef void (*grpc_bad_client_server_side_validator)(grpc_server *server, + grpc_completion_queue *cq, + void *registered_method); #define GRPC_BAD_CLIENT_DISCONNECT 1 diff --git a/test/core/bad_client/tests/badreq.c b/test/core/bad_client/tests/badreq.c index f57cc7a17f3..6d59d25b922 100644 --- a/test/core/bad_client/tests/badreq.c +++ b/test/core/bad_client/tests/badreq.c @@ -42,7 +42,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ -static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/connection_prefix.c b/test/core/bad_client/tests/connection_prefix.c index 9cd2da87db4..66ff8c29367 100644 --- a/test/core/bad_client/tests/connection_prefix.c +++ b/test/core/bad_client/tests/connection_prefix.c @@ -34,7 +34,8 @@ #include "test/core/bad_client/bad_client.h" #include "src/core/surface/server.h" -static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/headers.c b/test/core/bad_client/tests/headers.c index fd1d1cd574f..2186a4ffcb2 100644 --- a/test/core/bad_client/tests/headers.c +++ b/test/core/bad_client/tests/headers.c @@ -38,7 +38,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.c index 4ee589bf2b1..fb6149cc3ba 100644 --- a/test/core/bad_client/tests/initial_settings_frame.c +++ b/test/core/bad_client/tests/initial_settings_frame.c @@ -37,7 +37,8 @@ #define PFX_STR "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" #define ONE_SETTING_HDR "\x00\x00\x06\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/server_registered_method.c b/test/core/bad_client/tests/server_registered_method.c index a8f9548c7f9..d2876ffa93a 100644 --- a/test/core/bad_client/tests/server_registered_method.c +++ b/test/core/bad_client/tests/server_registered_method.c @@ -38,22 +38,25 @@ #include "test/core/end2end/cq_verifier.h" #include "src/core/surface/server.h" -#define PFX_STR \ - "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ - "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ \ - "\x00\x00\xd0\x01\x04\x00\x00\x00\x01" \ - "\x10\x05:path\x0f/registered/bar" \ - "\x10\x07:scheme\x04http" \ - "\x10\x07:method\x04POST" \ - "\x10\x0a:authority\x09localhost" \ - "\x10\x0c""content-type\x10""application/grpc" \ - "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" \ - "\x10\x02te\x08trailers" \ +#define PFX_STR \ + "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ + "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ \ + "\x00\x00\xd0\x01\x04\x00\x00\x00\x01" \ + "\x10\x05:path\x0f/registered/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" \ + "\x10\x02te\x08trailers" \ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" static void *tag(gpr_intptr t) { return (void *)t; } -static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { grpc_call_error error; grpc_call *s; cq_verifier *cqv = cq_verifier_create(cq); @@ -63,8 +66,9 @@ static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq, vo grpc_metadata_array_init(&request_metadata_recv); - error = grpc_server_request_registered_call(server, registered_method, &s, &deadline, - &request_metadata_recv, &payload, cq, cq, tag(101)); + error = grpc_server_request_registered_call(server, registered_method, &s, + &deadline, &request_metadata_recv, + &payload, cq, cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); @@ -77,7 +81,8 @@ static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq, vo cq_verifier_destroy(cqv); } -static void verifier_fails(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier_fails(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { grpc_call_error error; grpc_call *s; cq_verifier *cqv = cq_verifier_create(cq); @@ -87,8 +92,9 @@ static void verifier_fails(grpc_server *server, grpc_completion_queue *cq, void grpc_metadata_array_init(&request_metadata_recv); - error = grpc_server_request_registered_call(server, registered_method, &s, &deadline, - &request_metadata_recv, &payload, cq, cq, tag(101)); + error = grpc_server_request_registered_call(server, registered_method, &s, + &deadline, &request_metadata_recv, + &payload, cq, cq, tag(101)); GPR_ASSERT(GRPC_CALL_OK == error); cq_expect_completion(cqv, tag(101), 1); cq_verify(cqv); @@ -103,18 +109,47 @@ static void verifier_fails(grpc_server *server, grpc_completion_queue *cq, void int main(int argc, char **argv) { grpc_test_init(argc, argv); - /* body generated with tools/codegen/core/gen_server_registered_method_bad_client_test_body.py */ - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x00\x00\x00\x00\x00\x00\x01", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x03\x00\x00\x00\x00\x00\x01\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x04\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_succeeds, PFX_STR "\x00\x00\x05\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_succeeds, PFX_STR "\x00\x00\x06\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00", 0); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR "\x00\x00\x06\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00", GRPC_BAD_CLIENT_DISCONNECT); - GRPC_RUN_BAD_CLIENT_TEST(verifier_succeeds, PFX_STR "\x00\x00\x07\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00", 0); + /* body generated with + * tools/codegen/core/gen_server_registered_method_bad_client_test_body.py */ + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, + PFX_STR "\x00\x00\x00\x00\x00\x00\x00\x00\x01", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, + PFX_STR "\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR + "\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR + "\x00\x00\x03\x00\x00\x00\x00\x00\x01\x00\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x04\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_succeeds, + PFX_STR "\x00\x00\x05\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00", 0); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_succeeds, + PFX_STR "\x00\x00\x06\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00", + 0); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x06\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_succeeds, PFX_STR + "\x00\x00\x07\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00", + 0); return 0; } diff --git a/test/core/bad_client/tests/simple_request.c b/test/core/bad_client/tests/simple_request.c index 101f830ba52..4df586e0e41 100644 --- a/test/core/bad_client/tests/simple_request.c +++ b/test/core/bad_client/tests/simple_request.c @@ -79,7 +79,8 @@ static void *tag(gpr_intptr t) { return (void *)t; } -static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { grpc_call_error error; grpc_call *s; grpc_call_details call_details; @@ -104,7 +105,8 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq, void *regis cq_verifier_destroy(cqv); } -static void failure_verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void failure_verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/unknown_frame.c b/test/core/bad_client/tests/unknown_frame.c index f9d2316a61c..2ef340eeb5c 100644 --- a/test/core/bad_client/tests/unknown_frame.c +++ b/test/core/bad_client/tests/unknown_frame.c @@ -38,7 +38,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq, void *registered_method) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20),