diff options
author | 2015-09-22 12:33:20 -0700 | |
---|---|---|
committer | 2015-09-22 12:33:20 -0700 | |
commit | a82950e68318a6aab6fe894fa39f7fa616c4647b (patch) | |
tree | 7d02bd1e9e1cbae1f14ad4ad1e06d3ae81a96dfe /test/core/end2end | |
parent | 8af4c337181322cc4fb396199c90f574cfb4163f (diff) |
clang-format all core files
Diffstat (limited to 'test/core/end2end')
59 files changed, 4780 insertions, 5638 deletions
diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 3feb3977b3..922de268f4 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -50,8 +50,7 @@ #define ROOT_EXPECTATION 1000 /* a set of metadata we expect to find on an event */ -typedef struct metadata -{ +typedef struct metadata { size_t count; size_t cap; char **keys; @@ -60,8 +59,7 @@ typedef struct metadata /* details what we expect to find on a single event - and forms a linked list to detail other expectations */ -typedef struct expectation -{ +typedef struct expectation { struct expectation *next; struct expectation *prev; grpc_completion_type type; @@ -70,18 +68,15 @@ typedef struct expectation } expectation; /* the verifier itself */ -struct cq_verifier -{ +struct cq_verifier { /* bound completion queue */ grpc_completion_queue *cq; /* the root/sentinal expectation */ expectation expect; }; -cq_verifier * -cq_verifier_create (grpc_completion_queue * cq) -{ - cq_verifier *v = gpr_malloc (sizeof (cq_verifier)); +cq_verifier *cq_verifier_create(grpc_completion_queue *cq) { + cq_verifier *v = gpr_malloc(sizeof(cq_verifier)); v->expect.type = ROOT_EXPECTATION; v->expect.tag = NULL; v->expect.next = &v->expect; @@ -90,231 +85,197 @@ cq_verifier_create (grpc_completion_queue * cq) return v; } -void -cq_verifier_destroy (cq_verifier * v) -{ - cq_verify (v); - gpr_free (v); +void cq_verifier_destroy(cq_verifier *v) { + cq_verify(v); + gpr_free(v); } -static int -has_metadata (const grpc_metadata * md, size_t count, const char *key, const char *value) -{ +static int has_metadata(const grpc_metadata *md, size_t count, const char *key, + const char *value) { size_t i; - for (i = 0; i < count; i++) - { - if (0 == strcmp (key, md[i].key) && strlen (value) == md[i].value_length && 0 == memcmp (md[i].value, value, md[i].value_length)) - { - return 1; - } + for (i = 0; i < count; i++) { + if (0 == strcmp(key, md[i].key) && strlen(value) == md[i].value_length && + 0 == memcmp(md[i].value, value, md[i].value_length)) { + return 1; } + } return 0; } -int -contains_metadata (grpc_metadata_array * array, const char *key, const char *value) -{ - return has_metadata (array->metadata, array->count, key, value); +int contains_metadata(grpc_metadata_array *array, const char *key, + const char *value) { + return has_metadata(array->metadata, array->count, key, value); } -static gpr_slice -merge_slices (gpr_slice * slices, size_t nslices) -{ +static gpr_slice merge_slices(gpr_slice *slices, size_t nslices) { size_t i; size_t len = 0; gpr_uint8 *cursor; gpr_slice out; - for (i = 0; i < nslices; i++) - { - len += GPR_SLICE_LENGTH (slices[i]); - } + for (i = 0; i < nslices; i++) { + len += GPR_SLICE_LENGTH(slices[i]); + } - out = gpr_slice_malloc (len); - cursor = GPR_SLICE_START_PTR (out); + out = gpr_slice_malloc(len); + cursor = GPR_SLICE_START_PTR(out); - for (i = 0; i < nslices; i++) - { - memcpy (cursor, GPR_SLICE_START_PTR (slices[i]), GPR_SLICE_LENGTH (slices[i])); - cursor += GPR_SLICE_LENGTH (slices[i]); - } + for (i = 0; i < nslices; i++) { + memcpy(cursor, GPR_SLICE_START_PTR(slices[i]), GPR_SLICE_LENGTH(slices[i])); + cursor += GPR_SLICE_LENGTH(slices[i]); + } return out; } -static int -byte_buffer_eq_slice (grpc_byte_buffer * bb, gpr_slice b) -{ +static int byte_buffer_eq_slice(grpc_byte_buffer *bb, gpr_slice b) { gpr_slice a; int ok; - if (!bb) - return 0; + if (!bb) return 0; - a = merge_slices (bb->data.raw.slice_buffer.slices, bb->data.raw.slice_buffer.count); - ok = GPR_SLICE_LENGTH (a) == GPR_SLICE_LENGTH (b) && 0 == memcmp (GPR_SLICE_START_PTR (a), GPR_SLICE_START_PTR (b), GPR_SLICE_LENGTH (a)); - gpr_slice_unref (a); - gpr_slice_unref (b); + a = merge_slices(bb->data.raw.slice_buffer.slices, + bb->data.raw.slice_buffer.count); + ok = GPR_SLICE_LENGTH(a) == GPR_SLICE_LENGTH(b) && + 0 == memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b), + GPR_SLICE_LENGTH(a)); + gpr_slice_unref(a); + gpr_slice_unref(b); return ok; } -int -byte_buffer_eq_string (grpc_byte_buffer * bb, const char *str) -{ +int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) { grpc_byte_buffer_reader reader; grpc_byte_buffer *rbb; int res; - grpc_byte_buffer_reader_init (&reader, bb); - rbb = grpc_raw_byte_buffer_from_reader (&reader); - res = byte_buffer_eq_slice (rbb, gpr_slice_from_copied_string (str)); - grpc_byte_buffer_reader_destroy (&reader); - grpc_byte_buffer_destroy (rbb); + grpc_byte_buffer_reader_init(&reader, bb); + rbb = grpc_raw_byte_buffer_from_reader(&reader); + res = byte_buffer_eq_slice(rbb, gpr_slice_from_copied_string(str)); + grpc_byte_buffer_reader_destroy(&reader); + grpc_byte_buffer_destroy(rbb); return res; } -static void -verify_matches (expectation * e, grpc_event * ev) -{ - GPR_ASSERT (e->type == ev->type); - switch (e->type) - { +static void verify_matches(expectation *e, grpc_event *ev) { + GPR_ASSERT(e->type == ev->type); + switch (e->type) { case GRPC_QUEUE_SHUTDOWN: - gpr_log (GPR_ERROR, "premature queue shutdown"); - abort (); + gpr_log(GPR_ERROR, "premature queue shutdown"); + abort(); break; case GRPC_OP_COMPLETE: - GPR_ASSERT (e->success == ev->success); + GPR_ASSERT(e->success == ev->success); break; case GRPC_QUEUE_TIMEOUT: - gpr_log (GPR_ERROR, "not implemented"); - abort (); + gpr_log(GPR_ERROR, "not implemented"); + abort(); break; - } + } } -static void -expectation_to_strvec (gpr_strvec * buf, expectation * e) -{ +static void expectation_to_strvec(gpr_strvec *buf, expectation *e) { char *tmp; - gpr_asprintf (&tmp, "%p ", e->tag); - gpr_strvec_add (buf, tmp); + gpr_asprintf(&tmp, "%p ", e->tag); + gpr_strvec_add(buf, tmp); - switch (e->type) - { + switch (e->type) { case GRPC_OP_COMPLETE: - gpr_asprintf (&tmp, "GRPC_OP_COMPLETE result=%d", e->success); - gpr_strvec_add (buf, tmp); + gpr_asprintf(&tmp, "GRPC_OP_COMPLETE result=%d", e->success); + gpr_strvec_add(buf, tmp); break; case GRPC_QUEUE_TIMEOUT: case GRPC_QUEUE_SHUTDOWN: - gpr_log (GPR_ERROR, "not implemented"); - abort (); + gpr_log(GPR_ERROR, "not implemented"); + abort(); break; - } + } } -static void -expectations_to_strvec (gpr_strvec * buf, cq_verifier * v) -{ +static void expectations_to_strvec(gpr_strvec *buf, cq_verifier *v) { expectation *e; - for (e = v->expect.next; e != &v->expect; e = e->next) - { - expectation_to_strvec (buf, e); - gpr_strvec_add (buf, gpr_strdup ("\n")); - } + for (e = v->expect.next; e != &v->expect; e = e->next) { + expectation_to_strvec(buf, e); + gpr_strvec_add(buf, gpr_strdup("\n")); + } } -static void -fail_no_event_received (cq_verifier * v) -{ +static void fail_no_event_received(cq_verifier *v) { gpr_strvec buf; char *msg; - gpr_strvec_init (&buf); - gpr_strvec_add (&buf, gpr_strdup ("no event received, but expected:\n")); - expectations_to_strvec (&buf, v); - msg = gpr_strvec_flatten (&buf, NULL); - gpr_log (GPR_ERROR, "%s", msg); - gpr_strvec_destroy (&buf); - gpr_free (msg); - abort (); + gpr_strvec_init(&buf); + gpr_strvec_add(&buf, gpr_strdup("no event received, but expected:\n")); + expectations_to_strvec(&buf, v); + msg = gpr_strvec_flatten(&buf, NULL); + gpr_log(GPR_ERROR, "%s", msg); + gpr_strvec_destroy(&buf); + gpr_free(msg); + abort(); } -void -cq_verify (cq_verifier * v) -{ - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE (10); +void cq_verify(cq_verifier *v) { + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10); grpc_event ev; expectation *e; char *s; gpr_strvec have_tags; - gpr_strvec_init (&have_tags); - - while (v->expect.next != &v->expect) - { - ev = grpc_completion_queue_next (v->cq, deadline, NULL); - if (ev.type == GRPC_QUEUE_TIMEOUT) - { - fail_no_event_received (v); - break; - } - - for (e = v->expect.next; e != &v->expect; e = e->next) - { - gpr_asprintf (&s, " %p", e->tag); - gpr_strvec_add (&have_tags, s); - if (e->tag == ev.tag) - { - verify_matches (e, &ev); - e->next->prev = e->prev; - e->prev->next = e->next; - gpr_free (e); - break; - } - } - if (e == &v->expect) - { - s = grpc_event_string (&ev); - gpr_log (GPR_ERROR, "event not found: %s", s); - gpr_free (s); - s = gpr_strvec_flatten (&have_tags, NULL); - gpr_log (GPR_ERROR, "have tags:%s", s); - gpr_free (s); - gpr_strvec_destroy (&have_tags); - abort (); - } + gpr_strvec_init(&have_tags); + + while (v->expect.next != &v->expect) { + ev = grpc_completion_queue_next(v->cq, deadline, NULL); + if (ev.type == GRPC_QUEUE_TIMEOUT) { + fail_no_event_received(v); + break; } - gpr_strvec_destroy (&have_tags); + for (e = v->expect.next; e != &v->expect; e = e->next) { + gpr_asprintf(&s, " %p", e->tag); + gpr_strvec_add(&have_tags, s); + if (e->tag == ev.tag) { + verify_matches(e, &ev); + e->next->prev = e->prev; + e->prev->next = e->next; + gpr_free(e); + break; + } + } + if (e == &v->expect) { + s = grpc_event_string(&ev); + gpr_log(GPR_ERROR, "event not found: %s", s); + gpr_free(s); + s = gpr_strvec_flatten(&have_tags, NULL); + gpr_log(GPR_ERROR, "have tags:%s", s); + gpr_free(s); + gpr_strvec_destroy(&have_tags); + abort(); + } + } + + gpr_strvec_destroy(&have_tags); } -void -cq_verify_empty (cq_verifier * v) -{ - gpr_timespec deadline = gpr_time_add (gpr_now (GPR_CLOCK_REALTIME), - gpr_time_from_seconds (1, GPR_TIMESPAN)); +void cq_verify_empty(cq_verifier *v) { + gpr_timespec deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(1, GPR_TIMESPAN)); grpc_event ev; - GPR_ASSERT (v->expect.next == &v->expect && "expectation queue must be empty"); + GPR_ASSERT(v->expect.next == &v->expect && "expectation queue must be empty"); - ev = grpc_completion_queue_next (v->cq, deadline, NULL); - if (ev.type != GRPC_QUEUE_TIMEOUT) - { - char *s = grpc_event_string (&ev); - gpr_log (GPR_ERROR, "unexpected event (expected nothing): %s", s); - gpr_free (s); - abort (); - } + ev = grpc_completion_queue_next(v->cq, deadline, NULL); + if (ev.type != GRPC_QUEUE_TIMEOUT) { + char *s = grpc_event_string(&ev); + gpr_log(GPR_ERROR, "unexpected event (expected nothing): %s", s); + gpr_free(s); + abort(); + } } -static expectation * -add (cq_verifier * v, grpc_completion_type type, void *tag) -{ - expectation *e = gpr_malloc (sizeof (expectation)); +static expectation *add(cq_verifier *v, grpc_completion_type type, void *tag) { + expectation *e = gpr_malloc(sizeof(expectation)); e->type = type; e->tag = tag; e->next = &v->expect; @@ -323,8 +284,6 @@ add (cq_verifier * v, grpc_completion_type type, void *tag) return e; } -void -cq_expect_completion (cq_verifier * v, void *tag, int success) -{ - add (v, GRPC_OP_COMPLETE, tag)->success = success; +void cq_expect_completion(cq_verifier *v, void *tag, int success) { + add(v, GRPC_OP_COMPLETE, tag)->success = success; } diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index 4447acb3ee..b3e07c45a5 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -43,23 +43,24 @@ typedef struct cq_verifier cq_verifier; /* construct/destroy a cq_verifier */ -cq_verifier *cq_verifier_create (grpc_completion_queue * cq); -void cq_verifier_destroy (cq_verifier * v); +cq_verifier *cq_verifier_create(grpc_completion_queue *cq); +void cq_verifier_destroy(cq_verifier *v); /* ensure all expected events (and only those events) are present on the bound completion queue */ -void cq_verify (cq_verifier * v); +void cq_verify(cq_verifier *v); /* ensure that the completion queue is empty */ -void cq_verify_empty (cq_verifier * v); +void cq_verify_empty(cq_verifier *v); /* Various expectation matchers Any functions taking ... expect a NULL terminated list of key/value pairs (each pair using two parameter slots) of metadata that MUST be present in the event. */ -void cq_expect_completion (cq_verifier * v, void *tag, int success); +void cq_expect_completion(cq_verifier *v, void *tag, int success); -int byte_buffer_eq_string (grpc_byte_buffer * byte_buffer, const char *string); -int contains_metadata (grpc_metadata_array * array, const char *key, const char *value); +int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); +int contains_metadata(grpc_metadata_array *array, const char *key, + const char *value); #endif /* GRPC_TEST_CORE_END2END_CQ_VERIFIER_H */ diff --git a/test/core/end2end/data/server1_cert.c b/test/core/end2end/data/server1_cert.c index a303b27282..d31f2e2d0e 100644 --- a/test/core/end2end/data/server1_cert.c +++ b/test/core/end2end/data/server1_cert.c @@ -32,85 +32,84 @@ */ const char test_server1_cert[] = { - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, - 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6d, 0x7a, 0x43, 0x43, - 0x41, 0x67, 0x53, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x42, - 0x41, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, 0x47, - 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x55, 0x46, 0x41, 0x44, 0x42, 0x57, - 0x4d, 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, - 0x45, 0x77, 0x4a, 0x42, 0x56, 0x54, 0x45, 0x54, 0x0a, 0x4d, 0x42, 0x45, - 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, 0x4b, 0x55, 0x32, 0x39, - 0x74, 0x5a, 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, 0x30, 0x5a, 0x54, 0x45, - 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77, - 0x59, 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, 0x75, 0x5a, 0x58, 0x51, - 0x67, 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, 0x30, 0x63, 0x79, 0x42, - 0x51, 0x0a, 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, 0x52, 0x6b, 0x4d, 0x51, - 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x44, 0x41, - 0x5a, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x59, 0x32, 0x45, 0x77, 0x48, 0x68, - 0x63, 0x4e, 0x4d, 0x54, 0x51, 0x77, 0x4e, 0x7a, 0x49, 0x79, 0x4d, 0x44, - 0x59, 0x77, 0x4d, 0x44, 0x55, 0x33, 0x57, 0x68, 0x63, 0x4e, 0x4d, 0x6a, - 0x51, 0x77, 0x4e, 0x7a, 0x45, 0x35, 0x0a, 0x4d, 0x44, 0x59, 0x77, 0x4d, - 0x44, 0x55, 0x33, 0x57, 0x6a, 0x42, 0x6b, 0x4d, 0x51, 0x73, 0x77, 0x43, - 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x56, 0x55, - 0x7a, 0x45, 0x52, 0x4d, 0x41, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, - 0x42, 0x4d, 0x49, 0x53, 0x57, 0x78, 0x73, 0x61, 0x57, 0x35, 0x76, 0x61, - 0x58, 0x4d, 0x78, 0x45, 0x44, 0x41, 0x4f, 0x42, 0x67, 0x4e, 0x56, 0x0a, - 0x42, 0x41, 0x63, 0x54, 0x42, 0x30, 0x4e, 0x6f, 0x61, 0x57, 0x4e, 0x68, - 0x5a, 0x32, 0x38, 0x78, 0x46, 0x44, 0x41, 0x53, 0x42, 0x67, 0x4e, 0x56, - 0x42, 0x41, 0x6f, 0x54, 0x43, 0x30, 0x64, 0x76, 0x62, 0x32, 0x64, 0x73, - 0x5a, 0x53, 0x42, 0x4a, 0x62, 0x6d, 0x4d, 0x75, 0x4d, 0x52, 0x6f, 0x77, - 0x47, 0x41, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x46, 0x42, 0x45, 0x71, - 0x4c, 0x6e, 0x52, 0x6c, 0x0a, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39, - 0x76, 0x5a, 0x32, 0x78, 0x6c, 0x4c, 0x6d, 0x4e, 0x76, 0x62, 0x54, 0x43, - 0x42, 0x6e, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, - 0x47, 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x45, 0x46, 0x41, 0x41, 0x4f, - 0x42, 0x6a, 0x51, 0x41, 0x77, 0x67, 0x59, 0x6b, 0x43, 0x67, 0x59, 0x45, - 0x41, 0x34, 0x63, 0x4d, 0x56, 0x4a, 0x79, 0x67, 0x73, 0x0a, 0x4a, 0x55, - 0x6d, 0x6c, 0x67, 0x4d, 0x4d, 0x7a, 0x67, 0x64, 0x69, 0x30, 0x68, 0x31, - 0x58, 0x6f, 0x43, 0x52, 0x37, 0x2b, 0x77, 0x77, 0x31, 0x70, 0x6f, 0x70, - 0x30, 0x34, 0x4f, 0x4d, 0x4d, 0x79, 0x79, 0x37, 0x48, 0x2f, 0x69, 0x30, - 0x50, 0x4a, 0x32, 0x57, 0x36, 0x59, 0x33, 0x35, 0x2b, 0x62, 0x34, 0x43, - 0x4d, 0x38, 0x51, 0x72, 0x6b, 0x59, 0x65, 0x45, 0x61, 0x66, 0x55, 0x47, - 0x44, 0x4f, 0x0a, 0x52, 0x59, 0x58, 0x36, 0x79, 0x56, 0x2f, 0x63, 0x48, - 0x47, 0x47, 0x73, 0x44, 0x2f, 0x78, 0x30, 0x32, 0x79, 0x65, 0x36, 0x65, - 0x79, 0x31, 0x55, 0x44, 0x74, 0x6b, 0x47, 0x41, 0x44, 0x2f, 0x6d, 0x70, - 0x44, 0x45, 0x78, 0x38, 0x59, 0x43, 0x72, 0x6a, 0x41, 0x63, 0x31, 0x56, - 0x66, 0x76, 0x74, 0x38, 0x46, 0x6b, 0x36, 0x43, 0x6e, 0x31, 0x57, 0x56, - 0x49, 0x78, 0x56, 0x2f, 0x4a, 0x33, 0x30, 0x0a, 0x33, 0x78, 0x6a, 0x42, - 0x73, 0x46, 0x67, 0x42, 0x79, 0x51, 0x35, 0x35, 0x52, 0x42, 0x70, 0x31, - 0x4f, 0x4c, 0x5a, 0x66, 0x56, 0x4c, 0x6f, 0x36, 0x41, 0x6c, 0x65, 0x42, - 0x44, 0x53, 0x62, 0x63, 0x78, 0x61, 0x45, 0x43, 0x41, 0x77, 0x45, 0x41, - 0x41, 0x61, 0x4e, 0x72, 0x4d, 0x47, 0x6b, 0x77, 0x43, 0x51, 0x59, 0x44, - 0x56, 0x52, 0x30, 0x54, 0x42, 0x41, 0x49, 0x77, 0x41, 0x44, 0x41, 0x4c, - 0x0a, 0x42, 0x67, 0x4e, 0x56, 0x48, 0x51, 0x38, 0x45, 0x42, 0x41, 0x4d, - 0x43, 0x42, 0x65, 0x41, 0x77, 0x54, 0x77, 0x59, 0x44, 0x56, 0x52, 0x30, - 0x52, 0x42, 0x45, 0x67, 0x77, 0x52, 0x6f, 0x49, 0x51, 0x4b, 0x69, 0x35, - 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64, 0x76, 0x62, 0x32, 0x64, - 0x73, 0x5a, 0x53, 0x35, 0x6d, 0x63, 0x6f, 0x49, 0x59, 0x64, 0x32, 0x46, - 0x30, 0x5a, 0x58, 0x4a, 0x36, 0x0a, 0x62, 0x32, 0x39, 0x70, 0x4c, 0x6e, - 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39, 0x76, 0x5a, 0x32, - 0x78, 0x6c, 0x4c, 0x6d, 0x4a, 0x6c, 0x67, 0x68, 0x49, 0x71, 0x4c, 0x6e, - 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x65, 0x57, 0x39, 0x31, 0x64, 0x48, - 0x56, 0x69, 0x5a, 0x53, 0x35, 0x6a, 0x62, 0x32, 0x32, 0x48, 0x42, 0x4d, - 0x43, 0x6f, 0x41, 0x51, 0x4d, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x0a, 0x4b, - 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x46, 0x42, - 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, 0x4d, 0x32, 0x49, 0x69, 0x30, - 0x4c, 0x67, 0x54, 0x47, 0x62, 0x4a, 0x31, 0x6a, 0x34, 0x6f, 0x71, 0x58, - 0x39, 0x62, 0x78, 0x56, 0x63, 0x78, 0x6d, 0x2b, 0x2f, 0x52, 0x35, 0x59, - 0x66, 0x38, 0x6f, 0x69, 0x30, 0x61, 0x5a, 0x71, 0x54, 0x4a, 0x6c, 0x6e, - 0x4c, 0x59, 0x53, 0x0a, 0x77, 0x58, 0x63, 0x42, 0x79, 0x6b, 0x78, 0x54, - 0x78, 0x31, 0x38, 0x31, 0x73, 0x37, 0x57, 0x79, 0x66, 0x4a, 0x34, 0x39, - 0x57, 0x77, 0x72, 0x59, 0x58, 0x6f, 0x37, 0x38, 0x7a, 0x54, 0x44, 0x41, - 0x6e, 0x66, 0x31, 0x6d, 0x61, 0x30, 0x66, 0x50, 0x71, 0x33, 0x65, 0x34, - 0x6d, 0x70, 0x73, 0x70, 0x76, 0x79, 0x6e, 0x64, 0x4c, 0x68, 0x31, 0x61, - 0x2b, 0x4f, 0x61, 0x72, 0x48, 0x61, 0x31, 0x65, 0x0a, 0x61, 0x54, 0x30, - 0x44, 0x49, 0x49, 0x59, 0x6b, 0x37, 0x71, 0x65, 0x45, 0x61, 0x31, 0x59, - 0x63, 0x56, 0x6c, 0x6a, 0x78, 0x32, 0x4b, 0x79, 0x4c, 0x64, 0x30, 0x72, - 0x31, 0x42, 0x42, 0x41, 0x66, 0x72, 0x77, 0x79, 0x47, 0x61, 0x45, 0x50, - 0x56, 0x65, 0x4a, 0x51, 0x56, 0x59, 0x57, 0x61, 0x4f, 0x4a, 0x52, 0x55, - 0x32, 0x77, 0x65, 0x2f, 0x4b, 0x44, 0x34, 0x6f, 0x6a, 0x66, 0x39, 0x73, - 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43, - 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x0a, 0x00 -}; + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, + 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x6d, 0x7a, 0x43, 0x43, + 0x41, 0x67, 0x53, 0x67, 0x41, 0x77, 0x49, 0x42, 0x41, 0x67, 0x49, 0x42, + 0x41, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, 0x47, + 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x55, 0x46, 0x41, 0x44, 0x42, 0x57, + 0x4d, 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, + 0x45, 0x77, 0x4a, 0x42, 0x56, 0x54, 0x45, 0x54, 0x0a, 0x4d, 0x42, 0x45, + 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, 0x4b, 0x55, 0x32, 0x39, + 0x74, 0x5a, 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, 0x30, 0x5a, 0x54, 0x45, + 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77, + 0x59, 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, 0x75, 0x5a, 0x58, 0x51, + 0x67, 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, 0x30, 0x63, 0x79, 0x42, + 0x51, 0x0a, 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, 0x52, 0x6b, 0x4d, 0x51, + 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x44, 0x41, + 0x5a, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x59, 0x32, 0x45, 0x77, 0x48, 0x68, + 0x63, 0x4e, 0x4d, 0x54, 0x51, 0x77, 0x4e, 0x7a, 0x49, 0x79, 0x4d, 0x44, + 0x59, 0x77, 0x4d, 0x44, 0x55, 0x33, 0x57, 0x68, 0x63, 0x4e, 0x4d, 0x6a, + 0x51, 0x77, 0x4e, 0x7a, 0x45, 0x35, 0x0a, 0x4d, 0x44, 0x59, 0x77, 0x4d, + 0x44, 0x55, 0x33, 0x57, 0x6a, 0x42, 0x6b, 0x4d, 0x51, 0x73, 0x77, 0x43, + 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x56, 0x55, + 0x7a, 0x45, 0x52, 0x4d, 0x41, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, + 0x42, 0x4d, 0x49, 0x53, 0x57, 0x78, 0x73, 0x61, 0x57, 0x35, 0x76, 0x61, + 0x58, 0x4d, 0x78, 0x45, 0x44, 0x41, 0x4f, 0x42, 0x67, 0x4e, 0x56, 0x0a, + 0x42, 0x41, 0x63, 0x54, 0x42, 0x30, 0x4e, 0x6f, 0x61, 0x57, 0x4e, 0x68, + 0x5a, 0x32, 0x38, 0x78, 0x46, 0x44, 0x41, 0x53, 0x42, 0x67, 0x4e, 0x56, + 0x42, 0x41, 0x6f, 0x54, 0x43, 0x30, 0x64, 0x76, 0x62, 0x32, 0x64, 0x73, + 0x5a, 0x53, 0x42, 0x4a, 0x62, 0x6d, 0x4d, 0x75, 0x4d, 0x52, 0x6f, 0x77, + 0x47, 0x41, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x46, 0x42, 0x45, 0x71, + 0x4c, 0x6e, 0x52, 0x6c, 0x0a, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39, + 0x76, 0x5a, 0x32, 0x78, 0x6c, 0x4c, 0x6d, 0x4e, 0x76, 0x62, 0x54, 0x43, + 0x42, 0x6e, 0x7a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, 0x68, 0x6b, 0x69, + 0x47, 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x45, 0x46, 0x41, 0x41, 0x4f, + 0x42, 0x6a, 0x51, 0x41, 0x77, 0x67, 0x59, 0x6b, 0x43, 0x67, 0x59, 0x45, + 0x41, 0x34, 0x63, 0x4d, 0x56, 0x4a, 0x79, 0x67, 0x73, 0x0a, 0x4a, 0x55, + 0x6d, 0x6c, 0x67, 0x4d, 0x4d, 0x7a, 0x67, 0x64, 0x69, 0x30, 0x68, 0x31, + 0x58, 0x6f, 0x43, 0x52, 0x37, 0x2b, 0x77, 0x77, 0x31, 0x70, 0x6f, 0x70, + 0x30, 0x34, 0x4f, 0x4d, 0x4d, 0x79, 0x79, 0x37, 0x48, 0x2f, 0x69, 0x30, + 0x50, 0x4a, 0x32, 0x57, 0x36, 0x59, 0x33, 0x35, 0x2b, 0x62, 0x34, 0x43, + 0x4d, 0x38, 0x51, 0x72, 0x6b, 0x59, 0x65, 0x45, 0x61, 0x66, 0x55, 0x47, + 0x44, 0x4f, 0x0a, 0x52, 0x59, 0x58, 0x36, 0x79, 0x56, 0x2f, 0x63, 0x48, + 0x47, 0x47, 0x73, 0x44, 0x2f, 0x78, 0x30, 0x32, 0x79, 0x65, 0x36, 0x65, + 0x79, 0x31, 0x55, 0x44, 0x74, 0x6b, 0x47, 0x41, 0x44, 0x2f, 0x6d, 0x70, + 0x44, 0x45, 0x78, 0x38, 0x59, 0x43, 0x72, 0x6a, 0x41, 0x63, 0x31, 0x56, + 0x66, 0x76, 0x74, 0x38, 0x46, 0x6b, 0x36, 0x43, 0x6e, 0x31, 0x57, 0x56, + 0x49, 0x78, 0x56, 0x2f, 0x4a, 0x33, 0x30, 0x0a, 0x33, 0x78, 0x6a, 0x42, + 0x73, 0x46, 0x67, 0x42, 0x79, 0x51, 0x35, 0x35, 0x52, 0x42, 0x70, 0x31, + 0x4f, 0x4c, 0x5a, 0x66, 0x56, 0x4c, 0x6f, 0x36, 0x41, 0x6c, 0x65, 0x42, + 0x44, 0x53, 0x62, 0x63, 0x78, 0x61, 0x45, 0x43, 0x41, 0x77, 0x45, 0x41, + 0x41, 0x61, 0x4e, 0x72, 0x4d, 0x47, 0x6b, 0x77, 0x43, 0x51, 0x59, 0x44, + 0x56, 0x52, 0x30, 0x54, 0x42, 0x41, 0x49, 0x77, 0x41, 0x44, 0x41, 0x4c, + 0x0a, 0x42, 0x67, 0x4e, 0x56, 0x48, 0x51, 0x38, 0x45, 0x42, 0x41, 0x4d, + 0x43, 0x42, 0x65, 0x41, 0x77, 0x54, 0x77, 0x59, 0x44, 0x56, 0x52, 0x30, + 0x52, 0x42, 0x45, 0x67, 0x77, 0x52, 0x6f, 0x49, 0x51, 0x4b, 0x69, 0x35, + 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x4c, 0x6d, 0x64, 0x76, 0x62, 0x32, 0x64, + 0x73, 0x5a, 0x53, 0x35, 0x6d, 0x63, 0x6f, 0x49, 0x59, 0x64, 0x32, 0x46, + 0x30, 0x5a, 0x58, 0x4a, 0x36, 0x0a, 0x62, 0x32, 0x39, 0x70, 0x4c, 0x6e, + 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x5a, 0x32, 0x39, 0x76, 0x5a, 0x32, + 0x78, 0x6c, 0x4c, 0x6d, 0x4a, 0x6c, 0x67, 0x68, 0x49, 0x71, 0x4c, 0x6e, + 0x52, 0x6c, 0x63, 0x33, 0x51, 0x75, 0x65, 0x57, 0x39, 0x31, 0x64, 0x48, + 0x56, 0x69, 0x5a, 0x53, 0x35, 0x6a, 0x62, 0x32, 0x32, 0x48, 0x42, 0x4d, + 0x43, 0x6f, 0x41, 0x51, 0x4d, 0x77, 0x44, 0x51, 0x59, 0x4a, 0x0a, 0x4b, + 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, 0x41, 0x51, 0x45, 0x46, 0x42, + 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, 0x4d, 0x32, 0x49, 0x69, 0x30, + 0x4c, 0x67, 0x54, 0x47, 0x62, 0x4a, 0x31, 0x6a, 0x34, 0x6f, 0x71, 0x58, + 0x39, 0x62, 0x78, 0x56, 0x63, 0x78, 0x6d, 0x2b, 0x2f, 0x52, 0x35, 0x59, + 0x66, 0x38, 0x6f, 0x69, 0x30, 0x61, 0x5a, 0x71, 0x54, 0x4a, 0x6c, 0x6e, + 0x4c, 0x59, 0x53, 0x0a, 0x77, 0x58, 0x63, 0x42, 0x79, 0x6b, 0x78, 0x54, + 0x78, 0x31, 0x38, 0x31, 0x73, 0x37, 0x57, 0x79, 0x66, 0x4a, 0x34, 0x39, + 0x57, 0x77, 0x72, 0x59, 0x58, 0x6f, 0x37, 0x38, 0x7a, 0x54, 0x44, 0x41, + 0x6e, 0x66, 0x31, 0x6d, 0x61, 0x30, 0x66, 0x50, 0x71, 0x33, 0x65, 0x34, + 0x6d, 0x70, 0x73, 0x70, 0x76, 0x79, 0x6e, 0x64, 0x4c, 0x68, 0x31, 0x61, + 0x2b, 0x4f, 0x61, 0x72, 0x48, 0x61, 0x31, 0x65, 0x0a, 0x61, 0x54, 0x30, + 0x44, 0x49, 0x49, 0x59, 0x6b, 0x37, 0x71, 0x65, 0x45, 0x61, 0x31, 0x59, + 0x63, 0x56, 0x6c, 0x6a, 0x78, 0x32, 0x4b, 0x79, 0x4c, 0x64, 0x30, 0x72, + 0x31, 0x42, 0x42, 0x41, 0x66, 0x72, 0x77, 0x79, 0x47, 0x61, 0x45, 0x50, + 0x56, 0x65, 0x4a, 0x51, 0x56, 0x59, 0x57, 0x61, 0x4f, 0x4a, 0x52, 0x55, + 0x32, 0x77, 0x65, 0x2f, 0x4b, 0x44, 0x34, 0x6f, 0x6a, 0x66, 0x39, 0x73, + 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43, + 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x00}; diff --git a/test/core/end2end/data/server1_key.c b/test/core/end2end/data/server1_key.c index 78353eed6d..d089660bfd 100644 --- a/test/core/end2end/data/server1_key.c +++ b/test/core/end2end/data/server1_key.c @@ -32,78 +32,77 @@ */ const char test_server1_key[] = { - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, - 0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, - 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, - 0x57, 0x77, 0x49, 0x42, 0x41, 0x41, 0x4b, 0x42, 0x67, 0x51, 0x44, 0x68, - 0x77, 0x78, 0x55, 0x6e, 0x4b, 0x43, 0x77, 0x6c, 0x53, 0x61, 0x57, 0x41, - 0x77, 0x7a, 0x4f, 0x42, 0x32, 0x4c, 0x53, 0x48, 0x56, 0x65, 0x67, 0x4a, - 0x48, 0x76, 0x37, 0x44, 0x44, 0x57, 0x6d, 0x69, 0x6e, 0x54, 0x67, 0x34, - 0x77, 0x7a, 0x4c, 0x4c, 0x73, 0x66, 0x2b, 0x4c, 0x51, 0x38, 0x6e, 0x5a, - 0x0a, 0x62, 0x70, 0x6a, 0x66, 0x6e, 0x35, 0x76, 0x67, 0x49, 0x7a, 0x78, - 0x43, 0x75, 0x52, 0x68, 0x34, 0x52, 0x70, 0x39, 0x51, 0x59, 0x4d, 0x35, - 0x46, 0x68, 0x66, 0x72, 0x4a, 0x58, 0x39, 0x77, 0x63, 0x59, 0x61, 0x77, - 0x50, 0x2f, 0x48, 0x54, 0x62, 0x4a, 0x37, 0x70, 0x37, 0x4c, 0x56, 0x51, - 0x4f, 0x32, 0x51, 0x59, 0x41, 0x50, 0x2b, 0x61, 0x6b, 0x4d, 0x54, 0x48, - 0x78, 0x67, 0x4b, 0x75, 0x4d, 0x0a, 0x42, 0x7a, 0x56, 0x56, 0x2b, 0x2b, - 0x33, 0x77, 0x57, 0x54, 0x6f, 0x4b, 0x66, 0x56, 0x5a, 0x55, 0x6a, 0x46, - 0x58, 0x38, 0x6e, 0x66, 0x54, 0x66, 0x47, 0x4d, 0x47, 0x77, 0x57, 0x41, - 0x48, 0x4a, 0x44, 0x6e, 0x6c, 0x45, 0x47, 0x6e, 0x55, 0x34, 0x74, 0x6c, - 0x39, 0x55, 0x75, 0x6a, 0x6f, 0x43, 0x56, 0x34, 0x45, 0x4e, 0x4a, 0x74, - 0x7a, 0x46, 0x6f, 0x51, 0x49, 0x44, 0x41, 0x51, 0x41, 0x42, 0x0a, 0x41, - 0x6f, 0x47, 0x41, 0x4a, 0x2b, 0x36, 0x68, 0x70, 0x7a, 0x4e, 0x72, 0x32, - 0x34, 0x79, 0x54, 0x51, 0x5a, 0x74, 0x46, 0x57, 0x51, 0x70, 0x44, 0x70, - 0x45, 0x79, 0x46, 0x70, 0x6c, 0x64, 0x64, 0x4b, 0x4a, 0x4d, 0x4f, 0x78, - 0x44, 0x79, 0x61, 0x33, 0x53, 0x39, 0x70, 0x70, 0x4b, 0x33, 0x76, 0x54, - 0x57, 0x72, 0x49, 0x49, 0x54, 0x56, 0x32, 0x78, 0x4e, 0x63, 0x75, 0x63, - 0x77, 0x37, 0x49, 0x0a, 0x63, 0x65, 0x54, 0x62, 0x64, 0x79, 0x72, 0x47, - 0x73, 0x79, 0x6a, 0x73, 0x55, 0x30, 0x2f, 0x48, 0x64, 0x43, 0x63, 0x49, - 0x66, 0x39, 0x79, 0x6d, 0x32, 0x6a, 0x66, 0x6d, 0x47, 0x4c, 0x55, 0x77, - 0x6d, 0x79, 0x68, 0x6c, 0x74, 0x4b, 0x56, 0x77, 0x30, 0x51, 0x59, 0x63, - 0x46, 0x42, 0x30, 0x58, 0x4c, 0x6b, 0x63, 0x30, 0x6e, 0x49, 0x35, 0x59, - 0x76, 0x45, 0x59, 0x6f, 0x65, 0x56, 0x44, 0x67, 0x0a, 0x6f, 0x6d, 0x5a, - 0x49, 0x58, 0x6e, 0x31, 0x45, 0x33, 0x45, 0x57, 0x2b, 0x73, 0x53, 0x49, - 0x57, 0x53, 0x62, 0x6b, 0x4d, 0x75, 0x39, 0x62, 0x59, 0x32, 0x6b, 0x73, - 0x74, 0x4b, 0x58, 0x52, 0x32, 0x55, 0x5a, 0x6d, 0x4d, 0x67, 0x57, 0x44, - 0x74, 0x6d, 0x42, 0x45, 0x50, 0x4d, 0x61, 0x45, 0x43, 0x51, 0x51, 0x44, - 0x36, 0x79, 0x54, 0x34, 0x54, 0x41, 0x5a, 0x4d, 0x35, 0x68, 0x47, 0x42, - 0x62, 0x0a, 0x63, 0x69, 0x42, 0x4b, 0x67, 0x4d, 0x55, 0x50, 0x36, 0x50, - 0x77, 0x4f, 0x68, 0x50, 0x68, 0x4f, 0x4d, 0x50, 0x49, 0x76, 0x69, 0x6a, - 0x4f, 0x35, 0x30, 0x41, 0x69, 0x75, 0x36, 0x69, 0x75, 0x43, 0x56, 0x38, - 0x38, 0x6c, 0x31, 0x51, 0x49, 0x79, 0x33, 0x38, 0x67, 0x57, 0x56, 0x68, - 0x78, 0x6a, 0x4e, 0x72, 0x71, 0x36, 0x50, 0x33, 0x34, 0x36, 0x6a, 0x34, - 0x49, 0x42, 0x67, 0x2b, 0x6b, 0x42, 0x0a, 0x39, 0x61, 0x6c, 0x77, 0x70, - 0x43, 0x4f, 0x44, 0x41, 0x6b, 0x45, 0x41, 0x35, 0x6e, 0x53, 0x6e, 0x6d, - 0x39, 0x6b, 0x36, 0x79, 0x6b, 0x59, 0x65, 0x51, 0x57, 0x4e, 0x53, 0x30, - 0x66, 0x4e, 0x57, 0x69, 0x52, 0x69, 0x6e, 0x43, 0x64, 0x6c, 0x32, 0x33, - 0x41, 0x37, 0x75, 0x73, 0x44, 0x47, 0x53, 0x75, 0x4b, 0x4b, 0x6c, 0x6d, - 0x30, 0x31, 0x39, 0x69, 0x6f, 0x6d, 0x4a, 0x2f, 0x52, 0x67, 0x64, 0x0a, - 0x4d, 0x4b, 0x44, 0x4f, 0x70, 0x30, 0x71, 0x2f, 0x32, 0x4f, 0x6f, 0x73, - 0x74, 0x62, 0x74, 0x65, 0x4f, 0x57, 0x4d, 0x32, 0x4d, 0x52, 0x46, 0x66, - 0x34, 0x6a, 0x4d, 0x48, 0x33, 0x77, 0x79, 0x56, 0x43, 0x77, 0x4a, 0x41, - 0x66, 0x41, 0x64, 0x6a, 0x4a, 0x38, 0x73, 0x7a, 0x6f, 0x4e, 0x4b, 0x54, - 0x52, 0x53, 0x61, 0x67, 0x53, 0x62, 0x68, 0x39, 0x76, 0x57, 0x79, 0x67, - 0x6e, 0x42, 0x32, 0x76, 0x0a, 0x49, 0x42, 0x79, 0x63, 0x36, 0x6c, 0x34, - 0x54, 0x54, 0x75, 0x5a, 0x51, 0x4a, 0x52, 0x47, 0x7a, 0x43, 0x76, 0x65, - 0x61, 0x66, 0x7a, 0x39, 0x6c, 0x6f, 0x76, 0x75, 0x42, 0x33, 0x57, 0x6f, - 0x68, 0x43, 0x41, 0x42, 0x64, 0x51, 0x52, 0x64, 0x39, 0x75, 0x6b, 0x43, - 0x58, 0x4c, 0x32, 0x43, 0x70, 0x73, 0x45, 0x70, 0x71, 0x7a, 0x6b, 0x61, - 0x66, 0x4f, 0x51, 0x4a, 0x41, 0x4a, 0x55, 0x6a, 0x63, 0x0a, 0x55, 0x53, - 0x65, 0x64, 0x44, 0x6c, 0x71, 0x33, 0x7a, 0x47, 0x5a, 0x77, 0x59, 0x4d, - 0x31, 0x59, 0x77, 0x38, 0x64, 0x38, 0x52, 0x75, 0x69, 0x72, 0x42, 0x55, - 0x46, 0x5a, 0x4e, 0x71, 0x4a, 0x65, 0x6c, 0x59, 0x61, 0x69, 0x2b, 0x6e, - 0x52, 0x59, 0x43, 0x6c, 0x44, 0x6b, 0x52, 0x56, 0x46, 0x67, 0x62, 0x35, - 0x79, 0x6b, 0x73, 0x6f, 0x59, 0x79, 0x63, 0x62, 0x71, 0x35, 0x54, 0x78, - 0x47, 0x6f, 0x0a, 0x56, 0x65, 0x71, 0x4b, 0x4f, 0x76, 0x67, 0x50, 0x70, - 0x6a, 0x34, 0x52, 0x57, 0x50, 0x48, 0x6c, 0x4c, 0x77, 0x4a, 0x41, 0x47, - 0x55, 0x4d, 0x6b, 0x33, 0x62, 0x71, 0x54, 0x39, 0x31, 0x78, 0x42, 0x55, - 0x43, 0x6e, 0x4c, 0x52, 0x73, 0x2f, 0x76, 0x66, 0x6f, 0x43, 0x70, 0x48, - 0x70, 0x67, 0x36, 0x65, 0x79, 0x77, 0x51, 0x54, 0x42, 0x44, 0x41, 0x56, - 0x36, 0x78, 0x6b, 0x79, 0x7a, 0x34, 0x61, 0x0a, 0x52, 0x48, 0x33, 0x49, - 0x37, 0x2f, 0x2b, 0x79, 0x6a, 0x33, 0x5a, 0x78, 0x52, 0x32, 0x4a, 0x6f, - 0x57, 0x48, 0x67, 0x55, 0x77, 0x5a, 0x37, 0x6c, 0x5a, 0x6b, 0x31, 0x56, - 0x6e, 0x68, 0x66, 0x66, 0x46, 0x79, 0x65, 0x37, 0x53, 0x42, 0x58, 0x79, - 0x61, 0x67, 0x3d, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, - 0x44, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, - 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00 -}; + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x52, + 0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, 0x45, 0x20, 0x4b, + 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, + 0x57, 0x77, 0x49, 0x42, 0x41, 0x41, 0x4b, 0x42, 0x67, 0x51, 0x44, 0x68, + 0x77, 0x78, 0x55, 0x6e, 0x4b, 0x43, 0x77, 0x6c, 0x53, 0x61, 0x57, 0x41, + 0x77, 0x7a, 0x4f, 0x42, 0x32, 0x4c, 0x53, 0x48, 0x56, 0x65, 0x67, 0x4a, + 0x48, 0x76, 0x37, 0x44, 0x44, 0x57, 0x6d, 0x69, 0x6e, 0x54, 0x67, 0x34, + 0x77, 0x7a, 0x4c, 0x4c, 0x73, 0x66, 0x2b, 0x4c, 0x51, 0x38, 0x6e, 0x5a, + 0x0a, 0x62, 0x70, 0x6a, 0x66, 0x6e, 0x35, 0x76, 0x67, 0x49, 0x7a, 0x78, + 0x43, 0x75, 0x52, 0x68, 0x34, 0x52, 0x70, 0x39, 0x51, 0x59, 0x4d, 0x35, + 0x46, 0x68, 0x66, 0x72, 0x4a, 0x58, 0x39, 0x77, 0x63, 0x59, 0x61, 0x77, + 0x50, 0x2f, 0x48, 0x54, 0x62, 0x4a, 0x37, 0x70, 0x37, 0x4c, 0x56, 0x51, + 0x4f, 0x32, 0x51, 0x59, 0x41, 0x50, 0x2b, 0x61, 0x6b, 0x4d, 0x54, 0x48, + 0x78, 0x67, 0x4b, 0x75, 0x4d, 0x0a, 0x42, 0x7a, 0x56, 0x56, 0x2b, 0x2b, + 0x33, 0x77, 0x57, 0x54, 0x6f, 0x4b, 0x66, 0x56, 0x5a, 0x55, 0x6a, 0x46, + 0x58, 0x38, 0x6e, 0x66, 0x54, 0x66, 0x47, 0x4d, 0x47, 0x77, 0x57, 0x41, + 0x48, 0x4a, 0x44, 0x6e, 0x6c, 0x45, 0x47, 0x6e, 0x55, 0x34, 0x74, 0x6c, + 0x39, 0x55, 0x75, 0x6a, 0x6f, 0x43, 0x56, 0x34, 0x45, 0x4e, 0x4a, 0x74, + 0x7a, 0x46, 0x6f, 0x51, 0x49, 0x44, 0x41, 0x51, 0x41, 0x42, 0x0a, 0x41, + 0x6f, 0x47, 0x41, 0x4a, 0x2b, 0x36, 0x68, 0x70, 0x7a, 0x4e, 0x72, 0x32, + 0x34, 0x79, 0x54, 0x51, 0x5a, 0x74, 0x46, 0x57, 0x51, 0x70, 0x44, 0x70, + 0x45, 0x79, 0x46, 0x70, 0x6c, 0x64, 0x64, 0x4b, 0x4a, 0x4d, 0x4f, 0x78, + 0x44, 0x79, 0x61, 0x33, 0x53, 0x39, 0x70, 0x70, 0x4b, 0x33, 0x76, 0x54, + 0x57, 0x72, 0x49, 0x49, 0x54, 0x56, 0x32, 0x78, 0x4e, 0x63, 0x75, 0x63, + 0x77, 0x37, 0x49, 0x0a, 0x63, 0x65, 0x54, 0x62, 0x64, 0x79, 0x72, 0x47, + 0x73, 0x79, 0x6a, 0x73, 0x55, 0x30, 0x2f, 0x48, 0x64, 0x43, 0x63, 0x49, + 0x66, 0x39, 0x79, 0x6d, 0x32, 0x6a, 0x66, 0x6d, 0x47, 0x4c, 0x55, 0x77, + 0x6d, 0x79, 0x68, 0x6c, 0x74, 0x4b, 0x56, 0x77, 0x30, 0x51, 0x59, 0x63, + 0x46, 0x42, 0x30, 0x58, 0x4c, 0x6b, 0x63, 0x30, 0x6e, 0x49, 0x35, 0x59, + 0x76, 0x45, 0x59, 0x6f, 0x65, 0x56, 0x44, 0x67, 0x0a, 0x6f, 0x6d, 0x5a, + 0x49, 0x58, 0x6e, 0x31, 0x45, 0x33, 0x45, 0x57, 0x2b, 0x73, 0x53, 0x49, + 0x57, 0x53, 0x62, 0x6b, 0x4d, 0x75, 0x39, 0x62, 0x59, 0x32, 0x6b, 0x73, + 0x74, 0x4b, 0x58, 0x52, 0x32, 0x55, 0x5a, 0x6d, 0x4d, 0x67, 0x57, 0x44, + 0x74, 0x6d, 0x42, 0x45, 0x50, 0x4d, 0x61, 0x45, 0x43, 0x51, 0x51, 0x44, + 0x36, 0x79, 0x54, 0x34, 0x54, 0x41, 0x5a, 0x4d, 0x35, 0x68, 0x47, 0x42, + 0x62, 0x0a, 0x63, 0x69, 0x42, 0x4b, 0x67, 0x4d, 0x55, 0x50, 0x36, 0x50, + 0x77, 0x4f, 0x68, 0x50, 0x68, 0x4f, 0x4d, 0x50, 0x49, 0x76, 0x69, 0x6a, + 0x4f, 0x35, 0x30, 0x41, 0x69, 0x75, 0x36, 0x69, 0x75, 0x43, 0x56, 0x38, + 0x38, 0x6c, 0x31, 0x51, 0x49, 0x79, 0x33, 0x38, 0x67, 0x57, 0x56, 0x68, + 0x78, 0x6a, 0x4e, 0x72, 0x71, 0x36, 0x50, 0x33, 0x34, 0x36, 0x6a, 0x34, + 0x49, 0x42, 0x67, 0x2b, 0x6b, 0x42, 0x0a, 0x39, 0x61, 0x6c, 0x77, 0x70, + 0x43, 0x4f, 0x44, 0x41, 0x6b, 0x45, 0x41, 0x35, 0x6e, 0x53, 0x6e, 0x6d, + 0x39, 0x6b, 0x36, 0x79, 0x6b, 0x59, 0x65, 0x51, 0x57, 0x4e, 0x53, 0x30, + 0x66, 0x4e, 0x57, 0x69, 0x52, 0x69, 0x6e, 0x43, 0x64, 0x6c, 0x32, 0x33, + 0x41, 0x37, 0x75, 0x73, 0x44, 0x47, 0x53, 0x75, 0x4b, 0x4b, 0x6c, 0x6d, + 0x30, 0x31, 0x39, 0x69, 0x6f, 0x6d, 0x4a, 0x2f, 0x52, 0x67, 0x64, 0x0a, + 0x4d, 0x4b, 0x44, 0x4f, 0x70, 0x30, 0x71, 0x2f, 0x32, 0x4f, 0x6f, 0x73, + 0x74, 0x62, 0x74, 0x65, 0x4f, 0x57, 0x4d, 0x32, 0x4d, 0x52, 0x46, 0x66, + 0x34, 0x6a, 0x4d, 0x48, 0x33, 0x77, 0x79, 0x56, 0x43, 0x77, 0x4a, 0x41, + 0x66, 0x41, 0x64, 0x6a, 0x4a, 0x38, 0x73, 0x7a, 0x6f, 0x4e, 0x4b, 0x54, + 0x52, 0x53, 0x61, 0x67, 0x53, 0x62, 0x68, 0x39, 0x76, 0x57, 0x79, 0x67, + 0x6e, 0x42, 0x32, 0x76, 0x0a, 0x49, 0x42, 0x79, 0x63, 0x36, 0x6c, 0x34, + 0x54, 0x54, 0x75, 0x5a, 0x51, 0x4a, 0x52, 0x47, 0x7a, 0x43, 0x76, 0x65, + 0x61, 0x66, 0x7a, 0x39, 0x6c, 0x6f, 0x76, 0x75, 0x42, 0x33, 0x57, 0x6f, + 0x68, 0x43, 0x41, 0x42, 0x64, 0x51, 0x52, 0x64, 0x39, 0x75, 0x6b, 0x43, + 0x58, 0x4c, 0x32, 0x43, 0x70, 0x73, 0x45, 0x70, 0x71, 0x7a, 0x6b, 0x61, + 0x66, 0x4f, 0x51, 0x4a, 0x41, 0x4a, 0x55, 0x6a, 0x63, 0x0a, 0x55, 0x53, + 0x65, 0x64, 0x44, 0x6c, 0x71, 0x33, 0x7a, 0x47, 0x5a, 0x77, 0x59, 0x4d, + 0x31, 0x59, 0x77, 0x38, 0x64, 0x38, 0x52, 0x75, 0x69, 0x72, 0x42, 0x55, + 0x46, 0x5a, 0x4e, 0x71, 0x4a, 0x65, 0x6c, 0x59, 0x61, 0x69, 0x2b, 0x6e, + 0x52, 0x59, 0x43, 0x6c, 0x44, 0x6b, 0x52, 0x56, 0x46, 0x67, 0x62, 0x35, + 0x79, 0x6b, 0x73, 0x6f, 0x59, 0x79, 0x63, 0x62, 0x71, 0x35, 0x54, 0x78, + 0x47, 0x6f, 0x0a, 0x56, 0x65, 0x71, 0x4b, 0x4f, 0x76, 0x67, 0x50, 0x70, + 0x6a, 0x34, 0x52, 0x57, 0x50, 0x48, 0x6c, 0x4c, 0x77, 0x4a, 0x41, 0x47, + 0x55, 0x4d, 0x6b, 0x33, 0x62, 0x71, 0x54, 0x39, 0x31, 0x78, 0x42, 0x55, + 0x43, 0x6e, 0x4c, 0x52, 0x73, 0x2f, 0x76, 0x66, 0x6f, 0x43, 0x70, 0x48, + 0x70, 0x67, 0x36, 0x65, 0x79, 0x77, 0x51, 0x54, 0x42, 0x44, 0x41, 0x56, + 0x36, 0x78, 0x6b, 0x79, 0x7a, 0x34, 0x61, 0x0a, 0x52, 0x48, 0x33, 0x49, + 0x37, 0x2f, 0x2b, 0x79, 0x6a, 0x33, 0x5a, 0x78, 0x52, 0x32, 0x4a, 0x6f, + 0x57, 0x48, 0x67, 0x55, 0x77, 0x5a, 0x37, 0x6c, 0x5a, 0x6b, 0x31, 0x56, + 0x6e, 0x68, 0x66, 0x66, 0x46, 0x79, 0x65, 0x37, 0x53, 0x42, 0x58, 0x79, + 0x61, 0x67, 0x3d, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x45, 0x4e, + 0x44, 0x20, 0x52, 0x53, 0x41, 0x20, 0x50, 0x52, 0x49, 0x56, 0x41, 0x54, + 0x45, 0x20, 0x4b, 0x45, 0x59, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00}; diff --git a/test/core/end2end/data/test_root_cert.c b/test/core/end2end/data/test_root_cert.c index f8e69e61b2..58d9805017 100644 --- a/test/core/end2end/data/test_root_cert.c +++ b/test/core/end2end/data/test_root_cert.c @@ -32,71 +32,70 @@ */ const char test_root_cert[] = { - 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, - 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, - 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x49, 0x7a, 0x43, 0x43, - 0x41, 0x59, 0x77, 0x43, 0x43, 0x51, 0x43, 0x46, 0x54, 0x62, 0x46, 0x37, - 0x58, 0x4e, 0x53, 0x76, 0x76, 0x6a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, - 0x68, 0x6b, 0x69, 0x47, 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x55, 0x46, - 0x41, 0x44, 0x42, 0x57, 0x4d, 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, - 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x42, 0x0a, 0x56, 0x54, 0x45, - 0x54, 0x4d, 0x42, 0x45, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, - 0x4b, 0x55, 0x32, 0x39, 0x74, 0x5a, 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, - 0x30, 0x5a, 0x54, 0x45, 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, - 0x45, 0x43, 0x67, 0x77, 0x59, 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, - 0x75, 0x5a, 0x58, 0x51, 0x67, 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, - 0x30, 0x0a, 0x63, 0x79, 0x42, 0x51, 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, - 0x52, 0x6b, 0x4d, 0x51, 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, - 0x51, 0x44, 0x44, 0x41, 0x5a, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x59, 0x32, - 0x45, 0x77, 0x48, 0x68, 0x63, 0x4e, 0x4d, 0x54, 0x51, 0x77, 0x4e, 0x7a, - 0x45, 0x33, 0x4d, 0x6a, 0x4d, 0x78, 0x4e, 0x7a, 0x55, 0x78, 0x57, 0x68, - 0x63, 0x4e, 0x4d, 0x6a, 0x51, 0x77, 0x0a, 0x4e, 0x7a, 0x45, 0x30, 0x4d, - 0x6a, 0x4d, 0x78, 0x4e, 0x7a, 0x55, 0x78, 0x57, 0x6a, 0x42, 0x57, 0x4d, - 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, - 0x77, 0x4a, 0x42, 0x56, 0x54, 0x45, 0x54, 0x4d, 0x42, 0x45, 0x47, 0x41, - 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, 0x4b, 0x55, 0x32, 0x39, 0x74, 0x5a, - 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, 0x30, 0x5a, 0x54, 0x45, 0x68, 0x0a, - 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77, 0x59, - 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, 0x75, 0x5a, 0x58, 0x51, 0x67, - 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, 0x30, 0x63, 0x79, 0x42, 0x51, - 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, 0x52, 0x6b, 0x4d, 0x51, 0x38, 0x77, - 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x44, 0x41, 0x5a, 0x30, - 0x5a, 0x58, 0x4e, 0x30, 0x0a, 0x59, 0x32, 0x45, 0x77, 0x67, 0x5a, 0x38, - 0x77, 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, - 0x4e, 0x41, 0x51, 0x45, 0x42, 0x42, 0x51, 0x41, 0x44, 0x67, 0x59, 0x30, - 0x41, 0x4d, 0x49, 0x47, 0x4a, 0x41, 0x6f, 0x47, 0x42, 0x41, 0x4d, 0x42, - 0x41, 0x33, 0x77, 0x56, 0x65, 0x54, 0x47, 0x48, 0x5a, 0x52, 0x31, 0x52, - 0x79, 0x65, 0x2f, 0x69, 0x2b, 0x4a, 0x38, 0x61, 0x32, 0x0a, 0x63, 0x75, - 0x35, 0x67, 0x58, 0x77, 0x46, 0x56, 0x36, 0x54, 0x6e, 0x4f, 0x62, 0x7a, - 0x47, 0x4d, 0x37, 0x62, 0x4c, 0x46, 0x43, 0x4f, 0x35, 0x69, 0x39, 0x76, - 0x34, 0x6d, 0x4c, 0x6f, 0x34, 0x69, 0x46, 0x7a, 0x50, 0x73, 0x48, 0x6d, - 0x57, 0x44, 0x55, 0x78, 0x4b, 0x53, 0x33, 0x59, 0x38, 0x69, 0x58, 0x62, - 0x75, 0x30, 0x65, 0x59, 0x42, 0x6c, 0x4c, 0x6f, 0x4e, 0x59, 0x30, 0x6c, - 0x53, 0x76, 0x0a, 0x78, 0x44, 0x78, 0x33, 0x33, 0x4f, 0x2b, 0x44, 0x75, - 0x77, 0x4d, 0x6d, 0x56, 0x4e, 0x2b, 0x44, 0x7a, 0x53, 0x44, 0x2b, 0x45, - 0x6f, 0x64, 0x39, 0x7a, 0x66, 0x76, 0x77, 0x4f, 0x57, 0x48, 0x73, 0x61, - 0x7a, 0x59, 0x43, 0x5a, 0x54, 0x32, 0x50, 0x68, 0x4e, 0x78, 0x6e, 0x56, - 0x57, 0x49, 0x75, 0x4a, 0x58, 0x56, 0x69, 0x59, 0x34, 0x4a, 0x41, 0x48, - 0x55, 0x47, 0x6f, 0x64, 0x6a, 0x78, 0x2b, 0x0a, 0x51, 0x41, 0x69, 0x36, - 0x79, 0x43, 0x41, 0x75, 0x72, 0x55, 0x5a, 0x47, 0x76, 0x59, 0x58, 0x47, - 0x67, 0x5a, 0x53, 0x42, 0x41, 0x67, 0x4d, 0x42, 0x41, 0x41, 0x45, 0x77, - 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, - 0x41, 0x51, 0x45, 0x46, 0x42, 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, - 0x51, 0x6f, 0x51, 0x56, 0x44, 0x38, 0x62, 0x77, 0x64, 0x74, 0x57, 0x4a, - 0x0a, 0x41, 0x6e, 0x69, 0x47, 0x42, 0x77, 0x63, 0x43, 0x66, 0x71, 0x59, - 0x79, 0x48, 0x2b, 0x2f, 0x4b, 0x70, 0x41, 0x31, 0x30, 0x41, 0x63, 0x65, - 0x62, 0x4a, 0x56, 0x56, 0x54, 0x79, 0x59, 0x62, 0x59, 0x76, 0x49, 0x39, - 0x51, 0x38, 0x64, 0x36, 0x52, 0x53, 0x56, 0x75, 0x34, 0x50, 0x5a, 0x79, - 0x39, 0x4f, 0x41, 0x4c, 0x48, 0x52, 0x2f, 0x51, 0x72, 0x57, 0x42, 0x64, - 0x59, 0x54, 0x41, 0x79, 0x7a, 0x0a, 0x66, 0x4e, 0x41, 0x6d, 0x63, 0x32, - 0x63, 0x6d, 0x64, 0x6b, 0x53, 0x52, 0x4a, 0x7a, 0x6a, 0x68, 0x49, 0x61, - 0x4f, 0x73, 0x74, 0x6e, 0x51, 0x79, 0x31, 0x4a, 0x2b, 0x46, 0x6b, 0x30, - 0x54, 0x39, 0x58, 0x79, 0x76, 0x51, 0x74, 0x71, 0x34, 0x39, 0x39, 0x79, - 0x46, 0x62, 0x71, 0x39, 0x78, 0x6f, 0x67, 0x55, 0x56, 0x6c, 0x45, 0x47, - 0x48, 0x36, 0x32, 0x78, 0x50, 0x36, 0x76, 0x48, 0x30, 0x59, 0x0a, 0x35, - 0x75, 0x6b, 0x4b, 0x2f, 0x2f, 0x64, 0x43, 0x50, 0x41, 0x7a, 0x41, 0x31, - 0x31, 0x59, 0x75, 0x58, 0x32, 0x72, 0x6e, 0x65, 0x78, 0x30, 0x4a, 0x68, - 0x75, 0x54, 0x51, 0x66, 0x63, 0x49, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, - 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, - 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00 -}; + 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x42, 0x45, 0x47, 0x49, 0x4e, 0x20, 0x43, + 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, + 0x2d, 0x2d, 0x2d, 0x0a, 0x4d, 0x49, 0x49, 0x43, 0x49, 0x7a, 0x43, 0x43, + 0x41, 0x59, 0x77, 0x43, 0x43, 0x51, 0x43, 0x46, 0x54, 0x62, 0x46, 0x37, + 0x58, 0x4e, 0x53, 0x76, 0x76, 0x6a, 0x41, 0x4e, 0x42, 0x67, 0x6b, 0x71, + 0x68, 0x6b, 0x69, 0x47, 0x39, 0x77, 0x30, 0x42, 0x41, 0x51, 0x55, 0x46, + 0x41, 0x44, 0x42, 0x57, 0x4d, 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, + 0x56, 0x51, 0x51, 0x47, 0x45, 0x77, 0x4a, 0x42, 0x0a, 0x56, 0x54, 0x45, + 0x54, 0x4d, 0x42, 0x45, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, + 0x4b, 0x55, 0x32, 0x39, 0x74, 0x5a, 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, + 0x30, 0x5a, 0x54, 0x45, 0x68, 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, + 0x45, 0x43, 0x67, 0x77, 0x59, 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, + 0x75, 0x5a, 0x58, 0x51, 0x67, 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, + 0x30, 0x0a, 0x63, 0x79, 0x42, 0x51, 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, + 0x52, 0x6b, 0x4d, 0x51, 0x38, 0x77, 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, + 0x51, 0x44, 0x44, 0x41, 0x5a, 0x30, 0x5a, 0x58, 0x4e, 0x30, 0x59, 0x32, + 0x45, 0x77, 0x48, 0x68, 0x63, 0x4e, 0x4d, 0x54, 0x51, 0x77, 0x4e, 0x7a, + 0x45, 0x33, 0x4d, 0x6a, 0x4d, 0x78, 0x4e, 0x7a, 0x55, 0x78, 0x57, 0x68, + 0x63, 0x4e, 0x4d, 0x6a, 0x51, 0x77, 0x0a, 0x4e, 0x7a, 0x45, 0x30, 0x4d, + 0x6a, 0x4d, 0x78, 0x4e, 0x7a, 0x55, 0x78, 0x57, 0x6a, 0x42, 0x57, 0x4d, + 0x51, 0x73, 0x77, 0x43, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x47, 0x45, + 0x77, 0x4a, 0x42, 0x56, 0x54, 0x45, 0x54, 0x4d, 0x42, 0x45, 0x47, 0x41, + 0x31, 0x55, 0x45, 0x43, 0x41, 0x77, 0x4b, 0x55, 0x32, 0x39, 0x74, 0x5a, + 0x53, 0x31, 0x54, 0x64, 0x47, 0x46, 0x30, 0x5a, 0x54, 0x45, 0x68, 0x0a, + 0x4d, 0x42, 0x38, 0x47, 0x41, 0x31, 0x55, 0x45, 0x43, 0x67, 0x77, 0x59, + 0x53, 0x57, 0x35, 0x30, 0x5a, 0x58, 0x4a, 0x75, 0x5a, 0x58, 0x51, 0x67, + 0x56, 0x32, 0x6c, 0x6b, 0x5a, 0x32, 0x6c, 0x30, 0x63, 0x79, 0x42, 0x51, + 0x64, 0x48, 0x6b, 0x67, 0x54, 0x48, 0x52, 0x6b, 0x4d, 0x51, 0x38, 0x77, + 0x44, 0x51, 0x59, 0x44, 0x56, 0x51, 0x51, 0x44, 0x44, 0x41, 0x5a, 0x30, + 0x5a, 0x58, 0x4e, 0x30, 0x0a, 0x59, 0x32, 0x45, 0x77, 0x67, 0x5a, 0x38, + 0x77, 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, + 0x4e, 0x41, 0x51, 0x45, 0x42, 0x42, 0x51, 0x41, 0x44, 0x67, 0x59, 0x30, + 0x41, 0x4d, 0x49, 0x47, 0x4a, 0x41, 0x6f, 0x47, 0x42, 0x41, 0x4d, 0x42, + 0x41, 0x33, 0x77, 0x56, 0x65, 0x54, 0x47, 0x48, 0x5a, 0x52, 0x31, 0x52, + 0x79, 0x65, 0x2f, 0x69, 0x2b, 0x4a, 0x38, 0x61, 0x32, 0x0a, 0x63, 0x75, + 0x35, 0x67, 0x58, 0x77, 0x46, 0x56, 0x36, 0x54, 0x6e, 0x4f, 0x62, 0x7a, + 0x47, 0x4d, 0x37, 0x62, 0x4c, 0x46, 0x43, 0x4f, 0x35, 0x69, 0x39, 0x76, + 0x34, 0x6d, 0x4c, 0x6f, 0x34, 0x69, 0x46, 0x7a, 0x50, 0x73, 0x48, 0x6d, + 0x57, 0x44, 0x55, 0x78, 0x4b, 0x53, 0x33, 0x59, 0x38, 0x69, 0x58, 0x62, + 0x75, 0x30, 0x65, 0x59, 0x42, 0x6c, 0x4c, 0x6f, 0x4e, 0x59, 0x30, 0x6c, + 0x53, 0x76, 0x0a, 0x78, 0x44, 0x78, 0x33, 0x33, 0x4f, 0x2b, 0x44, 0x75, + 0x77, 0x4d, 0x6d, 0x56, 0x4e, 0x2b, 0x44, 0x7a, 0x53, 0x44, 0x2b, 0x45, + 0x6f, 0x64, 0x39, 0x7a, 0x66, 0x76, 0x77, 0x4f, 0x57, 0x48, 0x73, 0x61, + 0x7a, 0x59, 0x43, 0x5a, 0x54, 0x32, 0x50, 0x68, 0x4e, 0x78, 0x6e, 0x56, + 0x57, 0x49, 0x75, 0x4a, 0x58, 0x56, 0x69, 0x59, 0x34, 0x4a, 0x41, 0x48, + 0x55, 0x47, 0x6f, 0x64, 0x6a, 0x78, 0x2b, 0x0a, 0x51, 0x41, 0x69, 0x36, + 0x79, 0x43, 0x41, 0x75, 0x72, 0x55, 0x5a, 0x47, 0x76, 0x59, 0x58, 0x47, + 0x67, 0x5a, 0x53, 0x42, 0x41, 0x67, 0x4d, 0x42, 0x41, 0x41, 0x45, 0x77, + 0x44, 0x51, 0x59, 0x4a, 0x4b, 0x6f, 0x5a, 0x49, 0x68, 0x76, 0x63, 0x4e, + 0x41, 0x51, 0x45, 0x46, 0x42, 0x51, 0x41, 0x44, 0x67, 0x59, 0x45, 0x41, + 0x51, 0x6f, 0x51, 0x56, 0x44, 0x38, 0x62, 0x77, 0x64, 0x74, 0x57, 0x4a, + 0x0a, 0x41, 0x6e, 0x69, 0x47, 0x42, 0x77, 0x63, 0x43, 0x66, 0x71, 0x59, + 0x79, 0x48, 0x2b, 0x2f, 0x4b, 0x70, 0x41, 0x31, 0x30, 0x41, 0x63, 0x65, + 0x62, 0x4a, 0x56, 0x56, 0x54, 0x79, 0x59, 0x62, 0x59, 0x76, 0x49, 0x39, + 0x51, 0x38, 0x64, 0x36, 0x52, 0x53, 0x56, 0x75, 0x34, 0x50, 0x5a, 0x79, + 0x39, 0x4f, 0x41, 0x4c, 0x48, 0x52, 0x2f, 0x51, 0x72, 0x57, 0x42, 0x64, + 0x59, 0x54, 0x41, 0x79, 0x7a, 0x0a, 0x66, 0x4e, 0x41, 0x6d, 0x63, 0x32, + 0x63, 0x6d, 0x64, 0x6b, 0x53, 0x52, 0x4a, 0x7a, 0x6a, 0x68, 0x49, 0x61, + 0x4f, 0x73, 0x74, 0x6e, 0x51, 0x79, 0x31, 0x4a, 0x2b, 0x46, 0x6b, 0x30, + 0x54, 0x39, 0x58, 0x79, 0x76, 0x51, 0x74, 0x71, 0x34, 0x39, 0x39, 0x79, + 0x46, 0x62, 0x71, 0x39, 0x78, 0x6f, 0x67, 0x55, 0x56, 0x6c, 0x45, 0x47, + 0x48, 0x36, 0x32, 0x78, 0x50, 0x36, 0x76, 0x48, 0x30, 0x59, 0x0a, 0x35, + 0x75, 0x6b, 0x4b, 0x2f, 0x2f, 0x64, 0x43, 0x50, 0x41, 0x7a, 0x41, 0x31, + 0x31, 0x59, 0x75, 0x58, 0x32, 0x72, 0x6e, 0x65, 0x78, 0x30, 0x4a, 0x68, + 0x75, 0x54, 0x51, 0x66, 0x63, 0x49, 0x3d, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, + 0x2d, 0x45, 0x4e, 0x44, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, + 0x43, 0x41, 0x54, 0x45, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x00}; diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index 5da851bbcd..ca72d71dc1 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -49,37 +49,23 @@ /* This test exercises IPv4, IPv6, and dualstack sockets in various ways. */ -static void * -tag (gpr_intptr i) -{ - return (void *) i; -} +static void *tag(gpr_intptr i) { return (void *)i; } -static gpr_timespec -ms_from_now (int ms) -{ - return GRPC_TIMEOUT_MILLIS_TO_DEADLINE (ms); +static gpr_timespec ms_from_now(int ms) { + return GRPC_TIMEOUT_MILLIS_TO_DEADLINE(ms); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, ms_from_now (5000), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, ms_from_now(5000), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -do_nothing (void *ignored) -{ -} +static void do_nothing(void *ignored) {} -void -test_connect (const char *server_host, const char *client_host, int port, int expect_ok) -{ +void test_connect(const char *server_host, const char *client_host, int port, + int expect_ok) { char *client_hostport; char *server_hostport; grpc_channel *client; @@ -103,88 +89,81 @@ test_connect (const char *server_host, const char *client_host, int port, int ex grpc_call_details call_details; char *peer; - if (port == 0) - { - port = grpc_pick_unused_port_or_die (); - } + if (port == 0) { + port = grpc_pick_unused_port_or_die(); + } - gpr_join_host_port (&server_hostport, server_host, port); + gpr_join_host_port(&server_hostport, server_host, port); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); /* Create server. */ - cq = grpc_completion_queue_create (NULL); - server = grpc_server_create (NULL, NULL); - grpc_server_register_completion_queue (server, cq, NULL); - GPR_ASSERT ((got_port = grpc_server_add_insecure_http2_port (server, server_hostport)) > 0); - if (port == 0) - { - port = got_port; - } - else - { - GPR_ASSERT (port == got_port); - } - grpc_server_start (server); - cqv = cq_verifier_create (cq); + cq = grpc_completion_queue_create(NULL); + server = grpc_server_create(NULL, NULL); + grpc_server_register_completion_queue(server, cq, NULL); + GPR_ASSERT((got_port = grpc_server_add_insecure_http2_port( + server, server_hostport)) > 0); + if (port == 0) { + port = got_port; + } else { + GPR_ASSERT(port == got_port); + } + grpc_server_start(server); + cqv = cq_verifier_create(cq); /* Create client. */ - if (client_host[0] == 'i') - { - /* for ipv4:/ipv6: addresses, concatenate the port to each of the parts */ - size_t i; - gpr_slice uri_slice; - gpr_slice_buffer uri_parts; - char **hosts_with_port; - - uri_slice = gpr_slice_new ((char *) client_host, strlen (client_host), do_nothing); - gpr_slice_buffer_init (&uri_parts); - gpr_slice_split (uri_slice, ",", &uri_parts); - hosts_with_port = gpr_malloc (sizeof (char *) * uri_parts.count); - for (i = 0; i < uri_parts.count; i++) - { - char *uri_part_str = gpr_dump_slice (uri_parts.slices[i], GPR_DUMP_ASCII); - gpr_asprintf (&hosts_with_port[i], "%s:%d", uri_part_str, port); - gpr_free (uri_part_str); - } - client_hostport = gpr_strjoin_sep ((const char **) hosts_with_port, uri_parts.count, ",", NULL); - for (i = 0; i < uri_parts.count; i++) - { - gpr_free (hosts_with_port[i]); - } - gpr_free (hosts_with_port); - gpr_slice_buffer_destroy (&uri_parts); - gpr_slice_unref (uri_slice); - } - else - { - gpr_join_host_port (&client_hostport, client_host, port); - } - client = grpc_insecure_channel_create (client_hostport, NULL, NULL); - - gpr_log (GPR_INFO, "Testing with server=%s client=%s (expecting %s)", server_hostport, client_hostport, expect_ok ? "success" : "failure"); - - gpr_free (client_hostport); - gpr_free (server_hostport); - - if (expect_ok) - { - /* Normal deadline, shouldn't be reached. */ - deadline = ms_from_now (60000); + if (client_host[0] == 'i') { + /* for ipv4:/ipv6: addresses, concatenate the port to each of the parts */ + size_t i; + gpr_slice uri_slice; + gpr_slice_buffer uri_parts; + char **hosts_with_port; + + uri_slice = + gpr_slice_new((char *)client_host, strlen(client_host), do_nothing); + gpr_slice_buffer_init(&uri_parts); + gpr_slice_split(uri_slice, ",", &uri_parts); + hosts_with_port = gpr_malloc(sizeof(char *) * uri_parts.count); + for (i = 0; i < uri_parts.count; i++) { + char *uri_part_str = gpr_dump_slice(uri_parts.slices[i], GPR_DUMP_ASCII); + gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port); + gpr_free(uri_part_str); } - else - { - /* Give up faster when failure is expected. - BUG: Setting this to 1000 reveals a memory leak (b/18608927). */ - deadline = ms_from_now (1500); + client_hostport = gpr_strjoin_sep((const char **)hosts_with_port, + uri_parts.count, ",", NULL); + for (i = 0; i < uri_parts.count; i++) { + gpr_free(hosts_with_port[i]); } + gpr_free(hosts_with_port); + gpr_slice_buffer_destroy(&uri_parts); + gpr_slice_unref(uri_slice); + } else { + gpr_join_host_port(&client_hostport, client_host, port); + } + client = grpc_insecure_channel_create(client_hostport, NULL, NULL); + + gpr_log(GPR_INFO, "Testing with server=%s client=%s (expecting %s)", + server_hostport, client_hostport, expect_ok ? "success" : "failure"); + + gpr_free(client_hostport); + gpr_free(server_hostport); + + if (expect_ok) { + /* Normal deadline, shouldn't be reached. */ + deadline = ms_from_now(60000); + } else { + /* Give up faster when failure is expected. + BUG: Setting this to 1000 reveals a memory leak (b/18608927). */ + deadline = ms_from_now(1500); + } /* Send a trivial request. */ - c = grpc_channel_create_call (client, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(client, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -209,164 +188,159 @@ test_connect (const char *server_host, const char *client_host, int port, int ex op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - if (expect_ok) - { - /* Check for a successful request. */ - error = grpc_server_request_call (server, &s, &call_details, &request_metadata_recv, cq, cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); - - op = ops; - op->op = GRPC_OP_SEND_INITIAL_METADATA; - op->data.send_initial_metadata.count = 0; - op->flags = 0; - op++; - op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; - op->data.send_status_from_server.trailing_metadata_count = 0; - op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; - op->data.send_status_from_server.status_details = "xyz"; - op->flags = 0; - op++; - op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; - op->data.recv_close_on_server.cancelled = &was_cancelled; - op->flags = 0; - op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); - - peer = grpc_call_get_peer (c); - gpr_log (GPR_DEBUG, "got peer: '%s'", peer); - gpr_free (peer); - - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 1); - - grpc_call_destroy (s); - } - else - { - /* Check for a failed connection. */ - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); - - GPR_ASSERT (status == GRPC_STATUS_DEADLINE_EXCEEDED); - } - - grpc_call_destroy (c); - - cq_verifier_destroy (cqv); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + if (expect_ok) { + /* Check for a successful request. */ + error = grpc_server_request_call(server, &s, &call_details, + &request_metadata_recv, cq, cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); + + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op++; + op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op->data.send_status_from_server.trailing_metadata_count = 0; + op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; + op->data.send_status_from_server.status_details = "xyz"; + op->flags = 0; + op++; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op->flags = 0; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); + + peer = grpc_call_get_peer(c); + gpr_log(GPR_DEBUG, "got peer: '%s'", peer); + gpr_free(peer); + + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 1); + + grpc_call_destroy(s); + } else { + /* Check for a failed connection. */ + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); + + GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED); + } + + grpc_call_destroy(c); + + cq_verifier_destroy(cqv); /* Destroy client. */ - grpc_channel_destroy (client); + grpc_channel_destroy(client); /* Destroy server. */ - grpc_server_shutdown_and_notify (server, cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (server); - grpc_completion_queue_shutdown (cq); - drain_cq (cq); - grpc_completion_queue_destroy (cq); - - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - - grpc_call_details_destroy (&call_details); - gpr_free (details); + grpc_server_shutdown_and_notify(server, cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(server); + grpc_completion_queue_shutdown(cq); + drain_cq(cq); + grpc_completion_queue_destroy(cq); + + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + + grpc_call_details_destroy(&call_details); + gpr_free(details); } -int -external_dns_works (const char *host) -{ - grpc_resolved_addresses *res = grpc_blocking_resolve_address (host, "80"); - if (res != NULL) - { - grpc_resolved_addresses_destroy (res); - return 1; - } +int external_dns_works(const char *host) { + grpc_resolved_addresses *res = grpc_blocking_resolve_address(host, "80"); + if (res != NULL) { + grpc_resolved_addresses_destroy(res); + return 1; + } return 0; } -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { int do_ipv6 = 1; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - if (!grpc_ipv6_loopback_available ()) - { - gpr_log (GPR_INFO, "Can't bind to ::1. Skipping IPv6 tests."); - do_ipv6 = 0; - } + if (!grpc_ipv6_loopback_available()) { + gpr_log(GPR_INFO, "Can't bind to ::1. Skipping IPv6 tests."); + do_ipv6 = 0; + } /* For coverage, test with and without dualstack sockets. */ - for (grpc_forbid_dualstack_sockets_for_testing = 0; grpc_forbid_dualstack_sockets_for_testing <= 1; grpc_forbid_dualstack_sockets_for_testing++) - { - /* :: and 0.0.0.0 are handled identically. */ - test_connect ("::", "127.0.0.1", 0, 1); - test_connect ("::", "::ffff:127.0.0.1", 0, 1); - test_connect ("::", "ipv4:127.0.0.1", 0, 1); - test_connect ("::", "ipv6:[::ffff:127.0.0.1]", 0, 1); - test_connect ("::", "localhost", 0, 1); - test_connect ("0.0.0.0", "127.0.0.1", 0, 1); - test_connect ("0.0.0.0", "::ffff:127.0.0.1", 0, 1); - test_connect ("0.0.0.0", "ipv4:127.0.0.1", 0, 1); - test_connect ("0.0.0.0", "ipv4:127.0.0.1,127.0.0.2,127.0.0.3", 0, 1); - test_connect ("0.0.0.0", "ipv6:[::ffff:127.0.0.1],[::ffff:127.0.0.2]", 0, 1); - test_connect ("0.0.0.0", "localhost", 0, 1); - if (do_ipv6) - { - test_connect ("::", "::1", 0, 1); - test_connect ("0.0.0.0", "::1", 0, 1); - test_connect ("::", "ipv6:[::1]", 0, 1); - test_connect ("0.0.0.0", "ipv6:[::1]", 0, 1); - } - - /* These only work when the families agree. */ - test_connect ("127.0.0.1", "127.0.0.1", 0, 1); - test_connect ("127.0.0.1", "ipv4:127.0.0.1", 0, 1); - if (do_ipv6) - { - test_connect ("::1", "::1", 0, 1); - test_connect ("::1", "127.0.0.1", 0, 0); - test_connect ("127.0.0.1", "::1", 0, 0); - test_connect ("::1", "ipv6:[::1]", 0, 1); - test_connect ("::1", "ipv4:127.0.0.1", 0, 0); - test_connect ("127.0.0.1", "ipv6:[::1]", 0, 0); - } - - if (!external_dns_works ("loopback46.unittest.grpc.io")) - { - gpr_log (GPR_INFO, "Skipping tests that depend on *.unittest.grpc.io."); - } - else - { - test_connect ("loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io", 0, 1); - test_connect ("loopback4.unittest.grpc.io", "loopback46.unittest.grpc.io", 0, 1); - if (do_ipv6) - { - test_connect ("loopback46.unittest.grpc.io", "loopback6.unittest.grpc.io", 0, 1); - test_connect ("loopback6.unittest.grpc.io", "loopback46.unittest.grpc.io", 0, 1); - test_connect ("loopback4.unittest.grpc.io", "loopback6.unittest.grpc.io", 0, 0); - test_connect ("loopback6.unittest.grpc.io", "loopback4.unittest.grpc.io", 0, 0); - } - } + for (grpc_forbid_dualstack_sockets_for_testing = 0; + grpc_forbid_dualstack_sockets_for_testing <= 1; + grpc_forbid_dualstack_sockets_for_testing++) { + /* :: and 0.0.0.0 are handled identically. */ + test_connect("::", "127.0.0.1", 0, 1); + test_connect("::", "::ffff:127.0.0.1", 0, 1); + test_connect("::", "ipv4:127.0.0.1", 0, 1); + test_connect("::", "ipv6:[::ffff:127.0.0.1]", 0, 1); + test_connect("::", "localhost", 0, 1); + test_connect("0.0.0.0", "127.0.0.1", 0, 1); + test_connect("0.0.0.0", "::ffff:127.0.0.1", 0, 1); + test_connect("0.0.0.0", "ipv4:127.0.0.1", 0, 1); + test_connect("0.0.0.0", "ipv4:127.0.0.1,127.0.0.2,127.0.0.3", 0, 1); + test_connect("0.0.0.0", "ipv6:[::ffff:127.0.0.1],[::ffff:127.0.0.2]", 0, 1); + test_connect("0.0.0.0", "localhost", 0, 1); + if (do_ipv6) { + test_connect("::", "::1", 0, 1); + test_connect("0.0.0.0", "::1", 0, 1); + test_connect("::", "ipv6:[::1]", 0, 1); + test_connect("0.0.0.0", "ipv6:[::1]", 0, 1); + } + + /* These only work when the families agree. */ + test_connect("127.0.0.1", "127.0.0.1", 0, 1); + test_connect("127.0.0.1", "ipv4:127.0.0.1", 0, 1); + if (do_ipv6) { + test_connect("::1", "::1", 0, 1); + test_connect("::1", "127.0.0.1", 0, 0); + test_connect("127.0.0.1", "::1", 0, 0); + test_connect("::1", "ipv6:[::1]", 0, 1); + test_connect("::1", "ipv4:127.0.0.1", 0, 0); + test_connect("127.0.0.1", "ipv6:[::1]", 0, 0); + } + + if (!external_dns_works("loopback46.unittest.grpc.io")) { + gpr_log(GPR_INFO, "Skipping tests that depend on *.unittest.grpc.io."); + } else { + test_connect("loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io", + 0, 1); + test_connect("loopback4.unittest.grpc.io", "loopback46.unittest.grpc.io", + 0, 1); + if (do_ipv6) { + test_connect("loopback46.unittest.grpc.io", + "loopback6.unittest.grpc.io", 0, 1); + test_connect("loopback6.unittest.grpc.io", + "loopback46.unittest.grpc.io", 0, 1); + test_connect("loopback4.unittest.grpc.io", "loopback6.unittest.grpc.io", + 0, 0); + test_connect("loopback6.unittest.grpc.io", "loopback4.unittest.grpc.io", + 0, 0); + } } + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index 4f653ec868..3f1665613c 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -45,24 +45,25 @@ typedef struct grpc_end2end_test_config grpc_end2end_test_config; #define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check" -struct grpc_end2end_test_fixture -{ +struct grpc_end2end_test_fixture { grpc_completion_queue *cq; grpc_server *server; grpc_channel *client; void *fixture_data; }; -struct grpc_end2end_test_config -{ +struct grpc_end2end_test_config { const char *name; gpr_uint32 feature_mask; - grpc_end2end_test_fixture (*create_fixture) (grpc_channel_args * client_args, grpc_channel_args * server_args); - void (*init_client) (grpc_end2end_test_fixture * f, grpc_channel_args * client_args); - void (*init_server) (grpc_end2end_test_fixture * f, grpc_channel_args * server_args); - void (*tear_down_data) (grpc_end2end_test_fixture * f); + grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args *client_args, + grpc_channel_args *server_args); + void (*init_client)(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args); + void (*init_server)(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args); + void (*tear_down_data)(grpc_end2end_test_fixture *f); }; -void grpc_end2end_tests (grpc_end2end_test_config config); +void grpc_end2end_tests(grpc_end2end_test_config config); #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index 7117777bfa..6e7a1faf55 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -51,94 +51,86 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_compression_fixture_data -{ +typedef struct fullstack_compression_fixture_data { char *localaddr; grpc_channel_args *client_args_compression; grpc_channel_args *server_args_compression; } fullstack_compression_fixture_data; -static grpc_end2end_test_fixture -chttp2_create_fixture_fullstack_compression (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_fullstack_compression( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die (); - fullstack_compression_fixture_data *ffd = gpr_malloc (sizeof (fullstack_compression_fixture_data)); - memset (ffd, 0, sizeof (fullstack_compression_fixture_data)); + int port = grpc_pick_unused_port_or_die(); + fullstack_compression_fixture_data *ffd = + gpr_malloc(sizeof(fullstack_compression_fixture_data)); + memset(ffd, 0, sizeof(fullstack_compression_fixture_data)); - gpr_join_host_port (&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); - memset (&f, 0, sizeof (f)); + memset(&f, 0, sizeof(f)); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -void -chttp2_init_client_fullstack_compression (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +void chttp2_init_client_fullstack_compression(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { fullstack_compression_fixture_data *ffd = f->fixture_data; - if (ffd->client_args_compression != NULL) - { - grpc_channel_args_destroy (ffd->client_args_compression); - } - ffd->client_args_compression = grpc_channel_args_set_compression_algorithm (client_args, GRPC_COMPRESS_GZIP); - f->client = grpc_insecure_channel_create (ffd->localaddr, ffd->client_args_compression, NULL); + if (ffd->client_args_compression != NULL) { + grpc_channel_args_destroy(ffd->client_args_compression); + } + ffd->client_args_compression = grpc_channel_args_set_compression_algorithm( + client_args, GRPC_COMPRESS_GZIP); + f->client = grpc_insecure_channel_create(ffd->localaddr, + ffd->client_args_compression, NULL); } -void -chttp2_init_server_fullstack_compression (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +void chttp2_init_server_fullstack_compression(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { fullstack_compression_fixture_data *ffd = f->fixture_data; - if (ffd->server_args_compression != NULL) - { - grpc_channel_args_destroy (ffd->server_args_compression); - } - ffd->server_args_compression = grpc_channel_args_set_compression_algorithm (server_args, GRPC_COMPRESS_GZIP); - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (ffd->server_args_compression, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_insecure_http2_port (f->server, ffd->localaddr)); - grpc_server_start (f->server); + if (ffd->server_args_compression != NULL) { + grpc_channel_args_destroy(ffd->server_args_compression); + } + ffd->server_args_compression = grpc_channel_args_set_compression_algorithm( + server_args, GRPC_COMPRESS_GZIP); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(ffd->server_args_compression, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + grpc_server_start(f->server); } -void -chttp2_tear_down_fullstack_compression (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { fullstack_compression_fixture_data *ffd = f->fixture_data; - grpc_channel_args_destroy (ffd->client_args_compression); - grpc_channel_args_destroy (ffd->server_args_compression); - gpr_free (ffd->localaddr); - gpr_free (ffd); + grpc_channel_args_destroy(ffd->client_args_compression); + grpc_channel_args_destroy(ffd->server_args_compression); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, - chttp2_create_fixture_fullstack_compression, - chttp2_init_client_fullstack_compression, - chttp2_init_server_fullstack_compression, - chttp2_tear_down_fullstack_compression}, + {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, + chttp2_create_fixture_fullstack_compression, + chttp2_init_client_fullstack_compression, + chttp2_init_server_fullstack_compression, + chttp2_tear_down_fullstack_compression}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.c index c663f40ede..3e64cc08e8 100644 --- a/test/core/end2end/fixtures/h2_fakesec.c +++ b/test/core/end2end/fixtures/h2_fakesec.c @@ -45,126 +45,119 @@ #include "test/core/util/port.h" #include "test/core/end2end/data/ssl_test_data.h" -typedef struct fullstack_secure_fixture_data -{ +typedef struct fullstack_secure_fixture_data { char *localaddr; } fullstack_secure_fixture_data; -static grpc_end2end_test_fixture -chttp2_create_fixture_secure_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die (); - fullstack_secure_fixture_data *ffd = gpr_malloc (sizeof (fullstack_secure_fixture_data)); + int port = grpc_pick_unused_port_or_die(); + fullstack_secure_fixture_data *ffd = + gpr_malloc(sizeof(fullstack_secure_fixture_data)); - memset (&f, 0, sizeof (f)); - gpr_join_host_port (&ffd->localaddr, "localhost", port); + memset(&f, 0, sizeof(f)); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -static void -process_auth_failure (void *state, grpc_auth_context * ctx, const grpc_metadata * md, size_t md_count, grpc_process_auth_metadata_done_cb cb, void *user_data) -{ - GPR_ASSERT (state == NULL); - cb (user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); +static void process_auth_failure(void *state, grpc_auth_context *ctx, + const grpc_metadata *md, size_t md_count, + grpc_process_auth_metadata_done_cb cb, + void *user_data) { + GPR_ASSERT(state == NULL); + cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void -chttp2_init_client_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args, grpc_credentials * creds) -{ +static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args, + grpc_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - f->client = grpc_secure_channel_create (creds, ffd->localaddr, client_args, NULL); - GPR_ASSERT (f->client != NULL); - grpc_credentials_release (creds); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); + GPR_ASSERT(f->client != NULL); + grpc_credentials_release(creds); } -static void -chttp2_init_server_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args, grpc_server_credentials * server_creds) -{ +static void chttp2_init_server_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args, + grpc_server_credentials *server_creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_secure_http2_port (f->server, ffd->localaddr, server_creds)); - grpc_server_credentials_release (server_creds); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + server_creds)); + grpc_server_credentials_release(server_creds); + grpc_server_start(f->server); } -void -chttp2_tear_down_secure_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } -static void -chttp2_init_client_fake_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ - grpc_credentials *fake_ts_creds = grpc_fake_transport_security_credentials_create (); - chttp2_init_client_secure_fullstack (f, client_args, fake_ts_creds); +static void chttp2_init_client_fake_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { + grpc_credentials *fake_ts_creds = + grpc_fake_transport_security_credentials_create(); + chttp2_init_client_secure_fullstack(f, client_args, fake_ts_creds); } -static int -fail_server_auth_check (grpc_channel_args * server_args) -{ +static int fail_server_auth_check(grpc_channel_args *server_args) { size_t i; - if (server_args == NULL) - return 0; - for (i = 0; i < server_args->num_args; i++) - { - if (strcmp (server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == 0) - { - return 1; - } + if (server_args == NULL) return 0; + for (i = 0; i < server_args->num_args; i++) { + if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == + 0) { + return 1; } + } return 0; } -static void -chttp2_init_server_fake_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ - grpc_server_credentials *fake_ts_creds = grpc_fake_transport_security_server_credentials_create (); - if (fail_server_auth_check (server_args)) - { - grpc_auth_metadata_processor processor = { process_auth_failure, NULL, NULL }; - grpc_server_credentials_set_auth_metadata_processor (fake_ts_creds, processor); - } - chttp2_init_server_secure_fullstack (f, server_args, fake_ts_creds); +static void chttp2_init_server_fake_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_server_credentials *fake_ts_creds = + grpc_fake_transport_security_server_credentials_create(); + if (fail_server_auth_check(server_args)) { + grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL}; + grpc_server_credentials_set_auth_metadata_processor(fake_ts_creds, + processor); + } + chttp2_init_server_secure_fullstack(f, server_args, fake_ts_creds); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fake_secure_fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, - chttp2_create_fixture_secure_fullstack, - chttp2_init_client_fake_secure_fullstack, - chttp2_init_server_fake_secure_fullstack, - chttp2_tear_down_secure_fullstack}, + {"chttp2/fake_secure_fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, + chttp2_create_fixture_secure_fullstack, + chttp2_init_client_fake_secure_fullstack, + chttp2_init_server_fake_secure_fullstack, + chttp2_tear_down_secure_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); + grpc_test_init(argc, argv); - grpc_init (); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_full+poll.c b/test/core/end2end/fixtures/h2_full+poll.c index 92f49c0bc6..48feefc931 100644 --- a/test/core/end2end/fixtures/h2_full+poll.c +++ b/test/core/end2end/fixtures/h2_full+poll.c @@ -50,79 +50,69 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data -{ +typedef struct fullstack_fixture_data { char *localaddr; } fullstack_fixture_data; -static grpc_end2end_test_fixture -chttp2_create_fixture_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die (); - fullstack_fixture_data *ffd = gpr_malloc (sizeof (fullstack_fixture_data)); - memset (&f, 0, sizeof (f)); + int port = grpc_pick_unused_port_or_die(); + fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data)); + memset(&f, 0, sizeof(f)); - gpr_join_host_port (&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -void -chttp2_init_client_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { fullstack_fixture_data *ffd = f->fixture_data; - f->client = grpc_insecure_channel_create (ffd->localaddr, client_args, NULL); + f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); } -void -chttp2_init_server_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { fullstack_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_insecure_http2_port (f->server, ffd->localaddr)); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + grpc_server_start(f->server); } -void -chttp2_tear_down_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { fullstack_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, - chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, - chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, + chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, + chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; grpc_platform_become_multipoller = grpc_poll_become_multipoller; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index 16e9359500..0170dcf0e5 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -50,78 +50,68 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data -{ +typedef struct fullstack_fixture_data { char *localaddr; } fullstack_fixture_data; -static grpc_end2end_test_fixture -chttp2_create_fixture_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die (); - fullstack_fixture_data *ffd = gpr_malloc (sizeof (fullstack_fixture_data)); - memset (&f, 0, sizeof (f)); + int port = grpc_pick_unused_port_or_die(); + fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data)); + memset(&f, 0, sizeof(f)); - gpr_join_host_port (&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -void -chttp2_init_client_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { fullstack_fixture_data *ffd = f->fixture_data; - f->client = grpc_insecure_channel_create (ffd->localaddr, client_args, NULL); - GPR_ASSERT (f->client); + f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); + GPR_ASSERT(f->client); } -void -chttp2_init_server_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { fullstack_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_insecure_http2_port (f->server, ffd->localaddr)); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + grpc_server_start(f->server); } -void -chttp2_tear_down_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { fullstack_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, - chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, - chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, + chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, + chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c index a328eb1ed5..b4b2e02684 100644 --- a/test/core/end2end/fixtures/h2_oauth2.c +++ b/test/core/end2end/fixtures/h2_oauth2.c @@ -50,201 +50,191 @@ static const char oauth2_md[] = "Bearer aaslkfjs424535asdf"; static const char *client_identity_property_name = "smurf_name"; static const char *client_identity = "Brainy Smurf"; -typedef struct fullstack_secure_fixture_data -{ +typedef struct fullstack_secure_fixture_data { char *localaddr; } fullstack_secure_fixture_data; -static const grpc_metadata * -find_metadata (const grpc_metadata * md, size_t md_count, const char *key, const char *value) -{ +static const grpc_metadata *find_metadata(const grpc_metadata *md, + size_t md_count, const char *key, + const char *value) { size_t i; - for (i = 0; i < md_count; i++) - { - if (strcmp (key, md[i].key) == 0 && strlen (value) == md[i].value_length && memcmp (md[i].value, value, md[i].value_length) == 0) - { - return &md[i]; - } + for (i = 0; i < md_count; i++) { + if (strcmp(key, md[i].key) == 0 && strlen(value) == md[i].value_length && + memcmp(md[i].value, value, md[i].value_length) == 0) { + return &md[i]; } + } return NULL; } -typedef struct -{ - size_t pseudo_refcount; -} test_processor_state; +typedef struct { size_t pseudo_refcount; } test_processor_state; -static void -process_oauth2_success (void *state, grpc_auth_context * ctx, const grpc_metadata * md, size_t md_count, grpc_process_auth_metadata_done_cb cb, void *user_data) -{ - const grpc_metadata *oauth2 = find_metadata (md, md_count, "Authorization", oauth2_md); +static void process_oauth2_success(void *state, grpc_auth_context *ctx, + const grpc_metadata *md, size_t md_count, + grpc_process_auth_metadata_done_cb cb, + void *user_data) { + const grpc_metadata *oauth2 = + find_metadata(md, md_count, "Authorization", oauth2_md); test_processor_state *s; - GPR_ASSERT (state != NULL); - s = (test_processor_state *) state; - GPR_ASSERT (s->pseudo_refcount == 1); - GPR_ASSERT (oauth2 != NULL); - grpc_auth_context_add_cstring_property (ctx, client_identity_property_name, client_identity); - GPR_ASSERT (grpc_auth_context_set_peer_identity_property_name (ctx, client_identity_property_name) == 1); - cb (user_data, oauth2, 1, NULL, 0, GRPC_STATUS_OK, NULL); + GPR_ASSERT(state != NULL); + s = (test_processor_state *)state; + GPR_ASSERT(s->pseudo_refcount == 1); + GPR_ASSERT(oauth2 != NULL); + grpc_auth_context_add_cstring_property(ctx, client_identity_property_name, + client_identity); + GPR_ASSERT(grpc_auth_context_set_peer_identity_property_name( + ctx, client_identity_property_name) == 1); + cb(user_data, oauth2, 1, NULL, 0, GRPC_STATUS_OK, NULL); } -static void -process_oauth2_failure (void *state, grpc_auth_context * ctx, const grpc_metadata * md, size_t md_count, grpc_process_auth_metadata_done_cb cb, void *user_data) -{ - const grpc_metadata *oauth2 = find_metadata (md, md_count, "Authorization", oauth2_md); +static void process_oauth2_failure(void *state, grpc_auth_context *ctx, + const grpc_metadata *md, size_t md_count, + grpc_process_auth_metadata_done_cb cb, + void *user_data) { + const grpc_metadata *oauth2 = + find_metadata(md, md_count, "Authorization", oauth2_md); test_processor_state *s; - GPR_ASSERT (state != NULL); - s = (test_processor_state *) state; - GPR_ASSERT (s->pseudo_refcount == 1); - GPR_ASSERT (oauth2 != NULL); - cb (user_data, oauth2, 1, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); + GPR_ASSERT(state != NULL); + s = (test_processor_state *)state; + GPR_ASSERT(s->pseudo_refcount == 1); + GPR_ASSERT(oauth2 != NULL); + cb(user_data, oauth2, 1, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static grpc_end2end_test_fixture -chttp2_create_fixture_secure_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die (); - fullstack_secure_fixture_data *ffd = gpr_malloc (sizeof (fullstack_secure_fixture_data)); - memset (&f, 0, sizeof (f)); + int port = grpc_pick_unused_port_or_die(); + fullstack_secure_fixture_data *ffd = + gpr_malloc(sizeof(fullstack_secure_fixture_data)); + memset(&f, 0, sizeof(f)); - gpr_join_host_port (&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -static void -chttp2_init_client_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args, grpc_credentials * creds) -{ +static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args, + grpc_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - f->client = grpc_secure_channel_create (creds, ffd->localaddr, client_args, NULL); - GPR_ASSERT (f->client != NULL); - grpc_credentials_release (creds); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); + GPR_ASSERT(f->client != NULL); + grpc_credentials_release(creds); } -static void -chttp2_init_server_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args, grpc_server_credentials * server_creds) -{ +static void chttp2_init_server_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args, + grpc_server_credentials *server_creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_secure_http2_port (f->server, ffd->localaddr, server_creds)); - grpc_server_credentials_release (server_creds); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + server_creds)); + grpc_server_credentials_release(server_creds); + grpc_server_start(f->server); } -void -chttp2_tear_down_secure_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } -static void -chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ - grpc_credentials *ssl_creds = grpc_ssl_credentials_create (test_root_cert, NULL, NULL); - grpc_credentials *oauth2_creds = grpc_md_only_test_credentials_create ("Authorization", oauth2_md, 1); - grpc_credentials *ssl_oauth2_creds = grpc_composite_credentials_create (ssl_creds, oauth2_creds, NULL); - grpc_arg ssl_name_override = { GRPC_ARG_STRING, - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - {"foo.test.google.fr"} - }; - grpc_channel_args *new_client_args = grpc_channel_args_copy_and_add (client_args, &ssl_name_override, 1); - chttp2_init_client_secure_fullstack (f, new_client_args, ssl_oauth2_creds); - grpc_channel_args_destroy (new_client_args); - grpc_credentials_release (ssl_creds); - grpc_credentials_release (oauth2_creds); +static void chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { + grpc_credentials *ssl_creds = + grpc_ssl_credentials_create(test_root_cert, NULL, NULL); + grpc_credentials *oauth2_creds = + grpc_md_only_test_credentials_create("Authorization", oauth2_md, 1); + grpc_credentials *ssl_oauth2_creds = + grpc_composite_credentials_create(ssl_creds, oauth2_creds, NULL); + grpc_arg ssl_name_override = {GRPC_ARG_STRING, + GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, + {"foo.test.google.fr"}}; + grpc_channel_args *new_client_args = + grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); + chttp2_init_client_secure_fullstack(f, new_client_args, ssl_oauth2_creds); + grpc_channel_args_destroy(new_client_args); + grpc_credentials_release(ssl_creds); + grpc_credentials_release(oauth2_creds); } -static int -fail_server_auth_check (grpc_channel_args * server_args) -{ +static int fail_server_auth_check(grpc_channel_args *server_args) { size_t i; - if (server_args == NULL) - return 0; - for (i = 0; i < server_args->num_args; i++) - { - if (strcmp (server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == 0) - { - return 1; - } + if (server_args == NULL) return 0; + for (i = 0; i < server_args->num_args; i++) { + if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == + 0) { + return 1; } + } return 0; } -static void -processor_destroy (void *state) -{ - test_processor_state *s = (test_processor_state *) state; - GPR_ASSERT ((s->pseudo_refcount--) == 1); - gpr_free (s); +static void processor_destroy(void *state) { + test_processor_state *s = (test_processor_state *)state; + GPR_ASSERT((s->pseudo_refcount--) == 1); + gpr_free(s); } -static grpc_auth_metadata_processor -test_processor_create (int failing) -{ - test_processor_state *s = gpr_malloc (sizeof (*s)); +static grpc_auth_metadata_processor test_processor_create(int failing) { + test_processor_state *s = gpr_malloc(sizeof(*s)); grpc_auth_metadata_processor result; s->pseudo_refcount = 1; result.state = s; result.destroy = processor_destroy; - if (failing) - { - result.process = process_oauth2_failure; - } - else - { - result.process = process_oauth2_success; - } + if (failing) { + result.process = process_oauth2_failure; + } else { + result.process = process_oauth2_success; + } return result; } -static void -chttp2_init_server_simple_ssl_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ - grpc_ssl_pem_key_cert_pair pem_key_cert_pair = { test_server1_key, - test_server1_cert - }; - grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create (NULL, &pem_key_cert_pair, 1, 0, NULL); - grpc_server_credentials_set_auth_metadata_processor (ssl_creds, test_processor_create (fail_server_auth_check (server_args))); - chttp2_init_server_secure_fullstack (f, server_args, ssl_creds); +static void chttp2_init_server_simple_ssl_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {test_server1_key, + test_server1_cert}; + grpc_server_credentials *ssl_creds = + grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL); + grpc_server_credentials_set_auth_metadata_processor( + ssl_creds, test_processor_create(fail_server_auth_check(server_args))); + chttp2_init_server_secure_fullstack(f, server_args, ssl_creds); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/simple_ssl_with_oauth2_fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, - chttp2_create_fixture_secure_fullstack, - chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack, - chttp2_init_server_simple_ssl_secure_fullstack, - chttp2_tear_down_secure_fullstack}, + {"chttp2/simple_ssl_with_oauth2_fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, + chttp2_create_fixture_secure_fullstack, + chttp2_init_client_simple_ssl_with_oauth2_secure_fullstack, + chttp2_init_server_simple_ssl_secure_fullstack, + chttp2_tear_down_secure_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); + grpc_test_init(argc, argv); - grpc_init (); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index 479db966ca..44083e2676 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -51,95 +51,82 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data -{ +typedef struct fullstack_fixture_data { grpc_end2end_proxy *proxy; } fullstack_fixture_data; -static grpc_server * -create_proxy_server (const char *port) -{ - grpc_server *s = grpc_server_create (NULL, NULL); - GPR_ASSERT (grpc_server_add_insecure_http2_port (s, port)); +static grpc_server *create_proxy_server(const char *port) { + grpc_server *s = grpc_server_create(NULL, NULL); + GPR_ASSERT(grpc_server_add_insecure_http2_port(s, port)); return s; } -static grpc_channel * -create_proxy_client (const char *target) -{ - return grpc_insecure_channel_create (target, NULL, NULL); +static grpc_channel *create_proxy_client(const char *target) { + return grpc_insecure_channel_create(target, NULL, NULL); } -static const grpc_end2end_proxy_def proxy_def = { create_proxy_server, - create_proxy_client -}; +static const grpc_end2end_proxy_def proxy_def = {create_proxy_server, + create_proxy_client}; -static grpc_end2end_test_fixture -chttp2_create_fixture_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - fullstack_fixture_data *ffd = gpr_malloc (sizeof (fullstack_fixture_data)); - memset (&f, 0, sizeof (f)); + fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data)); + memset(&f, 0, sizeof(f)); - ffd->proxy = grpc_end2end_proxy_create (&proxy_def); + ffd->proxy = grpc_end2end_proxy_create(&proxy_def); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -void -chttp2_init_client_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { fullstack_fixture_data *ffd = f->fixture_data; - f->client = grpc_insecure_channel_create (grpc_end2end_proxy_get_client_target (ffd->proxy), client_args, NULL); - GPR_ASSERT (f->client); + f->client = grpc_insecure_channel_create( + grpc_end2end_proxy_get_client_target(ffd->proxy), client_args, NULL); + GPR_ASSERT(f->client); } -void -chttp2_init_server_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { fullstack_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_insecure_http2_port (f->server, grpc_end2end_proxy_get_server_port (ffd->proxy))); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_insecure_http2_port( + f->server, grpc_end2end_proxy_get_server_port(ffd->proxy))); + grpc_server_start(f->server); } -void -chttp2_tear_down_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { fullstack_fixture_data *ffd = f->fixture_data; - grpc_end2end_proxy_destroy (ffd->proxy); - gpr_free (ffd); + grpc_end2end_proxy_destroy(ffd->proxy); + gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, - chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, - chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, + {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, + chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, + chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index 2ba0c0793f..1f5051f0ab 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -57,133 +57,127 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void -server_setup_transport (void *ts, grpc_transport * transport, grpc_mdctx * mdctx) -{ +static void server_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { - &grpc_http_server_filter - }; + &grpc_http_server_filter}; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_server_setup_transport (&exec_ctx, f->server, transport, extra_filters, GPR_ARRAY_SIZE (extra_filters), mdctx, grpc_server_get_channel_args (f->server)); - grpc_exec_ctx_finish (&exec_ctx); + grpc_server_setup_transport(&exec_ctx, f->server, transport, extra_filters, + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(f->server)); + grpc_exec_ctx_finish(&exec_ctx); } -typedef struct -{ +typedef struct { grpc_end2end_test_fixture *f; grpc_channel_args *client_args; } sp_client_setup; -static void -client_setup_transport (grpc_exec_ctx * exec_ctx, void *ts, grpc_transport * transport, grpc_mdctx * mdctx) -{ +static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, + grpc_transport *transport, + grpc_mdctx *mdctx) { sp_client_setup *cs = ts; - const grpc_channel_filter *filters[] = { &grpc_http_client_filter, - &grpc_compress_filter, - &grpc_connected_channel_filter - }; - size_t nfilters = sizeof (filters) / sizeof (*filters); - grpc_channel *channel = grpc_channel_create_from_filters (exec_ctx, "socketpair-target", filters, nfilters, - cs->client_args, mdctx, 1); + const grpc_channel_filter *filters[] = {&grpc_http_client_filter, + &grpc_compress_filter, + &grpc_connected_channel_filter}; + size_t nfilters = sizeof(filters) / sizeof(*filters); + grpc_channel *channel = + grpc_channel_create_from_filters(exec_ctx, "socketpair-target", filters, + nfilters, cs->client_args, mdctx, 1); cs->f->client = channel; - grpc_connected_channel_bind_transport (grpc_channel_get_channel_stack (channel), transport); + grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel), + transport); } -static grpc_end2end_test_fixture -chttp2_create_fixture_socketpair (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ - grpc_endpoint_pair *sfd = gpr_malloc (sizeof (grpc_endpoint_pair)); +static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( + grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_endpoint_pair *sfd = gpr_malloc(sizeof(grpc_endpoint_pair)); grpc_end2end_test_fixture f; - memset (&f, 0, sizeof (f)); + memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); - *sfd = grpc_iomgr_create_endpoint_pair ("fixture", 65536); + *sfd = grpc_iomgr_create_endpoint_pair("fixture", 65536); return f; } -static void -chttp2_init_client_socketpair (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_pair *sfd = f->fixture_data; grpc_transport *transport; - grpc_mdctx *mdctx = grpc_mdctx_create (); + grpc_mdctx *mdctx = grpc_mdctx_create(); sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = grpc_create_chttp2_transport (&exec_ctx, client_args, sfd->client, mdctx, 1); - client_setup_transport (&exec_ctx, &cs, transport, mdctx); - GPR_ASSERT (f->client); - grpc_chttp2_transport_start_reading (&exec_ctx, transport, NULL, 0); - grpc_exec_ctx_finish (&exec_ctx); + transport = grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, + mdctx, 1); + client_setup_transport(&exec_ctx, &cs, transport, mdctx); + GPR_ASSERT(f->client); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + grpc_exec_ctx_finish(&exec_ctx); } -static void -chttp2_init_server_socketpair (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_pair *sfd = f->fixture_data; - grpc_mdctx *mdctx = grpc_mdctx_create (); + grpc_mdctx *mdctx = grpc_mdctx_create(); grpc_transport *transport; - GPR_ASSERT (!f->server); - f->server = grpc_server_create_from_filters (NULL, 0, server_args); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - grpc_server_start (f->server); - transport = grpc_create_chttp2_transport (&exec_ctx, server_args, sfd->server, mdctx, 0); - server_setup_transport (f, transport, mdctx); - grpc_chttp2_transport_start_reading (&exec_ctx, transport, NULL, 0); - grpc_exec_ctx_finish (&exec_ctx); + GPR_ASSERT(!f->server); + f->server = grpc_server_create_from_filters(NULL, 0, server_args); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + grpc_server_start(f->server); + transport = grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, + mdctx, 0); + server_setup_transport(f, transport, mdctx); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + grpc_exec_ctx_finish(&exec_ctx); } -static void -chttp2_tear_down_socketpair (grpc_end2end_test_fixture * f) -{ - gpr_free (f->fixture_data); +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { + gpr_free(f->fixture_data); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/socketpair", 0, chttp2_create_fixture_socketpair, - chttp2_init_client_socketpair, chttp2_init_server_socketpair, - chttp2_tear_down_socketpair}, + {"chttp2/socketpair", 0, chttp2_create_fixture_socketpair, + chttp2_init_client_socketpair, chttp2_init_server_socketpair, + chttp2_tear_down_socketpair}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; /* force tracing on, with a value to force many code paths in trace.c to be taken */ - gpr_setenv ("GRPC_TRACE", "doesnt-exist,http,all"); + gpr_setenv("GRPC_TRACE", "doesnt-exist,http,all"); #ifdef GPR_POSIX_SOCKET - g_fixture_slowdown_factor = isatty (STDOUT_FILENO) ? 10.0 : 1.0; + g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10.0 : 1.0; #else g_fixture_slowdown_factor = 10.0; #endif - grpc_test_init (argc, argv); - grpc_init (); - grpc_exec_ctx_finish (&exec_ctx); + grpc_test_init(argc, argv); + grpc_init(); + grpc_exec_ctx_finish(&exec_ctx); - GPR_ASSERT (0 == grpc_tracer_set_enabled ("also-doesnt-exist", 0)); - GPR_ASSERT (1 == grpc_tracer_set_enabled ("http", 1)); - GPR_ASSERT (1 == grpc_tracer_set_enabled ("all", 1)); + GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0)); + GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1)); + GPR_ASSERT(1 == grpc_tracer_set_enabled("all", 1)); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index c0296a1b09..b61fe98610 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -56,118 +56,112 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void -server_setup_transport (void *ts, grpc_transport * transport, grpc_mdctx * mdctx) -{ +static void server_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { - &grpc_http_server_filter - }; + &grpc_http_server_filter}; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_server_setup_transport (&exec_ctx, f->server, transport, extra_filters, GPR_ARRAY_SIZE (extra_filters), mdctx, grpc_server_get_channel_args (f->server)); - grpc_exec_ctx_finish (&exec_ctx); + grpc_server_setup_transport(&exec_ctx, f->server, transport, extra_filters, + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(f->server)); + grpc_exec_ctx_finish(&exec_ctx); } -typedef struct -{ +typedef struct { grpc_end2end_test_fixture *f; grpc_channel_args *client_args; } sp_client_setup; -static void -client_setup_transport (grpc_exec_ctx * exec_ctx, void *ts, grpc_transport * transport, grpc_mdctx * mdctx) -{ +static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, + grpc_transport *transport, + grpc_mdctx *mdctx) { sp_client_setup *cs = ts; - const grpc_channel_filter *filters[] = { &grpc_http_client_filter, - &grpc_compress_filter, - &grpc_connected_channel_filter - }; - size_t nfilters = sizeof (filters) / sizeof (*filters); - grpc_channel *channel = grpc_channel_create_from_filters (exec_ctx,"socketpair-target", filters, nfilters, - cs->client_args, mdctx, 1); + const grpc_channel_filter *filters[] = {&grpc_http_client_filter, + &grpc_compress_filter, + &grpc_connected_channel_filter}; + size_t nfilters = sizeof(filters) / sizeof(*filters); + grpc_channel *channel = + grpc_channel_create_from_filters(exec_ctx, "socketpair-target", filters, + nfilters, cs->client_args, mdctx, 1); cs->f->client = channel; - grpc_connected_channel_bind_transport (grpc_channel_get_channel_stack (channel), transport); + grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel), + transport); } -static grpc_end2end_test_fixture -chttp2_create_fixture_socketpair (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ - grpc_endpoint_pair *sfd = gpr_malloc (sizeof (grpc_endpoint_pair)); +static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( + grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_endpoint_pair *sfd = gpr_malloc(sizeof(grpc_endpoint_pair)); grpc_end2end_test_fixture f; - memset (&f, 0, sizeof (f)); + memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); - *sfd = grpc_iomgr_create_endpoint_pair ("fixture", 65536); + *sfd = grpc_iomgr_create_endpoint_pair("fixture", 65536); return f; } -static void -chttp2_init_client_socketpair (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_pair *sfd = f->fixture_data; grpc_transport *transport; - grpc_mdctx *mdctx = grpc_mdctx_create (); + grpc_mdctx *mdctx = grpc_mdctx_create(); sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = grpc_create_chttp2_transport (&exec_ctx, client_args, sfd->client, mdctx, 1); - client_setup_transport (&exec_ctx, &cs, transport, mdctx); - GPR_ASSERT (f->client); - grpc_chttp2_transport_start_reading (&exec_ctx, transport, NULL, 0); - grpc_exec_ctx_finish (&exec_ctx); + transport = grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, + mdctx, 1); + client_setup_transport(&exec_ctx, &cs, transport, mdctx); + GPR_ASSERT(f->client); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + grpc_exec_ctx_finish(&exec_ctx); } -static void -chttp2_init_server_socketpair (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_pair *sfd = f->fixture_data; - grpc_mdctx *mdctx = grpc_mdctx_create (); + grpc_mdctx *mdctx = grpc_mdctx_create(); grpc_transport *transport; - GPR_ASSERT (!f->server); - f->server = grpc_server_create_from_filters (NULL, 0, server_args); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - grpc_server_start (f->server); - transport = grpc_create_chttp2_transport (&exec_ctx, server_args, sfd->server, mdctx, 0); - server_setup_transport (f, transport, mdctx); - grpc_chttp2_transport_start_reading (&exec_ctx, transport, NULL, 0); - grpc_exec_ctx_finish (&exec_ctx); + GPR_ASSERT(!f->server); + f->server = grpc_server_create_from_filters(NULL, 0, server_args); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + grpc_server_start(f->server); + transport = grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, + mdctx, 0); + server_setup_transport(f, transport, mdctx); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + grpc_exec_ctx_finish(&exec_ctx); } -static void -chttp2_tear_down_socketpair (grpc_end2end_test_fixture * f) -{ - gpr_free (f->fixture_data); +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { + gpr_free(f->fixture_data); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/socketpair", 0, chttp2_create_fixture_socketpair, - chttp2_init_client_socketpair, chttp2_init_server_socketpair, - chttp2_tear_down_socketpair}, + {"chttp2/socketpair", 0, chttp2_create_fixture_socketpair, + chttp2_init_client_socketpair, chttp2_init_server_socketpair, + chttp2_tear_down_socketpair}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 1f39499d09..9f0fd2ea9a 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -56,118 +56,112 @@ /* chttp2 transport that is immediately available (used for testing connected_channel without a client_channel */ -static void -server_setup_transport (void *ts, grpc_transport * transport, grpc_mdctx * mdctx) -{ +static void server_setup_transport(void *ts, grpc_transport *transport, + grpc_mdctx *mdctx) { grpc_end2end_test_fixture *f = ts; static grpc_channel_filter const *extra_filters[] = { - &grpc_http_server_filter - }; + &grpc_http_server_filter}; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_server_setup_transport (&exec_ctx, f->server, transport, extra_filters, GPR_ARRAY_SIZE (extra_filters), mdctx, grpc_server_get_channel_args (f->server)); - grpc_exec_ctx_finish (&exec_ctx); + grpc_server_setup_transport(&exec_ctx, f->server, transport, extra_filters, + GPR_ARRAY_SIZE(extra_filters), mdctx, + grpc_server_get_channel_args(f->server)); + grpc_exec_ctx_finish(&exec_ctx); } -typedef struct -{ +typedef struct { grpc_end2end_test_fixture *f; grpc_channel_args *client_args; } sp_client_setup; -static void -client_setup_transport (grpc_exec_ctx * exec_ctx, void *ts, grpc_transport * transport, grpc_mdctx * mdctx) -{ +static void client_setup_transport(grpc_exec_ctx *exec_ctx, void *ts, + grpc_transport *transport, + grpc_mdctx *mdctx) { sp_client_setup *cs = ts; - const grpc_channel_filter *filters[] = { &grpc_http_client_filter, - &grpc_compress_filter, - &grpc_connected_channel_filter - }; - size_t nfilters = sizeof (filters) / sizeof (*filters); - grpc_channel *channel = grpc_channel_create_from_filters (exec_ctx, "socketpair-target", filters, nfilters, - cs->client_args, mdctx, 1); + const grpc_channel_filter *filters[] = {&grpc_http_client_filter, + &grpc_compress_filter, + &grpc_connected_channel_filter}; + size_t nfilters = sizeof(filters) / sizeof(*filters); + grpc_channel *channel = + grpc_channel_create_from_filters(exec_ctx, "socketpair-target", filters, + nfilters, cs->client_args, mdctx, 1); cs->f->client = channel; - grpc_connected_channel_bind_transport (grpc_channel_get_channel_stack (channel), transport); + grpc_connected_channel_bind_transport(grpc_channel_get_channel_stack(channel), + transport); } -static grpc_end2end_test_fixture -chttp2_create_fixture_socketpair (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ - grpc_endpoint_pair *sfd = gpr_malloc (sizeof (grpc_endpoint_pair)); +static grpc_end2end_test_fixture chttp2_create_fixture_socketpair( + grpc_channel_args *client_args, grpc_channel_args *server_args) { + grpc_endpoint_pair *sfd = gpr_malloc(sizeof(grpc_endpoint_pair)); grpc_end2end_test_fixture f; - memset (&f, 0, sizeof (f)); + memset(&f, 0, sizeof(f)); f.fixture_data = sfd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); - *sfd = grpc_iomgr_create_endpoint_pair ("fixture", 1); + *sfd = grpc_iomgr_create_endpoint_pair("fixture", 1); return f; } -static void -chttp2_init_client_socketpair (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +static void chttp2_init_client_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_pair *sfd = f->fixture_data; grpc_transport *transport; - grpc_mdctx *mdctx = grpc_mdctx_create (); + grpc_mdctx *mdctx = grpc_mdctx_create(); sp_client_setup cs; cs.client_args = client_args; cs.f = f; - transport = grpc_create_chttp2_transport (&exec_ctx, client_args, sfd->client, mdctx, 1); - client_setup_transport (&exec_ctx, &cs, transport, mdctx); - GPR_ASSERT (f->client); - grpc_chttp2_transport_start_reading (&exec_ctx, transport, NULL, 0); - grpc_exec_ctx_finish (&exec_ctx); + transport = grpc_create_chttp2_transport(&exec_ctx, client_args, sfd->client, + mdctx, 1); + client_setup_transport(&exec_ctx, &cs, transport, mdctx); + GPR_ASSERT(f->client); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + grpc_exec_ctx_finish(&exec_ctx); } -static void -chttp2_init_server_socketpair (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +static void chttp2_init_server_socketpair(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_pair *sfd = f->fixture_data; - grpc_mdctx *mdctx = grpc_mdctx_create (); + grpc_mdctx *mdctx = grpc_mdctx_create(); grpc_transport *transport; - GPR_ASSERT (!f->server); - f->server = grpc_server_create_from_filters (NULL, 0, server_args); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - grpc_server_start (f->server); - transport = grpc_create_chttp2_transport (&exec_ctx, server_args, sfd->server, mdctx, 0); - server_setup_transport (f, transport, mdctx); - grpc_chttp2_transport_start_reading (&exec_ctx, transport, NULL, 0); - grpc_exec_ctx_finish (&exec_ctx); + GPR_ASSERT(!f->server); + f->server = grpc_server_create_from_filters(NULL, 0, server_args); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + grpc_server_start(f->server); + transport = grpc_create_chttp2_transport(&exec_ctx, server_args, sfd->server, + mdctx, 0); + server_setup_transport(f, transport, mdctx); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL, 0); + grpc_exec_ctx_finish(&exec_ctx); } -static void -chttp2_tear_down_socketpair (grpc_end2end_test_fixture * f) -{ - gpr_free (f->fixture_data); +static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { + gpr_free(f->fixture_data); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/socketpair_one_byte_at_a_time", 0, - chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, - chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, + {"chttp2/socketpair_one_byte_at_a_time", 0, + chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, + chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_ssl+poll.c b/test/core/end2end/fixtures/h2_ssl+poll.c index 55c12a37ca..2c605d1471 100644 --- a/test/core/end2end/fixtures/h2_ssl+poll.c +++ b/test/core/end2end/fixtures/h2_ssl+poll.c @@ -48,153 +48,145 @@ #include "test/core/util/port.h" #include "test/core/end2end/data/ssl_test_data.h" -typedef struct fullstack_secure_fixture_data -{ +typedef struct fullstack_secure_fixture_data { char *localaddr; } fullstack_secure_fixture_data; -static grpc_end2end_test_fixture -chttp2_create_fixture_secure_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die (); - fullstack_secure_fixture_data *ffd = gpr_malloc (sizeof (fullstack_secure_fixture_data)); - memset (&f, 0, sizeof (f)); + int port = grpc_pick_unused_port_or_die(); + fullstack_secure_fixture_data *ffd = + gpr_malloc(sizeof(fullstack_secure_fixture_data)); + memset(&f, 0, sizeof(f)); - gpr_join_host_port (&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -static void -process_auth_failure (void *state, grpc_auth_context * ctx, const grpc_metadata * md, size_t md_count, grpc_process_auth_metadata_done_cb cb, void *user_data) -{ - GPR_ASSERT (state == NULL); - cb (user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); +static void process_auth_failure(void *state, grpc_auth_context *ctx, + const grpc_metadata *md, size_t md_count, + grpc_process_auth_metadata_done_cb cb, + void *user_data) { + GPR_ASSERT(state == NULL); + cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void -chttp2_init_client_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args, grpc_credentials * creds) -{ +static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args, + grpc_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - f->client = grpc_secure_channel_create (creds, ffd->localaddr, client_args, NULL); - GPR_ASSERT (f->client != NULL); - grpc_credentials_release (creds); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); + GPR_ASSERT(f->client != NULL); + grpc_credentials_release(creds); } -static void -chttp2_init_server_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args, grpc_server_credentials * server_creds) -{ +static void chttp2_init_server_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args, + grpc_server_credentials *server_creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_secure_http2_port (f->server, ffd->localaddr, server_creds)); - grpc_server_credentials_release (server_creds); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + server_creds)); + grpc_server_credentials_release(server_creds); + grpc_server_start(f->server); } -void -chttp2_tear_down_secure_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } -static void -chttp2_init_client_simple_ssl_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ - grpc_credentials *ssl_creds = grpc_ssl_credentials_create (NULL, NULL, NULL); - grpc_arg ssl_name_override = { GRPC_ARG_STRING, - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - {"foo.test.google.fr"} - }; - grpc_channel_args *new_client_args = grpc_channel_args_copy_and_add (client_args, &ssl_name_override, 1); - chttp2_init_client_secure_fullstack (f, new_client_args, ssl_creds); - grpc_channel_args_destroy (new_client_args); +static void chttp2_init_client_simple_ssl_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { + grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_arg ssl_name_override = {GRPC_ARG_STRING, + GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, + {"foo.test.google.fr"}}; + grpc_channel_args *new_client_args = + grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); + chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); + grpc_channel_args_destroy(new_client_args); } -static int -fail_server_auth_check (grpc_channel_args * server_args) -{ +static int fail_server_auth_check(grpc_channel_args *server_args) { size_t i; - if (server_args == NULL) - return 0; - for (i = 0; i < server_args->num_args; i++) - { - if (strcmp (server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == 0) - { - return 1; - } + if (server_args == NULL) return 0; + for (i = 0; i < server_args->num_args; i++) { + if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == + 0) { + return 1; } + } return 0; } -static void -chttp2_init_server_simple_ssl_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ - grpc_ssl_pem_key_cert_pair pem_cert_key_pair = { test_server1_key, - test_server1_cert - }; - grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create (NULL, &pem_cert_key_pair, 1, 0, NULL); - if (fail_server_auth_check (server_args)) - { - grpc_auth_metadata_processor processor = { process_auth_failure, NULL, NULL }; - grpc_server_credentials_set_auth_metadata_processor (ssl_creds, processor); - } - chttp2_init_server_secure_fullstack (f, server_args, ssl_creds); +static void chttp2_init_server_simple_ssl_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, + test_server1_cert}; + grpc_server_credentials *ssl_creds = + grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL); + if (fail_server_auth_check(server_args)) { + grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL}; + grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor); + } + chttp2_init_server_secure_fullstack(f, server_args, ssl_creds); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/simple_ssl_fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, - chttp2_create_fixture_secure_fullstack, - chttp2_init_client_simple_ssl_secure_fullstack, - chttp2_init_server_simple_ssl_secure_fullstack, - chttp2_tear_down_secure_fullstack}, + {"chttp2/simple_ssl_fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, + chttp2_create_fixture_secure_fullstack, + chttp2_init_client_simple_ssl_secure_fullstack, + chttp2_init_server_simple_ssl_secure_fullstack, + chttp2_tear_down_secure_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; FILE *roots_file; - size_t roots_size = strlen (test_root_cert); + size_t roots_size = strlen(test_root_cert); char *roots_filename; grpc_platform_become_multipoller = grpc_poll_become_multipoller; - grpc_test_init (argc, argv); + grpc_test_init(argc, argv); /* Set the SSL roots env var. */ - roots_file = gpr_tmpfile ("chttp2_simple_ssl_with_poll_fullstack_test", &roots_filename); - GPR_ASSERT (roots_filename != NULL); - GPR_ASSERT (roots_file != NULL); - GPR_ASSERT (fwrite (test_root_cert, 1, roots_size, roots_file) == roots_size); - fclose (roots_file); - gpr_setenv (GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); - - grpc_init (); - - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + roots_file = gpr_tmpfile("chttp2_simple_ssl_with_poll_fullstack_test", + &roots_filename); + GPR_ASSERT(roots_filename != NULL); + GPR_ASSERT(roots_file != NULL); + GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); + fclose(roots_file); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + + grpc_init(); + + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); /* Cleanup. */ - remove (roots_filename); - gpr_free (roots_filename); + remove(roots_filename); + gpr_free(roots_filename); return 0; } diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c index 7752ff2703..9193a09b17 100644 --- a/test/core/end2end/fixtures/h2_ssl.c +++ b/test/core/end2end/fixtures/h2_ssl.c @@ -48,151 +48,142 @@ #include "test/core/util/port.h" #include "test/core/end2end/data/ssl_test_data.h" -typedef struct fullstack_secure_fixture_data -{ +typedef struct fullstack_secure_fixture_data { char *localaddr; } fullstack_secure_fixture_data; -static grpc_end2end_test_fixture -chttp2_create_fixture_secure_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - int port = grpc_pick_unused_port_or_die (); - fullstack_secure_fixture_data *ffd = gpr_malloc (sizeof (fullstack_secure_fixture_data)); - memset (&f, 0, sizeof (f)); + int port = grpc_pick_unused_port_or_die(); + fullstack_secure_fixture_data *ffd = + gpr_malloc(sizeof(fullstack_secure_fixture_data)); + memset(&f, 0, sizeof(f)); - gpr_join_host_port (&ffd->localaddr, "localhost", port); + gpr_join_host_port(&ffd->localaddr, "localhost", port); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -static void -process_auth_failure (void *state, grpc_auth_context * ctx, const grpc_metadata * md, size_t md_count, grpc_process_auth_metadata_done_cb cb, void *user_data) -{ - GPR_ASSERT (state == NULL); - cb (user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); +static void process_auth_failure(void *state, grpc_auth_context *ctx, + const grpc_metadata *md, size_t md_count, + grpc_process_auth_metadata_done_cb cb, + void *user_data) { + GPR_ASSERT(state == NULL); + cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void -chttp2_init_client_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args, grpc_credentials * creds) -{ +static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args, + grpc_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - f->client = grpc_secure_channel_create (creds, ffd->localaddr, client_args, NULL); - GPR_ASSERT (f->client != NULL); - grpc_credentials_release (creds); + f->client = + grpc_secure_channel_create(creds, ffd->localaddr, client_args, NULL); + GPR_ASSERT(f->client != NULL); + grpc_credentials_release(creds); } -static void -chttp2_init_server_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args, grpc_server_credentials * server_creds) -{ +static void chttp2_init_server_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args, + grpc_server_credentials *server_creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_secure_http2_port (f->server, ffd->localaddr, server_creds)); - grpc_server_credentials_release (server_creds); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_secure_http2_port(f->server, ffd->localaddr, + server_creds)); + grpc_server_credentials_release(server_creds); + grpc_server_start(f->server); } -void -chttp2_tear_down_secure_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } -static void -chttp2_init_client_simple_ssl_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ - grpc_credentials *ssl_creds = grpc_ssl_credentials_create (NULL, NULL, NULL); - grpc_arg ssl_name_override = { GRPC_ARG_STRING, - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - {"foo.test.google.fr"} - }; - grpc_channel_args *new_client_args = grpc_channel_args_copy_and_add (client_args, &ssl_name_override, 1); - chttp2_init_client_secure_fullstack (f, new_client_args, ssl_creds); - grpc_channel_args_destroy (new_client_args); +static void chttp2_init_client_simple_ssl_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { + grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_arg ssl_name_override = {GRPC_ARG_STRING, + GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, + {"foo.test.google.fr"}}; + grpc_channel_args *new_client_args = + grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); + chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); + grpc_channel_args_destroy(new_client_args); } -static int -fail_server_auth_check (grpc_channel_args * server_args) -{ +static int fail_server_auth_check(grpc_channel_args *server_args) { size_t i; - if (server_args == NULL) - return 0; - for (i = 0; i < server_args->num_args; i++) - { - if (strcmp (server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == 0) - { - return 1; - } + if (server_args == NULL) return 0; + for (i = 0; i < server_args->num_args; i++) { + if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == + 0) { + return 1; } + } return 0; } -static void -chttp2_init_server_simple_ssl_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ - grpc_ssl_pem_key_cert_pair pem_cert_key_pair = { test_server1_key, - test_server1_cert - }; - grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create (NULL, &pem_cert_key_pair, 1, 0, NULL); - if (fail_server_auth_check (server_args)) - { - grpc_auth_metadata_processor processor = { process_auth_failure, NULL, NULL }; - grpc_server_credentials_set_auth_metadata_processor (ssl_creds, processor); - } - chttp2_init_server_secure_fullstack (f, server_args, ssl_creds); +static void chttp2_init_server_simple_ssl_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, + test_server1_cert}; + grpc_server_credentials *ssl_creds = + grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL); + if (fail_server_auth_check(server_args)) { + grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL}; + grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor); + } + chttp2_init_server_secure_fullstack(f, server_args, ssl_creds); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/simple_ssl_fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, - chttp2_create_fixture_secure_fullstack, - chttp2_init_client_simple_ssl_secure_fullstack, - chttp2_init_server_simple_ssl_secure_fullstack, - chttp2_tear_down_secure_fullstack}, + {"chttp2/simple_ssl_fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, + chttp2_create_fixture_secure_fullstack, + chttp2_init_client_simple_ssl_secure_fullstack, + chttp2_init_server_simple_ssl_secure_fullstack, + chttp2_tear_down_secure_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; FILE *roots_file; - size_t roots_size = strlen (test_root_cert); + size_t roots_size = strlen(test_root_cert); char *roots_filename; - grpc_test_init (argc, argv); + grpc_test_init(argc, argv); /* Set the SSL roots env var. */ - roots_file = gpr_tmpfile ("chttp2_simple_ssl_fullstack_test", &roots_filename); - GPR_ASSERT (roots_filename != NULL); - GPR_ASSERT (roots_file != NULL); - GPR_ASSERT (fwrite (test_root_cert, 1, roots_size, roots_file) == roots_size); - fclose (roots_file); - gpr_setenv (GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); - - grpc_init (); - - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + roots_file = gpr_tmpfile("chttp2_simple_ssl_fullstack_test", &roots_filename); + GPR_ASSERT(roots_filename != NULL); + GPR_ASSERT(roots_file != NULL); + GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); + fclose(roots_file); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + + grpc_init(); + + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); /* Cleanup. */ - remove (roots_filename); - gpr_free (roots_filename); + remove(roots_filename); + gpr_free(roots_filename); return 0; } diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c index ff82a0f291..8133a69a0c 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.c +++ b/test/core/end2end/fixtures/h2_ssl_proxy.c @@ -49,184 +49,170 @@ #include "test/core/util/test_config.h" #include "test/core/util/port.h" -typedef struct fullstack_secure_fixture_data -{ +typedef struct fullstack_secure_fixture_data { grpc_end2end_proxy *proxy; } fullstack_secure_fixture_data; -static grpc_server * -create_proxy_server (const char *port) -{ - grpc_server *s = grpc_server_create (NULL, NULL); - grpc_ssl_pem_key_cert_pair pem_cert_key_pair = { test_server1_key, - test_server1_cert - }; - grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create (NULL, &pem_cert_key_pair, 1, 0, NULL); - GPR_ASSERT (grpc_server_add_secure_http2_port (s, port, ssl_creds)); - grpc_server_credentials_release (ssl_creds); +static grpc_server *create_proxy_server(const char *port) { + grpc_server *s = grpc_server_create(NULL, NULL); + grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, + test_server1_cert}; + grpc_server_credentials *ssl_creds = + grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL); + GPR_ASSERT(grpc_server_add_secure_http2_port(s, port, ssl_creds)); + grpc_server_credentials_release(ssl_creds); return s; } -static grpc_channel * -create_proxy_client (const char *target) -{ +static grpc_channel *create_proxy_client(const char *target) { grpc_channel *channel; - grpc_credentials *ssl_creds = grpc_ssl_credentials_create (NULL, NULL, NULL); - grpc_arg ssl_name_override = { GRPC_ARG_STRING, - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - {"foo.test.google.fr"} - }; + grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_arg ssl_name_override = {GRPC_ARG_STRING, + GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, + {"foo.test.google.fr"}}; grpc_channel_args client_args; client_args.num_args = 1; client_args.args = &ssl_name_override; - channel = grpc_secure_channel_create (ssl_creds, target, &client_args, NULL); - grpc_credentials_release (ssl_creds); + channel = grpc_secure_channel_create(ssl_creds, target, &client_args, NULL); + grpc_credentials_release(ssl_creds); return channel; } -static const grpc_end2end_proxy_def proxy_def = { create_proxy_server, - create_proxy_client -}; +static const grpc_end2end_proxy_def proxy_def = {create_proxy_server, + create_proxy_client}; -static grpc_end2end_test_fixture -chttp2_create_fixture_secure_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_secure_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - fullstack_secure_fixture_data *ffd = gpr_malloc (sizeof (fullstack_secure_fixture_data)); - memset (&f, 0, sizeof (f)); + fullstack_secure_fixture_data *ffd = + gpr_malloc(sizeof(fullstack_secure_fixture_data)); + memset(&f, 0, sizeof(f)); - ffd->proxy = grpc_end2end_proxy_create (&proxy_def); + ffd->proxy = grpc_end2end_proxy_create(&proxy_def); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -static void -process_auth_failure (void *state, grpc_auth_context * ctx, const grpc_metadata * md, size_t md_count, grpc_process_auth_metadata_done_cb cb, void *user_data) -{ - GPR_ASSERT (state == NULL); - cb (user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); +static void process_auth_failure(void *state, grpc_auth_context *ctx, + const grpc_metadata *md, size_t md_count, + grpc_process_auth_metadata_done_cb cb, + void *user_data) { + GPR_ASSERT(state == NULL); + cb(user_data, NULL, 0, NULL, 0, GRPC_STATUS_UNAUTHENTICATED, NULL); } -static void -chttp2_init_client_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args, grpc_credentials * creds) -{ +static void chttp2_init_client_secure_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args, + grpc_credentials *creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - f->client = grpc_secure_channel_create (creds, grpc_end2end_proxy_get_client_target (ffd->proxy), client_args, NULL); - GPR_ASSERT (f->client != NULL); - grpc_credentials_release (creds); + f->client = grpc_secure_channel_create( + creds, grpc_end2end_proxy_get_client_target(ffd->proxy), client_args, + NULL); + GPR_ASSERT(f->client != NULL); + grpc_credentials_release(creds); } -static void -chttp2_init_server_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args, grpc_server_credentials * server_creds) -{ +static void chttp2_init_server_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args, + grpc_server_credentials *server_creds) { fullstack_secure_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_secure_http2_port (f->server, grpc_end2end_proxy_get_server_port (ffd->proxy), server_creds)); - grpc_server_credentials_release (server_creds); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_secure_http2_port( + f->server, grpc_end2end_proxy_get_server_port(ffd->proxy), server_creds)); + grpc_server_credentials_release(server_creds); + grpc_server_start(f->server); } -void -chttp2_tear_down_secure_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_secure_fullstack(grpc_end2end_test_fixture *f) { fullstack_secure_fixture_data *ffd = f->fixture_data; - grpc_end2end_proxy_destroy (ffd->proxy); - gpr_free (ffd); + grpc_end2end_proxy_destroy(ffd->proxy); + gpr_free(ffd); } -static void -chttp2_init_client_simple_ssl_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ - grpc_credentials *ssl_creds = grpc_ssl_credentials_create (NULL, NULL, NULL); - grpc_arg ssl_name_override = { GRPC_ARG_STRING, - GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, - {"foo.test.google.fr"} - }; - grpc_channel_args *new_client_args = grpc_channel_args_copy_and_add (client_args, &ssl_name_override, 1); - chttp2_init_client_secure_fullstack (f, new_client_args, ssl_creds); - grpc_channel_args_destroy (new_client_args); +static void chttp2_init_client_simple_ssl_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *client_args) { + grpc_credentials *ssl_creds = grpc_ssl_credentials_create(NULL, NULL, NULL); + grpc_arg ssl_name_override = {GRPC_ARG_STRING, + GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, + {"foo.test.google.fr"}}; + grpc_channel_args *new_client_args = + grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); + chttp2_init_client_secure_fullstack(f, new_client_args, ssl_creds); + grpc_channel_args_destroy(new_client_args); } -static int -fail_server_auth_check (grpc_channel_args * server_args) -{ +static int fail_server_auth_check(grpc_channel_args *server_args) { size_t i; - if (server_args == NULL) - return 0; - for (i = 0; i < server_args->num_args; i++) - { - if (strcmp (server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == 0) - { - return 1; - } + if (server_args == NULL) return 0; + for (i = 0; i < server_args->num_args; i++) { + if (strcmp(server_args->args[i].key, FAIL_AUTH_CHECK_SERVER_ARG_NAME) == + 0) { + return 1; } + } return 0; } -static void -chttp2_init_server_simple_ssl_secure_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ - grpc_ssl_pem_key_cert_pair pem_cert_key_pair = { test_server1_key, - test_server1_cert - }; - grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create (NULL, &pem_cert_key_pair, 1, 0, NULL); - if (fail_server_auth_check (server_args)) - { - grpc_auth_metadata_processor processor = { process_auth_failure, NULL, NULL }; - grpc_server_credentials_set_auth_metadata_processor (ssl_creds, processor); - } - chttp2_init_server_secure_fullstack (f, server_args, ssl_creds); +static void chttp2_init_server_simple_ssl_secure_fullstack( + grpc_end2end_test_fixture *f, grpc_channel_args *server_args) { + grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, + test_server1_cert}; + grpc_server_credentials *ssl_creds = + grpc_ssl_server_credentials_create(NULL, &pem_cert_key_pair, 1, 0, NULL); + if (fail_server_auth_check(server_args)) { + grpc_auth_metadata_processor processor = {process_auth_failure, NULL, NULL}; + grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor); + } + chttp2_init_server_secure_fullstack(f, server_args, ssl_creds); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/simple_ssl_fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, - chttp2_create_fixture_secure_fullstack, - chttp2_init_client_simple_ssl_secure_fullstack, - chttp2_init_server_simple_ssl_secure_fullstack, - chttp2_tear_down_secure_fullstack}, + {"chttp2/simple_ssl_fullstack", + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION | + FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, + chttp2_create_fixture_secure_fullstack, + chttp2_init_client_simple_ssl_secure_fullstack, + chttp2_init_server_simple_ssl_secure_fullstack, + chttp2_tear_down_secure_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; FILE *roots_file; - size_t roots_size = strlen (test_root_cert); + size_t roots_size = strlen(test_root_cert); char *roots_filename; - grpc_test_init (argc, argv); + grpc_test_init(argc, argv); /* Set the SSL roots env var. */ - roots_file = gpr_tmpfile ("chttp2_simple_ssl_fullstack_test", &roots_filename); - GPR_ASSERT (roots_filename != NULL); - GPR_ASSERT (roots_file != NULL); - GPR_ASSERT (fwrite (test_root_cert, 1, roots_size, roots_file) == roots_size); - fclose (roots_file); - gpr_setenv (GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); - - grpc_init (); - - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + roots_file = gpr_tmpfile("chttp2_simple_ssl_fullstack_test", &roots_filename); + GPR_ASSERT(roots_filename != NULL); + GPR_ASSERT(roots_file != NULL); + GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); + fclose(roots_file); + gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_filename); + + grpc_init(); + + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); /* Cleanup. */ - remove (roots_filename); - gpr_free (roots_filename); + remove(roots_filename); + gpr_free(roots_filename); return 0; } diff --git a/test/core/end2end/fixtures/h2_uds+poll.c b/test/core/end2end/fixtures/h2_uds+poll.c index b2981fe0bc..05b9ea0949 100644 --- a/test/core/end2end/fixtures/h2_uds+poll.c +++ b/test/core/end2end/fixtures/h2_uds+poll.c @@ -54,80 +54,71 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data -{ +typedef struct fullstack_fixture_data { char *localaddr; } fullstack_fixture_data; static int unique = 1; -static grpc_end2end_test_fixture -chttp2_create_fixture_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - fullstack_fixture_data *ffd = gpr_malloc (sizeof (fullstack_fixture_data)); - memset (&f, 0, sizeof (f)); + fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data)); + memset(&f, 0, sizeof(f)); - gpr_asprintf (&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid (), unique++); + gpr_asprintf(&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), + unique++); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -void -chttp2_init_client_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { fullstack_fixture_data *ffd = f->fixture_data; - f->client = grpc_insecure_channel_create (ffd->localaddr, client_args, NULL); + f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); } -void -chttp2_init_server_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { fullstack_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_insecure_http2_port (f->server, ffd->localaddr)); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + grpc_server_start(f->server); } -void -chttp2_tear_down_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { fullstack_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, - chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, - chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, + {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, + chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, + chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; grpc_platform_become_multipoller = grpc_poll_become_multipoller; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 6b664d3aec..59d39bbb0f 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -54,78 +54,69 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -typedef struct fullstack_fixture_data -{ +typedef struct fullstack_fixture_data { char *localaddr; } fullstack_fixture_data; static int unique = 1; -static grpc_end2end_test_fixture -chttp2_create_fixture_fullstack (grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture chttp2_create_fixture_fullstack( + grpc_channel_args *client_args, grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - fullstack_fixture_data *ffd = gpr_malloc (sizeof (fullstack_fixture_data)); - memset (&f, 0, sizeof (f)); + fullstack_fixture_data *ffd = gpr_malloc(sizeof(fullstack_fixture_data)); + memset(&f, 0, sizeof(f)); - gpr_asprintf (&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid (), unique++); + gpr_asprintf(&ffd->localaddr, "unix:/tmp/grpc_fullstack_test.%d.%d", getpid(), + unique++); f.fixture_data = ffd; - f.cq = grpc_completion_queue_create (NULL); + f.cq = grpc_completion_queue_create(NULL); return f; } -void -chttp2_init_client_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * client_args) -{ +void chttp2_init_client_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *client_args) { fullstack_fixture_data *ffd = f->fixture_data; - f->client = grpc_insecure_channel_create (ffd->localaddr, client_args, NULL); + f->client = grpc_insecure_channel_create(ffd->localaddr, client_args, NULL); } -void -chttp2_init_server_fullstack (grpc_end2end_test_fixture * f, grpc_channel_args * server_args) -{ +void chttp2_init_server_fullstack(grpc_end2end_test_fixture *f, + grpc_channel_args *server_args) { fullstack_fixture_data *ffd = f->fixture_data; - if (f->server) - { - grpc_server_destroy (f->server); - } - f->server = grpc_server_create (server_args, NULL); - grpc_server_register_completion_queue (f->server, f->cq, NULL); - GPR_ASSERT (grpc_server_add_insecure_http2_port (f->server, ffd->localaddr)); - grpc_server_start (f->server); + if (f->server) { + grpc_server_destroy(f->server); + } + f->server = grpc_server_create(server_args, NULL); + grpc_server_register_completion_queue(f->server, f->cq, NULL); + GPR_ASSERT(grpc_server_add_insecure_http2_port(f->server, ffd->localaddr)); + grpc_server_start(f->server); } -void -chttp2_tear_down_fullstack (grpc_end2end_test_fixture * f) -{ +void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { fullstack_fixture_data *ffd = f->fixture_data; - gpr_free (ffd->localaddr); - gpr_free (ffd); + gpr_free(ffd->localaddr); + gpr_free(ffd); } /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, - chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, - chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, + {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION, + chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, + chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { size_t i; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - for (i = 0; i < sizeof (configs) / sizeof (*configs); i++) - { - grpc_end2end_tests (configs[i]); - } + for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { + grpc_end2end_tests(configs[i]); + } - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/fixtures/proxy.c b/test/core/end2end/fixtures/proxy.c index 14a55fb852..434e75dd15 100644 --- a/test/core/end2end/fixtures/proxy.c +++ b/test/core/end2end/fixtures/proxy.c @@ -44,8 +44,7 @@ #include "test/core/util/port.h" -struct grpc_end2end_proxy -{ +struct grpc_end2end_proxy { gpr_thd_id thd; char *proxy_port; char *server_port; @@ -61,14 +60,12 @@ struct grpc_end2end_proxy grpc_metadata_array new_call_metadata; }; -typedef struct -{ - void (*func) (void *arg, int success); +typedef struct { + void (*func)(void *arg, int success); void *arg; } closure; -typedef struct -{ +typedef struct { gpr_refcount refs; grpc_end2end_proxy *proxy; @@ -89,383 +86,351 @@ typedef struct int c2p_server_cancelled; } proxy_call; -static void thread_main (void *arg); -static void request_call (grpc_end2end_proxy * proxy); +static void thread_main(void *arg); +static void request_call(grpc_end2end_proxy *proxy); -grpc_end2end_proxy * -grpc_end2end_proxy_create (const grpc_end2end_proxy_def * def) -{ - gpr_thd_options opt = gpr_thd_options_default (); - int proxy_port = grpc_pick_unused_port_or_die (); - int server_port = grpc_pick_unused_port_or_die (); +grpc_end2end_proxy *grpc_end2end_proxy_create( + const grpc_end2end_proxy_def *def) { + gpr_thd_options opt = gpr_thd_options_default(); + int proxy_port = grpc_pick_unused_port_or_die(); + int server_port = grpc_pick_unused_port_or_die(); - grpc_end2end_proxy *proxy = gpr_malloc (sizeof (*proxy)); - memset (proxy, 0, sizeof (*proxy)); + grpc_end2end_proxy *proxy = gpr_malloc(sizeof(*proxy)); + memset(proxy, 0, sizeof(*proxy)); - gpr_join_host_port (&proxy->proxy_port, "localhost", proxy_port); - gpr_join_host_port (&proxy->server_port, "localhost", server_port); + gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port); + gpr_join_host_port(&proxy->server_port, "localhost", server_port); - gpr_log (GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, proxy->server_port); + gpr_log(GPR_DEBUG, "PROXY ADDR:%s BACKEND:%s", proxy->proxy_port, + proxy->server_port); - proxy->cq = grpc_completion_queue_create (NULL); - proxy->server = def->create_server (proxy->proxy_port); - proxy->client = def->create_client (proxy->server_port); + proxy->cq = grpc_completion_queue_create(NULL); + proxy->server = def->create_server(proxy->proxy_port); + proxy->client = def->create_client(proxy->server_port); - grpc_server_register_completion_queue (proxy->server, proxy->cq, NULL); - grpc_server_start (proxy->server); + grpc_server_register_completion_queue(proxy->server, proxy->cq, NULL); + grpc_server_start(proxy->server); - gpr_thd_options_set_joinable (&opt); - GPR_ASSERT (gpr_thd_new (&proxy->thd, thread_main, proxy, &opt)); + gpr_thd_options_set_joinable(&opt); + GPR_ASSERT(gpr_thd_new(&proxy->thd, thread_main, proxy, &opt)); - request_call (proxy); + request_call(proxy); return proxy; } -static closure * -new_closure (void (*func) (void *arg, int success), void *arg) -{ - closure *cl = gpr_malloc (sizeof (*cl)); +static closure *new_closure(void (*func)(void *arg, int success), void *arg) { + closure *cl = gpr_malloc(sizeof(*cl)); cl->func = func; cl->arg = arg; return cl; } -static void -shutdown_complete (void *arg, int success) -{ +static void shutdown_complete(void *arg, int success) { grpc_end2end_proxy *proxy = arg; proxy->shutdown = 1; - grpc_completion_queue_shutdown (proxy->cq); + grpc_completion_queue_shutdown(proxy->cq); } -void -grpc_end2end_proxy_destroy (grpc_end2end_proxy * proxy) -{ - grpc_server_shutdown_and_notify (proxy->server, proxy->cq, new_closure (shutdown_complete, proxy)); - gpr_thd_join (proxy->thd); - gpr_free (proxy->proxy_port); - gpr_free (proxy->server_port); - grpc_server_destroy (proxy->server); - grpc_channel_destroy (proxy->client); - grpc_completion_queue_destroy (proxy->cq); - grpc_call_details_destroy (&proxy->new_call_details); - gpr_free (proxy); +void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy) { + grpc_server_shutdown_and_notify(proxy->server, proxy->cq, + new_closure(shutdown_complete, proxy)); + gpr_thd_join(proxy->thd); + gpr_free(proxy->proxy_port); + gpr_free(proxy->server_port); + grpc_server_destroy(proxy->server); + grpc_channel_destroy(proxy->client); + grpc_completion_queue_destroy(proxy->cq); + grpc_call_details_destroy(&proxy->new_call_details); + gpr_free(proxy); } -static void -unrefpc (proxy_call * pc, const char *reason) -{ - if (gpr_unref (&pc->refs)) - { - grpc_call_destroy (pc->c2p); - grpc_call_destroy (pc->p2s); - grpc_metadata_array_destroy (&pc->c2p_initial_metadata); - grpc_metadata_array_destroy (&pc->p2s_initial_metadata); - grpc_metadata_array_destroy (&pc->p2s_trailing_metadata); - gpr_free (pc->p2s_status_details); - gpr_free (pc); - } +static void unrefpc(proxy_call *pc, const char *reason) { + if (gpr_unref(&pc->refs)) { + grpc_call_destroy(pc->c2p); + grpc_call_destroy(pc->p2s); + grpc_metadata_array_destroy(&pc->c2p_initial_metadata); + grpc_metadata_array_destroy(&pc->p2s_initial_metadata); + grpc_metadata_array_destroy(&pc->p2s_trailing_metadata); + gpr_free(pc->p2s_status_details); + gpr_free(pc); + } } -static void -refpc (proxy_call * pc, const char *reason) -{ - gpr_ref (&pc->refs); -} +static void refpc(proxy_call *pc, const char *reason) { gpr_ref(&pc->refs); } -static void -on_c2p_sent_initial_metadata (void *arg, int success) -{ +static void on_c2p_sent_initial_metadata(void *arg, int success) { proxy_call *pc = arg; - unrefpc (pc, "on_c2p_sent_initial_metadata"); + unrefpc(pc, "on_c2p_sent_initial_metadata"); } -static void -on_p2s_recv_initial_metadata (void *arg, int success) -{ +static void on_p2s_recv_initial_metadata(void *arg, int success) { proxy_call *pc = arg; grpc_op op; grpc_call_error err; - if (!pc->proxy->shutdown) - { - op.op = GRPC_OP_SEND_INITIAL_METADATA; - op.flags = 0; - op.reserved = NULL; - op.data.send_initial_metadata.count = pc->p2s_initial_metadata.count; - op.data.send_initial_metadata.metadata = pc->p2s_initial_metadata.metadata; - refpc (pc, "on_c2p_sent_initial_metadata"); - err = grpc_call_start_batch (pc->c2p, &op, 1, new_closure (on_c2p_sent_initial_metadata, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - } - - unrefpc (pc, "on_p2s_recv_initial_metadata"); + if (!pc->proxy->shutdown) { + op.op = GRPC_OP_SEND_INITIAL_METADATA; + op.flags = 0; + op.reserved = NULL; + op.data.send_initial_metadata.count = pc->p2s_initial_metadata.count; + op.data.send_initial_metadata.metadata = pc->p2s_initial_metadata.metadata; + refpc(pc, "on_c2p_sent_initial_metadata"); + err = grpc_call_start_batch( + pc->c2p, &op, 1, new_closure(on_c2p_sent_initial_metadata, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + } + + unrefpc(pc, "on_p2s_recv_initial_metadata"); } -static void -on_p2s_sent_initial_metadata (void *arg, int success) -{ +static void on_p2s_sent_initial_metadata(void *arg, int success) { proxy_call *pc = arg; - unrefpc (pc, "on_p2s_sent_initial_metadata"); + unrefpc(pc, "on_p2s_sent_initial_metadata"); } -static void on_c2p_recv_msg (void *arg, int success); +static void on_c2p_recv_msg(void *arg, int success); -static void -on_p2s_sent_message (void *arg, int success) -{ +static void on_p2s_sent_message(void *arg, int success) { proxy_call *pc = arg; grpc_op op; grpc_call_error err; - grpc_byte_buffer_destroy (pc->c2p_msg); - if (!pc->proxy->shutdown && success) - { - op.op = GRPC_OP_RECV_MESSAGE; - op.flags = 0; - op.reserved = NULL; - op.data.recv_message = &pc->c2p_msg; - refpc (pc, "on_c2p_recv_msg"); - err = grpc_call_start_batch (pc->c2p, &op, 1, new_closure (on_c2p_recv_msg, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - } - - unrefpc (pc, "on_p2s_sent_message"); + grpc_byte_buffer_destroy(pc->c2p_msg); + if (!pc->proxy->shutdown && success) { + op.op = GRPC_OP_RECV_MESSAGE; + op.flags = 0; + op.reserved = NULL; + op.data.recv_message = &pc->c2p_msg; + refpc(pc, "on_c2p_recv_msg"); + err = grpc_call_start_batch(pc->c2p, &op, 1, + new_closure(on_c2p_recv_msg, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + } + + unrefpc(pc, "on_p2s_sent_message"); } -static void -on_p2s_sent_close (void *arg, int success) -{ +static void on_p2s_sent_close(void *arg, int success) { proxy_call *pc = arg; - unrefpc (pc, "on_p2s_sent_close"); + unrefpc(pc, "on_p2s_sent_close"); } -static void -on_c2p_recv_msg (void *arg, int success) -{ +static void on_c2p_recv_msg(void *arg, int success) { proxy_call *pc = arg; grpc_op op; grpc_call_error err; - if (!pc->proxy->shutdown && success) - { - if (pc->c2p_msg != NULL) - { - op.op = GRPC_OP_SEND_MESSAGE; - op.flags = 0; - op.reserved = NULL; - op.data.send_message = pc->c2p_msg; - refpc (pc, "on_p2s_sent_message"); - err = grpc_call_start_batch (pc->p2s, &op, 1, new_closure (on_p2s_sent_message, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - } - else - { - op.op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; - op.flags = 0; - op.reserved = NULL; - refpc (pc, "on_p2s_sent_close"); - err = grpc_call_start_batch (pc->p2s, &op, 1, new_closure (on_p2s_sent_close, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - } + if (!pc->proxy->shutdown && success) { + if (pc->c2p_msg != NULL) { + op.op = GRPC_OP_SEND_MESSAGE; + op.flags = 0; + op.reserved = NULL; + op.data.send_message = pc->c2p_msg; + refpc(pc, "on_p2s_sent_message"); + err = grpc_call_start_batch(pc->p2s, &op, 1, + new_closure(on_p2s_sent_message, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + } else { + op.op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; + op.flags = 0; + op.reserved = NULL; + refpc(pc, "on_p2s_sent_close"); + err = grpc_call_start_batch(pc->p2s, &op, 1, + new_closure(on_p2s_sent_close, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); } + } - unrefpc (pc, "on_c2p_recv_msg"); + unrefpc(pc, "on_c2p_recv_msg"); } -static void on_p2s_recv_msg (void *arg, int success); +static void on_p2s_recv_msg(void *arg, int success); -static void -on_c2p_sent_message (void *arg, int success) -{ +static void on_c2p_sent_message(void *arg, int success) { proxy_call *pc = arg; grpc_op op; grpc_call_error err; - grpc_byte_buffer_destroy (pc->p2s_msg); - if (!pc->proxy->shutdown && success) - { - op.op = GRPC_OP_RECV_MESSAGE; - op.flags = 0; - op.reserved = NULL; - op.data.recv_message = &pc->p2s_msg; - refpc (pc, "on_p2s_recv_msg"); - err = grpc_call_start_batch (pc->p2s, &op, 1, new_closure (on_p2s_recv_msg, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - } - - unrefpc (pc, "on_c2p_sent_message"); + grpc_byte_buffer_destroy(pc->p2s_msg); + if (!pc->proxy->shutdown && success) { + op.op = GRPC_OP_RECV_MESSAGE; + op.flags = 0; + op.reserved = NULL; + op.data.recv_message = &pc->p2s_msg; + refpc(pc, "on_p2s_recv_msg"); + err = grpc_call_start_batch(pc->p2s, &op, 1, + new_closure(on_p2s_recv_msg, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + } + + unrefpc(pc, "on_c2p_sent_message"); } -static void -on_p2s_recv_msg (void *arg, int success) -{ +static void on_p2s_recv_msg(void *arg, int success) { proxy_call *pc = arg; grpc_op op; grpc_call_error err; - if (!pc->proxy->shutdown && success && pc->p2s_msg) - { - op.op = GRPC_OP_SEND_MESSAGE; - op.flags = 0; - op.reserved = NULL; - op.data.send_message = pc->p2s_msg; - refpc (pc, "on_c2p_sent_message"); - err = grpc_call_start_batch (pc->c2p, &op, 1, new_closure (on_c2p_sent_message, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - } - unrefpc (pc, "on_p2s_recv_msg"); + if (!pc->proxy->shutdown && success && pc->p2s_msg) { + op.op = GRPC_OP_SEND_MESSAGE; + op.flags = 0; + op.reserved = NULL; + op.data.send_message = pc->p2s_msg; + refpc(pc, "on_c2p_sent_message"); + err = grpc_call_start_batch(pc->c2p, &op, 1, + new_closure(on_c2p_sent_message, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + } + unrefpc(pc, "on_p2s_recv_msg"); } -static void -on_c2p_sent_status (void *arg, int success) -{ +static void on_c2p_sent_status(void *arg, int success) { proxy_call *pc = arg; - unrefpc (pc, "on_c2p_sent_status"); + unrefpc(pc, "on_c2p_sent_status"); } -static void -on_p2s_status (void *arg, int success) -{ +static void on_p2s_status(void *arg, int success) { proxy_call *pc = arg; grpc_op op; grpc_call_error err; - if (!pc->proxy->shutdown) - { - GPR_ASSERT (success); - op.op = GRPC_OP_SEND_STATUS_FROM_SERVER; - op.flags = 0; - op.reserved = NULL; - op.data.send_status_from_server.trailing_metadata_count = pc->p2s_trailing_metadata.count; - op.data.send_status_from_server.trailing_metadata = pc->p2s_trailing_metadata.metadata; - op.data.send_status_from_server.status = pc->p2s_status; - op.data.send_status_from_server.status_details = pc->p2s_status_details; - refpc (pc, "on_c2p_sent_status"); - err = grpc_call_start_batch (pc->c2p, &op, 1, new_closure (on_c2p_sent_status, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - } - - unrefpc (pc, "on_p2s_status"); + if (!pc->proxy->shutdown) { + GPR_ASSERT(success); + op.op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op.flags = 0; + op.reserved = NULL; + op.data.send_status_from_server.trailing_metadata_count = + pc->p2s_trailing_metadata.count; + op.data.send_status_from_server.trailing_metadata = + pc->p2s_trailing_metadata.metadata; + op.data.send_status_from_server.status = pc->p2s_status; + op.data.send_status_from_server.status_details = pc->p2s_status_details; + refpc(pc, "on_c2p_sent_status"); + err = grpc_call_start_batch(pc->c2p, &op, 1, + new_closure(on_c2p_sent_status, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + } + + unrefpc(pc, "on_p2s_status"); } -static void -on_c2p_closed (void *arg, int success) -{ +static void on_c2p_closed(void *arg, int success) { proxy_call *pc = arg; - unrefpc (pc, "on_c2p_closed"); + unrefpc(pc, "on_c2p_closed"); } -static void -on_new_call (void *arg, int success) -{ +static void on_new_call(void *arg, int success) { grpc_end2end_proxy *proxy = arg; grpc_call_error err; - if (success) - { - grpc_op op; - proxy_call *pc = gpr_malloc (sizeof (*pc)); - memset (pc, 0, sizeof (*pc)); - pc->proxy = proxy; - GPR_SWAP (grpc_metadata_array, pc->c2p_initial_metadata, proxy->new_call_metadata); - pc->c2p = proxy->new_call; - pc->p2s = grpc_channel_create_call (proxy->client, pc->c2p, GRPC_PROPAGATE_DEFAULTS, proxy->cq, proxy->new_call_details.method, proxy->new_call_details.host, proxy->new_call_details.deadline, NULL); - gpr_ref_init (&pc->refs, 1); - - op.flags = 0; - op.reserved = NULL; - - op.op = GRPC_OP_RECV_INITIAL_METADATA; - op.data.recv_initial_metadata = &pc->p2s_initial_metadata; - refpc (pc, "on_p2s_recv_initial_metadata"); - err = grpc_call_start_batch (pc->p2s, &op, 1, new_closure (on_p2s_recv_initial_metadata, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - - op.op = GRPC_OP_SEND_INITIAL_METADATA; - op.data.send_initial_metadata.count = pc->c2p_initial_metadata.count; - op.data.send_initial_metadata.metadata = pc->c2p_initial_metadata.metadata; - refpc (pc, "on_p2s_sent_initial_metadata"); - err = grpc_call_start_batch (pc->p2s, &op, 1, new_closure (on_p2s_sent_initial_metadata, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - - op.op = GRPC_OP_RECV_MESSAGE; - op.data.recv_message = &pc->c2p_msg; - refpc (pc, "on_c2p_recv_msg"); - err = grpc_call_start_batch (pc->c2p, &op, 1, new_closure (on_c2p_recv_msg, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - - op.op = GRPC_OP_RECV_MESSAGE; - op.data.recv_message = &pc->p2s_msg; - refpc (pc, "on_p2s_recv_msg"); - err = grpc_call_start_batch (pc->p2s, &op, 1, new_closure (on_p2s_recv_msg, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - - op.op = GRPC_OP_RECV_STATUS_ON_CLIENT; - op.data.recv_status_on_client.trailing_metadata = &pc->p2s_trailing_metadata; - op.data.recv_status_on_client.status = &pc->p2s_status; - op.data.recv_status_on_client.status_details = &pc->p2s_status_details; - op.data.recv_status_on_client.status_details_capacity = &pc->p2s_status_details_capacity; - refpc (pc, "on_p2s_status"); - err = grpc_call_start_batch (pc->p2s, &op, 1, new_closure (on_p2s_status, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - - op.op = GRPC_OP_RECV_CLOSE_ON_SERVER; - op.data.recv_close_on_server.cancelled = &pc->c2p_server_cancelled; - refpc (pc, "on_c2p_closed"); - err = grpc_call_start_batch (pc->c2p, &op, 1, new_closure (on_c2p_closed, pc), NULL); - GPR_ASSERT (err == GRPC_CALL_OK); - - request_call (proxy); - - unrefpc (pc, "init"); - } - else - { - GPR_ASSERT (proxy->new_call == NULL); - } + if (success) { + grpc_op op; + proxy_call *pc = gpr_malloc(sizeof(*pc)); + memset(pc, 0, sizeof(*pc)); + pc->proxy = proxy; + GPR_SWAP(grpc_metadata_array, pc->c2p_initial_metadata, + proxy->new_call_metadata); + pc->c2p = proxy->new_call; + pc->p2s = grpc_channel_create_call( + proxy->client, pc->c2p, GRPC_PROPAGATE_DEFAULTS, proxy->cq, + proxy->new_call_details.method, proxy->new_call_details.host, + proxy->new_call_details.deadline, NULL); + gpr_ref_init(&pc->refs, 1); + + op.flags = 0; + op.reserved = NULL; + + op.op = GRPC_OP_RECV_INITIAL_METADATA; + op.data.recv_initial_metadata = &pc->p2s_initial_metadata; + refpc(pc, "on_p2s_recv_initial_metadata"); + err = grpc_call_start_batch( + pc->p2s, &op, 1, new_closure(on_p2s_recv_initial_metadata, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + + op.op = GRPC_OP_SEND_INITIAL_METADATA; + op.data.send_initial_metadata.count = pc->c2p_initial_metadata.count; + op.data.send_initial_metadata.metadata = pc->c2p_initial_metadata.metadata; + refpc(pc, "on_p2s_sent_initial_metadata"); + err = grpc_call_start_batch( + pc->p2s, &op, 1, new_closure(on_p2s_sent_initial_metadata, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + + op.op = GRPC_OP_RECV_MESSAGE; + op.data.recv_message = &pc->c2p_msg; + refpc(pc, "on_c2p_recv_msg"); + err = grpc_call_start_batch(pc->c2p, &op, 1, + new_closure(on_c2p_recv_msg, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + + op.op = GRPC_OP_RECV_MESSAGE; + op.data.recv_message = &pc->p2s_msg; + refpc(pc, "on_p2s_recv_msg"); + err = grpc_call_start_batch(pc->p2s, &op, 1, + new_closure(on_p2s_recv_msg, pc), NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + + op.op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op.data.recv_status_on_client.trailing_metadata = + &pc->p2s_trailing_metadata; + op.data.recv_status_on_client.status = &pc->p2s_status; + op.data.recv_status_on_client.status_details = &pc->p2s_status_details; + op.data.recv_status_on_client.status_details_capacity = + &pc->p2s_status_details_capacity; + refpc(pc, "on_p2s_status"); + err = grpc_call_start_batch(pc->p2s, &op, 1, new_closure(on_p2s_status, pc), + NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + + op.op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op.data.recv_close_on_server.cancelled = &pc->c2p_server_cancelled; + refpc(pc, "on_c2p_closed"); + err = grpc_call_start_batch(pc->c2p, &op, 1, new_closure(on_c2p_closed, pc), + NULL); + GPR_ASSERT(err == GRPC_CALL_OK); + + request_call(proxy); + + unrefpc(pc, "init"); + } else { + GPR_ASSERT(proxy->new_call == NULL); + } } -static void -request_call (grpc_end2end_proxy * proxy) -{ +static void request_call(grpc_end2end_proxy *proxy) { proxy->new_call = NULL; - GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (proxy->server, &proxy->new_call, &proxy->new_call_details, &proxy->new_call_metadata, proxy->cq, proxy->cq, new_closure (on_new_call, proxy))); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + proxy->server, &proxy->new_call, + &proxy->new_call_details, + &proxy->new_call_metadata, proxy->cq, + proxy->cq, new_closure(on_new_call, proxy))); } -static void -thread_main (void *arg) -{ +static void thread_main(void *arg) { grpc_end2end_proxy *proxy = arg; closure *cl; - for (;;) - { - grpc_event ev = grpc_completion_queue_next (proxy->cq, gpr_inf_future (GPR_CLOCK_MONOTONIC), NULL); - switch (ev.type) - { - case GRPC_QUEUE_TIMEOUT: - gpr_log (GPR_ERROR, "Should never reach here"); - abort (); - case GRPC_QUEUE_SHUTDOWN: - return; - case GRPC_OP_COMPLETE: - cl = ev.tag; - cl->func (cl->arg, ev.success); - gpr_free (cl); - break; - } + for (;;) { + grpc_event ev = grpc_completion_queue_next( + proxy->cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL); + switch (ev.type) { + case GRPC_QUEUE_TIMEOUT: + gpr_log(GPR_ERROR, "Should never reach here"); + abort(); + case GRPC_QUEUE_SHUTDOWN: + return; + case GRPC_OP_COMPLETE: + cl = ev.tag; + cl->func(cl->arg, ev.success); + gpr_free(cl); + break; } + } } -const char * -grpc_end2end_proxy_get_client_target (grpc_end2end_proxy * proxy) -{ +const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy) { return proxy->proxy_port; } -const char * -grpc_end2end_proxy_get_server_port (grpc_end2end_proxy * proxy) -{ +const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy) { return proxy->server_port; } diff --git a/test/core/end2end/fixtures/proxy.h b/test/core/end2end/fixtures/proxy.h index 616fa1e10e..c1cf01d39a 100644 --- a/test/core/end2end/fixtures/proxy.h +++ b/test/core/end2end/fixtures/proxy.h @@ -40,16 +40,16 @@ typedef struct grpc_end2end_proxy grpc_end2end_proxy; -typedef struct grpc_end2end_proxy_def -{ - grpc_server *(*create_server) (const char *port); - grpc_channel *(*create_client) (const char *target); +typedef struct grpc_end2end_proxy_def { + grpc_server *(*create_server)(const char *port); + grpc_channel *(*create_client)(const char *target); } grpc_end2end_proxy_def; -grpc_end2end_proxy *grpc_end2end_proxy_create (const grpc_end2end_proxy_def * def); -void grpc_end2end_proxy_destroy (grpc_end2end_proxy * proxy); +grpc_end2end_proxy *grpc_end2end_proxy_create( + const grpc_end2end_proxy_def *def); +void grpc_end2end_proxy_destroy(grpc_end2end_proxy *proxy); -const char *grpc_end2end_proxy_get_client_target (grpc_end2end_proxy * proxy); -const char *grpc_end2end_proxy_get_server_port (grpc_end2end_proxy * proxy); +const char *grpc_end2end_proxy_get_client_target(grpc_end2end_proxy *proxy); +const char *grpc_end2end_proxy_get_server_port(grpc_end2end_proxy *proxy); #endif /* GRPC_TEST_CORE_END2END_FIXTURES_PROXY_H */ diff --git a/test/core/end2end/multiple_server_queues_test.c b/test/core/end2end/multiple_server_queues_test.c index 4d68a2d40d..5e2eaf4ae9 100644 --- a/test/core/end2end/multiple_server_queues_test.c +++ b/test/core/end2end/multiple_server_queues_test.c @@ -34,31 +34,30 @@ #include <grpc/grpc.h> #include "test/core/util/test_config.h" -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { grpc_completion_queue *cq1; grpc_completion_queue *cq2; grpc_server *server; - grpc_test_init (argc, argv); - grpc_init (); - cq1 = grpc_completion_queue_create (NULL); - cq2 = grpc_completion_queue_create (NULL); - server = grpc_server_create (NULL, NULL); - grpc_server_register_completion_queue (server, cq1, NULL); - grpc_server_add_insecure_http2_port (server, "[::]:0"); - grpc_server_register_completion_queue (server, cq2, NULL); - grpc_server_start (server); - grpc_server_shutdown_and_notify (server, cq2, NULL); - grpc_completion_queue_next (cq2, gpr_inf_future (GPR_CLOCK_REALTIME), NULL); /* cue queue hang */ - grpc_completion_queue_shutdown (cq1); - grpc_completion_queue_shutdown (cq2); - grpc_completion_queue_next (cq1, gpr_inf_future (GPR_CLOCK_REALTIME), NULL); - grpc_completion_queue_next (cq2, gpr_inf_future (GPR_CLOCK_REALTIME), NULL); - grpc_server_destroy (server); - grpc_completion_queue_destroy (cq1); - grpc_completion_queue_destroy (cq2); - grpc_shutdown (); + grpc_test_init(argc, argv); + grpc_init(); + cq1 = grpc_completion_queue_create(NULL); + cq2 = grpc_completion_queue_create(NULL); + server = grpc_server_create(NULL, NULL); + grpc_server_register_completion_queue(server, cq1, NULL); + grpc_server_add_insecure_http2_port(server, "[::]:0"); + grpc_server_register_completion_queue(server, cq2, NULL); + grpc_server_start(server); + grpc_server_shutdown_and_notify(server, cq2, NULL); + grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), + NULL); /* cue queue hang */ + grpc_completion_queue_shutdown(cq1); + grpc_completion_queue_shutdown(cq2); + grpc_completion_queue_next(cq1, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_completion_queue_next(cq2, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_server_destroy(server); + grpc_completion_queue_destroy(cq1); + grpc_completion_queue_destroy(cq2); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 45642dca2b..c391003141 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -37,18 +37,12 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/util/test_config.h" -static void * -tag (gpr_intptr i) -{ - return (void *) i; -} +static void *tag(gpr_intptr i) { return (void *)i; } -int -main (int argc, char **argv) -{ +int main(int argc, char **argv) { grpc_channel *chan; grpc_call *call; - gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE (2); + gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(2); grpc_completion_queue *cq; cq_verifier *cqv; grpc_op ops[6]; @@ -58,17 +52,18 @@ main (int argc, char **argv) char *details = NULL; size_t details_capacity = 0; - grpc_test_init (argc, argv); - grpc_init (); + grpc_test_init(argc, argv); + grpc_init(); - grpc_metadata_array_init (&trailing_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); - cq = grpc_completion_queue_create (NULL); - cqv = cq_verifier_create (cq); + cq = grpc_completion_queue_create(NULL); + cqv = cq_verifier_create(cq); /* create a call, channel to a non existant server */ - chan = grpc_insecure_channel_create ("nonexistant:54321", NULL, NULL); - call = grpc_channel_create_call (chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, "/Foo", "nonexistant", deadline, NULL); + chan = grpc_insecure_channel_create("nonexistant:54321", NULL, NULL); + call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq, + "/Foo", "nonexistant", deadline, NULL); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -84,25 +79,28 @@ main (int argc, char **argv) op->flags = 0; op->reserved = NULL; op++; - GPR_ASSERT (GRPC_CALL_OK == grpc_call_start_batch (call, ops, (size_t) (op - ops), tag (1), NULL)); + GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch( + call, ops, (size_t)(op - ops), tag(1), NULL)); /* verify that all tags get completed */ - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_DEADLINE_EXCEEDED); + GPR_ASSERT(status == GRPC_STATUS_DEADLINE_EXCEEDED); - grpc_completion_queue_shutdown (cq); - while (grpc_completion_queue_next (cq, gpr_inf_future (GPR_CLOCK_REALTIME), NULL).type != GRPC_QUEUE_SHUTDOWN) + grpc_completion_queue_shutdown(cq); + while ( + grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL) + .type != GRPC_QUEUE_SHUTDOWN) ; - grpc_completion_queue_destroy (cq); - grpc_call_destroy (call); - grpc_channel_destroy (chan); - cq_verifier_destroy (cqv); + grpc_completion_queue_destroy(cq); + grpc_call_destroy(call); + grpc_channel_destroy(chan); + cq_verifier_destroy(cqv); - gpr_free (details); - grpc_metadata_array_destroy (&trailing_metadata_recv); + gpr_free(details); + grpc_metadata_array_destroy(&trailing_metadata_recv); - grpc_shutdown (); + grpc_shutdown(); return 0; } diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index 901b4b2210..93e2df1e43 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -45,86 +45,64 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_request_body (grpc_end2end_test_fixture f) -{ +static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call *c; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -136,13 +114,14 @@ simple_request_body (grpc_end2end_test_fixture f) char *details = NULL; size_t details_capacity = 0; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "slartibartfast.local", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "slartibartfast.local", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -167,41 +146,36 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_INVALID_ARGUMENT); + GPR_ASSERT(status == GRPC_STATUS_INVALID_ARGUMENT); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_simple_request (grpc_end2end_test_config config) -{ +static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - f = begin_test (config, "test_invoke_simple_request", NULL, NULL); - simple_request_body (f); - end_test (&f); - config.tear_down_data (&f); + f = begin_test(config, "test_invoke_simple_request", NULL, NULL); + simple_request_body(f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - if (config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) - { - test_invoke_simple_request (config); - } +void grpc_end2end_tests(grpc_end2end_test_config config) { + if (config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) { + test_invoke_simple_request(config); + } } diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 2b32077847..21e0bbcc49 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -43,117 +43,97 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Request/response with metadata and payload.*/ -static void -test_request_response_with_metadata_and_payload (grpc_end2end_test_config config) -{ +static void test_request_response_with_metadata_and_payload( + grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); - gpr_timespec deadline = five_seconds_time (); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + gpr_timespec deadline = five_seconds_time(); grpc_metadata meta_c[2] = { - {"key1-bin", - "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", - 13, - 0, - {{NULL, NULL, NULL, NULL}}}, - {"key2-bin", - "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", - 14, - 0, - {{NULL, NULL, NULL, NULL}}} - }; + {"key1-bin", + "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc", + 13, + 0, + {{NULL, NULL, NULL, NULL}}}, + {"key2-bin", + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d", + 14, + 0, + {{NULL, NULL, NULL, NULL}}}}; grpc_metadata meta_s[2] = { - {"key3-bin", - "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", - 15, - 0, - {{NULL, NULL, NULL, NULL}}}, - {"key4-bin", - "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", - 16, - 0, - {{NULL, NULL, NULL, NULL}}} - }; - grpc_end2end_test_fixture f = begin_test (config, "test_request_response_with_metadata_and_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + {"key3-bin", + "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee", + 15, + 0, + {{NULL, NULL, NULL, NULL}}}, + {"key4-bin", + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", + 16, + 0, + {{NULL, NULL, NULL, NULL}}}}; + grpc_end2end_test_fixture f = begin_test( + config, "test_request_response_with_metadata_and_payload", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -168,13 +148,14 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -210,13 +191,15 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -230,11 +213,11 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -254,47 +237,53 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 0); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world")); - GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you")); - GPR_ASSERT (contains_metadata (&request_metadata_recv, "key1-bin", "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc")); - GPR_ASSERT (contains_metadata (&request_metadata_recv, "key2-bin", "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d")); - GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key3-bin", "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee")); - GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key4-bin", "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")); + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 0); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); + GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); + GPR_ASSERT(contains_metadata( + &request_metadata_recv, "key1-bin", + "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc")); + GPR_ASSERT(contains_metadata( + &request_metadata_recv, "key2-bin", + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d")); + GPR_ASSERT(contains_metadata( + &initial_metadata_recv, "key3-bin", + "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee")); + GPR_ASSERT(contains_metadata( + &initial_metadata_recv, "key4-bin", + "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_request_response_with_metadata_and_payload (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index a8ec505ffb..4e905aafc7 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -51,147 +51,120 @@ static const char iam_selector[] = "selector"; static const char overridden_iam_token[] = "overridden_token"; static const char overridden_iam_selector[] = "overridden_selector"; -typedef enum -{ NONE, OVERRIDE, DESTROY } override_mode; +typedef enum { NONE, OVERRIDE, DESTROY } override_mode; -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, int fail_server_auth_check) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + int fail_server_auth_check) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (NULL, NULL); - config.init_client (&f, NULL); - if (fail_server_auth_check) - { - grpc_arg fail_auth_arg = { - GRPC_ARG_STRING, FAIL_AUTH_CHECK_SERVER_ARG_NAME, {NULL} - }; - grpc_channel_args args; - args.num_args = 1; - args.args = &fail_auth_arg; - config.init_server (&f, &args); - } - else - { - config.init_server (&f, NULL); - } + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(NULL, NULL); + config.init_client(&f, NULL); + if (fail_server_auth_check) { + grpc_arg fail_auth_arg = { + GRPC_ARG_STRING, FAIL_AUTH_CHECK_SERVER_ARG_NAME, {NULL}}; + grpc_channel_args args; + args.num_args = 1; + args.args = &fail_auth_arg; + config.init_server(&f, &args); + } else { + config.init_server(&f, NULL); + } return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -print_auth_context (int is_client, const grpc_auth_context * ctx) -{ +static void print_auth_context(int is_client, const grpc_auth_context *ctx) { const grpc_auth_property *p; grpc_auth_property_iterator it; - gpr_log (GPR_INFO, "%s peer:", is_client ? "client" : "server"); - gpr_log (GPR_INFO, "\tauthenticated: %s", grpc_auth_context_peer_is_authenticated (ctx) ? "YES" : "NO"); - it = grpc_auth_context_peer_identity (ctx); - while ((p = grpc_auth_property_iterator_next (&it)) != NULL) - { - gpr_log (GPR_INFO, "\t\t%s: %s", p->name, p->value); - } - gpr_log (GPR_INFO, "\tall properties:"); - it = grpc_auth_context_property_iterator (ctx); - while ((p = grpc_auth_property_iterator_next (&it)) != NULL) - { - gpr_log (GPR_INFO, "\t\t%s: %s", p->name, p->value); - } + gpr_log(GPR_INFO, "%s peer:", is_client ? "client" : "server"); + gpr_log(GPR_INFO, "\tauthenticated: %s", + grpc_auth_context_peer_is_authenticated(ctx) ? "YES" : "NO"); + it = grpc_auth_context_peer_identity(ctx); + while ((p = grpc_auth_property_iterator_next(&it)) != NULL) { + gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value); + } + gpr_log(GPR_INFO, "\tall properties:"); + it = grpc_auth_context_property_iterator(ctx); + while ((p = grpc_auth_property_iterator_next(&it)) != NULL) { + gpr_log(GPR_INFO, "\t\t%s: %s", p->name, p->value); + } } -static void -test_call_creds_failure (grpc_end2end_test_config config) -{ +static void test_call_creds_failure(grpc_end2end_test_config config) { grpc_call *c; grpc_credentials *creds = NULL; - grpc_end2end_test_fixture f = begin_test (config, "test_call_creds_failure", 0); - gpr_timespec deadline = five_seconds_time (); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + grpc_end2end_test_fixture f = + begin_test(config, "test_call_creds_failure", 0); + gpr_timespec deadline = five_seconds_time(); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); /* Try with credentials unfit to be set on a call (channel creds). */ - creds = grpc_fake_transport_security_credentials_create (); - GPR_ASSERT (grpc_call_set_credentials (c, creds) != GRPC_CALL_OK); - grpc_credentials_release (creds); + creds = grpc_fake_transport_security_credentials_create(); + GPR_ASSERT(grpc_call_set_credentials(c, creds) != GRPC_CALL_OK); + grpc_credentials_release(creds); - grpc_call_destroy (c); + grpc_call_destroy(c); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -static void -request_response_with_payload_and_call_creds (const char *test_name, grpc_end2end_test_config config, override_mode mode) -{ +static void request_response_with_payload_and_call_creds( + const char *test_name, grpc_end2end_test_config config, + override_mode mode) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); - gpr_timespec deadline = five_seconds_time (); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + gpr_timespec deadline = five_seconds_time(); grpc_end2end_test_fixture f; cq_verifier *cqv; grpc_op ops[6]; @@ -211,34 +184,35 @@ request_response_with_payload_and_call_creds (const char *test_name, grpc_end2en grpc_auth_context *s_auth_context = NULL; grpc_auth_context *c_auth_context = NULL; - f = begin_test (config, test_name, 0); - cqv = cq_verifier_create (f.cq); + f = begin_test(config, test_name, 0); + cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); - creds = grpc_google_iam_credentials_create (iam_token, iam_selector, NULL); - GPR_ASSERT (creds != NULL); - GPR_ASSERT (grpc_call_set_credentials (c, creds) == GRPC_CALL_OK); - switch (mode) - { + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); + creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); + GPR_ASSERT(creds != NULL); + GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK); + switch (mode) { case NONE: break; case OVERRIDE: - grpc_credentials_release (creds); - creds = grpc_google_iam_credentials_create (overridden_iam_token, overridden_iam_selector, NULL); - GPR_ASSERT (creds != NULL); - GPR_ASSERT (grpc_call_set_credentials (c, creds) == GRPC_CALL_OK); + grpc_credentials_release(creds); + creds = grpc_google_iam_credentials_create(overridden_iam_token, + overridden_iam_selector, NULL); + GPR_ASSERT(creds != NULL); + GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK); break; case DESTROY: - GPR_ASSERT (grpc_call_set_credentials (c, NULL) == GRPC_CALL_OK); + GPR_ASSERT(grpc_call_set_credentials(c, NULL) == GRPC_CALL_OK); break; - } - grpc_credentials_release (creds); + } + grpc_credentials_release(creds); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -273,25 +247,27 @@ request_response_with_payload_and_call_creds (const char *test_name, grpc_end2en op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); - s_auth_context = grpc_call_auth_context (s); - GPR_ASSERT (s_auth_context != NULL); - print_auth_context (0, s_auth_context); - grpc_auth_context_release (s_auth_context); - - c_auth_context = grpc_call_auth_context (c); - GPR_ASSERT (c_auth_context != NULL); - print_auth_context (1, c_auth_context); - grpc_auth_context_release (c_auth_context); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); + s_auth_context = grpc_call_auth_context(s); + GPR_ASSERT(s_auth_context != NULL); + print_auth_context(0, s_auth_context); + grpc_auth_context_release(s_auth_context); + + c_auth_context = grpc_call_auth_context(c); + GPR_ASSERT(c_auth_context != NULL); + print_auth_context(1, c_auth_context); + grpc_auth_context_release(c_auth_context); /* Cannot set creds on the server call object. */ - GPR_ASSERT (grpc_call_set_credentials (s, NULL) != GRPC_CALL_OK); + GPR_ASSERT(grpc_call_set_credentials(s, NULL) != GRPC_CALL_OK); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -304,11 +280,11 @@ request_response_with_payload_and_call_creds (const char *test_name, grpc_end2en op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -328,85 +304,101 @@ request_response_with_payload_and_call_creds (const char *test_name, grpc_end2en op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); - - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 0); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world")); - GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you")); - - switch (mode) - { + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); + + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 0); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); + GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); + + switch (mode) { case NONE: - GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, iam_token)); - GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, iam_selector)); + GPR_ASSERT(contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + iam_token)); + GPR_ASSERT(contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + iam_selector)); break; case OVERRIDE: - GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, overridden_iam_token)); - GPR_ASSERT (contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, overridden_iam_selector)); + GPR_ASSERT(contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + overridden_iam_token)); + GPR_ASSERT(contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + overridden_iam_selector)); break; case DESTROY: - GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, iam_token)); - GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, iam_selector)); - GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, overridden_iam_token)); - GPR_ASSERT (!contains_metadata (&request_metadata_recv, GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, overridden_iam_selector)); + GPR_ASSERT(!contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + iam_token)); + GPR_ASSERT(!contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + iam_selector)); + GPR_ASSERT(!contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY, + overridden_iam_token)); + GPR_ASSERT(!contains_metadata(&request_metadata_recv, + GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY, + overridden_iam_selector)); break; - } + } - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -static void -test_request_response_with_payload_and_call_creds (grpc_end2end_test_config config) -{ - request_response_with_payload_and_call_creds ("test_request_response_with_payload_and_call_creds", config, NONE); +static void test_request_response_with_payload_and_call_creds( + grpc_end2end_test_config config) { + request_response_with_payload_and_call_creds( + "test_request_response_with_payload_and_call_creds", config, NONE); } -static void -test_request_response_with_payload_and_overridden_call_creds (grpc_end2end_test_config config) -{ - request_response_with_payload_and_call_creds ("test_request_response_with_payload_and_overridden_call_creds", config, OVERRIDE); +static void test_request_response_with_payload_and_overridden_call_creds( + grpc_end2end_test_config config) { + request_response_with_payload_and_call_creds( + "test_request_response_with_payload_and_overridden_call_creds", config, + OVERRIDE); } -static void -test_request_response_with_payload_and_deleted_call_creds (grpc_end2end_test_config config) -{ - request_response_with_payload_and_call_creds ("test_request_response_with_payload_and_deleted_call_creds", config, DESTROY); +static void test_request_response_with_payload_and_deleted_call_creds( + grpc_end2end_test_config config) { + request_response_with_payload_and_call_creds( + "test_request_response_with_payload_and_deleted_call_creds", config, + DESTROY); } -static void -test_request_with_server_rejecting_client_creds (grpc_end2end_test_config config) -{ +static void test_request_with_server_rejecting_client_creds( + grpc_end2end_test_config config) { grpc_op ops[6]; grpc_op *op; grpc_call *c; grpc_end2end_test_fixture f; - gpr_timespec deadline = five_seconds_time (); + gpr_timespec deadline = five_seconds_time(); cq_verifier *cqv; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; @@ -417,25 +409,27 @@ test_request_with_server_rejecting_client_creds (grpc_end2end_test_config config char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_credentials *creds; - f = begin_test (config, "test_request_with_server_rejecting_client_creds", 1); - cqv = cq_verifier_create (f.cq); + f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1); + cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - creds = grpc_google_iam_credentials_create (iam_token, iam_selector, NULL); - GPR_ASSERT (creds != NULL); - GPR_ASSERT (grpc_call_set_credentials (c, creds) == GRPC_CALL_OK); - grpc_credentials_release (creds); + creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); + GPR_ASSERT(creds != NULL); + GPR_ASSERT(grpc_call_set_credentials(c, creds) == GRPC_CALL_OK); + grpc_credentials_release(creds); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -470,39 +464,36 @@ test_request_with_server_rejecting_client_creds (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (error == GRPC_CALL_OK); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(error == GRPC_CALL_OK); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNAUTHENTICATED); + GPR_ASSERT(status == GRPC_STATUS_UNAUTHENTICATED); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload_recv); - gpr_free (details); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload_recv); + gpr_free(details); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (cqv); - end_test (&f); - config.tear_down_data (&f); + cq_verifier_destroy(cqv); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) - { - test_call_creds_failure (config); - test_request_response_with_payload_and_call_creds (config); - test_request_response_with_payload_and_overridden_call_creds (config); - test_request_response_with_payload_and_deleted_call_creds (config); - test_request_with_server_rejecting_client_creds (config); - } +void grpc_end2end_tests(grpc_end2end_test_config config) { + if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) { + test_call_creds_failure(config); + test_request_response_with_payload_and_call_creds(config); + test_request_response_with_payload_and_overridden_call_creds(config); + test_request_response_with_payload_and_deleted_call_creds(config); + test_request_with_server_rejecting_client_creds(config); + } } diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index bbef223229..10e62275ab 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -44,91 +44,71 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Cancel after accept, no payload */ -static void -test_cancel_after_accept (grpc_end2end_test_config config, cancellation_mode mode) -{ +static void test_cancel_after_accept(grpc_end2end_test_config config, + cancellation_mode mode) { grpc_op ops[6]; grpc_op *op; grpc_call *c; grpc_call *s; - grpc_end2end_test_fixture f = begin_test (config, "cancel_after_accept", NULL, NULL); - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + grpc_end2end_test_fixture f = + begin_test(config, "cancel_after_accept", NULL, NULL); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -139,19 +119,22 @@ test_cancel_after_accept (grpc_end2end_test_config config, cancellation_mode mod size_t details_capacity = 0; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -182,13 +165,14 @@ test_cancel_after_accept (grpc_end2end_test_config config, cancellation_mode mod op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (2)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (2), 1); - cq_verify (cqv); + error = grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(2)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(2), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_MESSAGE; @@ -211,44 +195,41 @@ test_cancel_after_accept (grpc_end2end_test_config config, cancellation_mode mod op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (3), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL)); + GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); - cq_expect_completion (cqv, tag (3), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(3), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == mode.expect_status || status == GRPC_STATUS_INTERNAL); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL); + GPR_ASSERT(was_cancelled == 1); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); - gpr_free (details); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + gpr_free(details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); - end_test (&f); - config.tear_down_data (&f); + cq_verifier_destroy(cqv); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { unsigned i; - for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++) - { - test_cancel_after_accept (config, cancellation_modes[i]); - } + for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { + test_cancel_after_accept(config, cancellation_modes[i]); + } } diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index b02d40c250..4fed5be5f7 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -44,91 +44,71 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Cancel after accept with a writes closed, no payload */ -static void -test_cancel_after_accept_and_writes_closed (grpc_end2end_test_config config, cancellation_mode mode) -{ +static void test_cancel_after_accept_and_writes_closed( + grpc_end2end_test_config config, cancellation_mode mode) { grpc_op ops[6]; grpc_op *op; grpc_call *c; grpc_call *s; - grpc_end2end_test_fixture f = begin_test (config, "test_cancel_after_accept_and_writes_closed", NULL, NULL); - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + grpc_end2end_test_fixture f = begin_test( + config, "test_cancel_after_accept_and_writes_closed", NULL, NULL); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -139,19 +119,22 @@ test_cancel_after_accept_and_writes_closed (grpc_end2end_test_config config, can size_t details_capacity = 0; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -186,13 +169,14 @@ test_cancel_after_accept_and_writes_closed (grpc_end2end_test_config config, can op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (2)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (2), 1); - cq_verify (cqv); + error = grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(2)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(2), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_MESSAGE; @@ -215,44 +199,41 @@ test_cancel_after_accept_and_writes_closed (grpc_end2end_test_config config, can op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (3), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(3), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL)); + GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); - cq_expect_completion (cqv, tag (3), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(3), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == mode.expect_status || status == GRPC_STATUS_INTERNAL); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL); + GPR_ASSERT(was_cancelled == 1); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); - gpr_free (details); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + gpr_free(details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); - end_test (&f); - config.tear_down_data (&f); + cq_verifier_destroy(cqv); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { unsigned i; - for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++) - { - test_cancel_after_accept_and_writes_closed (config, cancellation_modes[i]); - } + for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { + test_cancel_after_accept_and_writes_closed(config, cancellation_modes[i]); + } } diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 4f83a3ea7c..40595e4c7b 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -44,90 +44,71 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, cancellation_mode mode, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + cancellation_mode mode, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s/%s", test_name, config.name, mode.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s/%s", test_name, config.name, mode.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Cancel after invoke, no payload */ -static void -test_cancel_after_invoke (grpc_end2end_test_config config, cancellation_mode mode, size_t test_ops) -{ +static void test_cancel_after_invoke(grpc_end2end_test_config config, + cancellation_mode mode, size_t test_ops) { grpc_op ops[6]; grpc_op *op; grpc_call *c; - grpc_end2end_test_fixture f = begin_test (config, "test_cancel_after_invoke", mode, NULL, NULL); - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + grpc_end2end_test_fixture f = + begin_test(config, "test_cancel_after_invoke", mode, NULL, NULL); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -137,16 +118,18 @@ test_cancel_after_invoke (grpc_end2end_test_config config, cancellation_mode mod char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -181,42 +164,38 @@ test_cancel_after_invoke (grpc_end2end_test_config config, cancellation_mode mod op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, test_ops, tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, test_ops, tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL)); + GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == mode.expect_status || status == GRPC_STATUS_INTERNAL); + GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload_recv); - gpr_free (details); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload_recv); + gpr_free(details); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (cqv); - end_test (&f); - config.tear_down_data (&f); + cq_verifier_destroy(cqv); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { unsigned i, j; - for (j = 2; j < 6; j++) - { - for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++) - { - test_cancel_after_invoke (config, cancellation_modes[i], j); - } + for (j = 2; j < 6; j++) { + for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { + test_cancel_after_invoke(config, cancellation_modes[i], j); } + } } diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 065ed43ebd..c049e0c2d6 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -43,90 +43,70 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Cancel before invoke */ -static void -test_cancel_before_invoke (grpc_end2end_test_config config, size_t test_ops) -{ +static void test_cancel_before_invoke(grpc_end2end_test_config config, + size_t test_ops) { grpc_op ops[6]; grpc_op *op; grpc_call *c; - grpc_end2end_test_fixture f = begin_test (config, "cancel_before_invoke", NULL, NULL); - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + grpc_end2end_test_fixture f = + begin_test(config, "cancel_before_invoke", NULL, NULL); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -136,18 +116,20 @@ test_cancel_before_invoke (grpc_end2end_test_config config, size_t test_ops) char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - GPR_ASSERT (GRPC_CALL_OK == grpc_call_cancel (c, NULL)); + GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c, NULL)); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -182,36 +164,33 @@ test_cancel_before_invoke (grpc_end2end_test_config config, size_t test_ops) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, test_ops, tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, test_ops, tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_CANCELLED); + GPR_ASSERT(status == GRPC_STATUS_CANCELLED); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload_recv); - gpr_free (details); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload_recv); + gpr_free(details); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (cqv); - end_test (&f); - config.tear_down_data (&f); + cq_verifier_destroy(cqv); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { size_t i; - for (i = 1; i <= 6; i++) - { - test_cancel_before_invoke (config, i); - } + for (i = 1; i <= 6; i++) { + test_cancel_before_invoke(config, i); + } } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 512bceb6e5..6c63d7c0ad 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -44,108 +44,86 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Cancel and do nothing */ -static void -test_cancel_in_a_vacuum (grpc_end2end_test_config config, cancellation_mode mode) -{ +static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, + cancellation_mode mode) { grpc_call *c; - grpc_end2end_test_fixture f = begin_test (config, "test_cancel_in_a_vacuum", NULL, NULL); - gpr_timespec deadline = five_seconds_time (); - cq_verifier *v_client = cq_verifier_create (f.cq); + grpc_end2end_test_fixture f = + begin_test(config, "test_cancel_in_a_vacuum", NULL, NULL); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *v_client = cq_verifier_create(f.cq); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - GPR_ASSERT (GRPC_CALL_OK == mode.initiate_cancel (c, NULL)); + GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (v_client); - end_test (&f); - config.tear_down_data (&f); + cq_verifier_destroy(v_client); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { unsigned i; - for (i = 0; i < GPR_ARRAY_SIZE (cancellation_modes); i++) - { - test_cancel_in_a_vacuum (config, cancellation_modes[i]); - } + for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { + test_cancel_in_a_vacuum(config, cancellation_modes[i]); + } } diff --git a/test/core/end2end/tests/cancel_test_helpers.h b/test/core/end2end/tests/cancel_test_helpers.h index 20bcfc86aa..f8fafae597 100644 --- a/test/core/end2end/tests/cancel_test_helpers.h +++ b/test/core/end2end/tests/cancel_test_helpers.h @@ -34,25 +34,22 @@ #ifndef GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H #define GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H -typedef struct -{ +typedef struct { const char *name; - grpc_call_error (*initiate_cancel) (grpc_call * call, void *reserved); + grpc_call_error (*initiate_cancel)(grpc_call *call, void *reserved); grpc_status_code expect_status; const char *expect_details; } cancellation_mode; -static grpc_call_error -wait_for_deadline (grpc_call * call, void *reserved) -{ - (void) reserved; +static grpc_call_error wait_for_deadline(grpc_call *call, void *reserved) { + (void)reserved; return GRPC_CALL_OK; } static const cancellation_mode cancellation_modes[] = { - {"cancel", grpc_call_cancel, GRPC_STATUS_CANCELLED, "Cancelled"}, - {"deadline", wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, - "Deadline Exceeded"}, + {"cancel", grpc_call_cancel, GRPC_STATUS_CANCELLED, "Cancelled"}, + {"deadline", wait_for_deadline, GRPC_STATUS_DEADLINE_EXCEEDED, + "Deadline Exceeded"}, }; #endif /* GRPC_TEST_CORE_END2END_TESTS_CANCEL_TEST_HELPERS_H */ diff --git a/test/core/end2end/tests/census_simple_request.c b/test/core/end2end/tests/census_simple_request.c index 71fd9e0e49..adf855ca60 100644 --- a/test/core/end2end/tests/census_simple_request.c +++ b/test/core/end2end/tests/census_simple_request.c @@ -45,78 +45,61 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, n_seconds_time (5), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, n_seconds_time(5), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -test_body (grpc_end2end_test_fixture f) -{ +static void test_body(grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = n_seconds_time (5); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = n_seconds_time(5); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -129,13 +112,15 @@ test_body (grpc_end2end_test_fixture f) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -160,13 +145,15 @@ test_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -186,34 +173,34 @@ test_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_request_with_census (grpc_end2end_test_config config, const char *name, void (*body) (grpc_end2end_test_fixture f)) -{ +static void test_invoke_request_with_census( + grpc_end2end_test_config config, const char *name, + void (*body)(grpc_end2end_test_fixture f)) { char *fullname; grpc_end2end_test_fixture f; grpc_arg client_arg, server_arg; @@ -232,16 +219,14 @@ test_invoke_request_with_census (grpc_end2end_test_config config, const char *na server_args.num_args = 1; server_args.args = &server_arg; - gpr_asprintf (&fullname, "%s/%s", "test_invoke_request_with_census", name); - f = begin_test (config, fullname, &client_args, &server_args); - body (f); - end_test (&f); - config.tear_down_data (&f); - gpr_free (fullname); + gpr_asprintf(&fullname, "%s/%s", "test_invoke_request_with_census", name); + f = begin_test(config, fullname, &client_args, &server_args); + body(f); + end_test(&f); + config.tear_down_data(&f); + gpr_free(fullname); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_request_with_census (config, "census_simple_request", test_body); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_request_with_census(config, "census_simple_request", test_body); } diff --git a/test/core/end2end/tests/channel_connectivity.c b/test/core/end2end/tests/channel_connectivity.c index 54e719e545..0b7a8a664b 100644 --- a/test/core/end2end/tests/channel_connectivity.c +++ b/test/core/end2end/tests/channel_connectivity.c @@ -38,95 +38,101 @@ #include "test/core/end2end/cq_verifier.h" -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static void -test_connectivity (grpc_end2end_test_config config) -{ - grpc_end2end_test_fixture f = config.create_fixture (NULL, NULL); +static void test_connectivity(grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); grpc_connectivity_state state; - cq_verifier *cqv = cq_verifier_create (f.cq); + cq_verifier *cqv = cq_verifier_create(f.cq); - config.init_client (&f, NULL); + config.init_client(&f, NULL); /* channels should start life in IDLE, and stay there */ - GPR_ASSERT (grpc_channel_check_connectivity_state (f.client, 0) == GRPC_CHANNEL_IDLE); - gpr_sleep_until (GRPC_TIMEOUT_MILLIS_TO_DEADLINE (100)); - GPR_ASSERT (grpc_channel_check_connectivity_state (f.client, 0) == GRPC_CHANNEL_IDLE); + GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == + GRPC_CHANNEL_IDLE); + gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100)); + GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 0) == + GRPC_CHANNEL_IDLE); /* start watching for a change */ - grpc_channel_watch_connectivity_state (f.client, GRPC_CHANNEL_IDLE, GRPC_TIMEOUT_SECONDS_TO_DEADLINE (3), f.cq, tag (1)); + grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_IDLE, + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + f.cq, tag(1)); /* nothing should happen */ - cq_verify_empty (cqv); + cq_verify_empty(cqv); /* check that we're still in idle, and start connecting */ - GPR_ASSERT (grpc_channel_check_connectivity_state (f.client, 1) == GRPC_CHANNEL_IDLE); + GPR_ASSERT(grpc_channel_check_connectivity_state(f.client, 1) == + GRPC_CHANNEL_IDLE); /* and now the watch should trigger */ - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); - state = grpc_channel_check_connectivity_state (f.client, 0); - GPR_ASSERT (state == GRPC_CHANNEL_TRANSIENT_FAILURE || state == GRPC_CHANNEL_CONNECTING); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); + state = grpc_channel_check_connectivity_state(f.client, 0); + GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || + state == GRPC_CHANNEL_CONNECTING); /* quickly followed by a transition to TRANSIENT_FAILURE */ - grpc_channel_watch_connectivity_state (f.client, GRPC_CHANNEL_CONNECTING, GRPC_TIMEOUT_SECONDS_TO_DEADLINE (3), f.cq, tag (2)); - cq_expect_completion (cqv, tag (2), 1); - cq_verify (cqv); - state = grpc_channel_check_connectivity_state (f.client, 0); - GPR_ASSERT (state == GRPC_CHANNEL_TRANSIENT_FAILURE || state == GRPC_CHANNEL_CONNECTING); + grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_CONNECTING, + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + f.cq, tag(2)); + cq_expect_completion(cqv, tag(2), 1); + cq_verify(cqv); + state = grpc_channel_check_connectivity_state(f.client, 0); + GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || + state == GRPC_CHANNEL_CONNECTING); - gpr_log (GPR_DEBUG, "*** STARTING SERVER ***"); + gpr_log(GPR_DEBUG, "*** STARTING SERVER ***"); /* now let's bring up a server to connect to */ - config.init_server (&f, NULL); + config.init_server(&f, NULL); - gpr_log (GPR_DEBUG, "*** STARTED SERVER ***"); + gpr_log(GPR_DEBUG, "*** STARTED SERVER ***"); /* we'll go through some set of transitions (some might be missed), until READY is reached */ - while (state != GRPC_CHANNEL_READY) - { - grpc_channel_watch_connectivity_state (f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE (3), f.cq, tag (3)); - cq_expect_completion (cqv, tag (3), 1); - cq_verify (cqv); - state = grpc_channel_check_connectivity_state (f.client, 0); - GPR_ASSERT (state == GRPC_CHANNEL_READY || state == GRPC_CHANNEL_CONNECTING || state == GRPC_CHANNEL_TRANSIENT_FAILURE); - } + while (state != GRPC_CHANNEL_READY) { + grpc_channel_watch_connectivity_state( + f.client, state, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), f.cq, tag(3)); + cq_expect_completion(cqv, tag(3), 1); + cq_verify(cqv); + state = grpc_channel_check_connectivity_state(f.client, 0); + GPR_ASSERT(state == GRPC_CHANNEL_READY || + state == GRPC_CHANNEL_CONNECTING || + state == GRPC_CHANNEL_TRANSIENT_FAILURE); + } /* bring down the server again */ /* we should go immediately to TRANSIENT_FAILURE */ - gpr_log (GPR_DEBUG, "*** SHUTTING DOWN SERVER ***"); + gpr_log(GPR_DEBUG, "*** SHUTTING DOWN SERVER ***"); - grpc_channel_watch_connectivity_state (f.client, GRPC_CHANNEL_READY, GRPC_TIMEOUT_SECONDS_TO_DEADLINE (3), f.cq, tag (4)); + grpc_channel_watch_connectivity_state(f.client, GRPC_CHANNEL_READY, + GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + f.cq, tag(4)); - grpc_server_shutdown_and_notify (f.server, f.cq, tag (0xdead)); + grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead)); - cq_expect_completion (cqv, tag (4), 1); - cq_expect_completion (cqv, tag (0xdead), 1); - cq_verify (cqv); - state = grpc_channel_check_connectivity_state (f.client, 0); - GPR_ASSERT (state == GRPC_CHANNEL_TRANSIENT_FAILURE || state == GRPC_CHANNEL_CONNECTING); + cq_expect_completion(cqv, tag(4), 1); + cq_expect_completion(cqv, tag(0xdead), 1); + cq_verify(cqv); + state = grpc_channel_check_connectivity_state(f.client, 0); + GPR_ASSERT(state == GRPC_CHANNEL_TRANSIENT_FAILURE || + state == GRPC_CHANNEL_CONNECTING); /* cleanup server */ - grpc_server_destroy (f.server); + grpc_server_destroy(f.server); - gpr_log (GPR_DEBUG, "*** SHUTDOWN SERVER ***"); + gpr_log(GPR_DEBUG, "*** SHUTDOWN SERVER ***"); - grpc_channel_destroy (f.client); - grpc_completion_queue_shutdown (f.cq); - grpc_completion_queue_destroy (f.cq); - config.tear_down_data (&f); + grpc_channel_destroy(f.client); + grpc_completion_queue_shutdown(f.cq); + grpc_completion_queue_destroy(f.cq); + config.tear_down_data(&f); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - GPR_ASSERT (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); - test_connectivity (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); + test_connectivity(config); } diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index e7c0768d22..c50eaba8b2 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -48,88 +48,71 @@ #include "src/core/channel/compress_filter.h" #include "src/core/surface/call.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -request_with_payload_template (grpc_end2end_test_config config, const char *test_name, gpr_uint32 send_flags_bitmask, grpc_compression_algorithm requested_compression_algorithm, grpc_compression_algorithm expected_compression_algorithm, grpc_metadata * client_metadata) -{ +static void request_with_payload_template( + grpc_end2end_test_config config, const char *test_name, + gpr_uint32 send_flags_bitmask, + grpc_compression_algorithm requested_compression_algorithm, + grpc_compression_algorithm expected_compression_algorithm, + grpc_metadata *client_metadata) { grpc_call *c; grpc_call *s; gpr_slice request_payload_slice; grpc_byte_buffer *request_payload; - gpr_timespec deadline = five_seconds_time (); + gpr_timespec deadline = five_seconds_time(); grpc_channel_args *client_args; grpc_channel_args *server_args; grpc_end2end_test_fixture f; @@ -148,36 +131,36 @@ request_with_payload_template (grpc_end2end_test_config config, const char *test cq_verifier *cqv; char str[1024]; - memset (str, 'x', 1023); + memset(str, 'x', 1023); str[1023] = '\0'; - request_payload_slice = gpr_slice_from_copied_string (str); - request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); + request_payload_slice = gpr_slice_from_copied_string(str); + request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - client_args = grpc_channel_args_set_compression_algorithm (NULL, requested_compression_algorithm); - server_args = grpc_channel_args_set_compression_algorithm (NULL, requested_compression_algorithm); + client_args = grpc_channel_args_set_compression_algorithm( + NULL, requested_compression_algorithm); + server_args = grpc_channel_args_set_compression_algorithm( + NULL, requested_compression_algorithm); - f = begin_test (config, test_name, client_args, server_args); - cqv = cq_verifier_create (f.cq); + f = begin_test(config, test_name, client_args, server_args); + cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; - if (client_metadata != NULL) - { - op->data.send_initial_metadata.count = 1; - op->data.send_initial_metadata.metadata = client_metadata; - } - else - { - op->data.send_initial_metadata.count = 0; - } + if (client_metadata != NULL) { + op->data.send_initial_metadata.count = 1; + op->data.send_initial_metadata.metadata = client_metadata; + } else { + op->data.send_initial_metadata.count = 0; + } op->flags = 0; op->reserved = NULL; op++; @@ -203,18 +186,23 @@ request_with_payload_template (grpc_end2end_test_config config, const char *test op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); - - GPR_ASSERT (GPR_BITCOUNT (grpc_call_get_encodings_accepted_by_peer (s)) == 3); - GPR_ASSERT (GPR_BITGET (grpc_call_get_encodings_accepted_by_peer (s), GRPC_COMPRESS_NONE) != 0); - GPR_ASSERT (GPR_BITGET (grpc_call_get_encodings_accepted_by_peer (s), GRPC_COMPRESS_DEFLATE) != 0); - GPR_ASSERT (GPR_BITGET (grpc_call_get_encodings_accepted_by_peer (s), GRPC_COMPRESS_GZIP) != 0); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); + + GPR_ASSERT(GPR_BITCOUNT(grpc_call_get_encodings_accepted_by_peer(s)) == 3); + GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_NONE) != 0); + GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_DEFLATE) != 0); + GPR_ASSERT(GPR_BITGET(grpc_call_get_encodings_accepted_by_peer(s), + GRPC_COMPRESS_GZIP) != 0); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -227,11 +215,11 @@ request_with_payload_template (grpc_end2end_test_config config, const char *test op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -246,95 +234,104 @@ request_with_payload_template (grpc_end2end_test_config config, const char *test op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 0); + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 0); - GPR_ASSERT (request_payload_recv->type == GRPC_BB_RAW); - GPR_ASSERT (request_payload_recv->data.raw.compression == expected_compression_algorithm); + GPR_ASSERT(request_payload_recv->type == GRPC_BB_RAW); + GPR_ASSERT(request_payload_recv->data.raw.compression == + expected_compression_algorithm); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, str)); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, str)); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - gpr_slice_unref (request_payload_slice); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (request_payload_recv); + gpr_slice_unref(request_payload_slice); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(request_payload_recv); - grpc_channel_args_destroy (client_args); - grpc_channel_args_destroy (server_args); + grpc_channel_args_destroy(client_args); + grpc_channel_args_destroy(server_args); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -static void -test_invoke_request_with_exceptionally_uncompressed_payload (grpc_end2end_test_config config) -{ - request_with_payload_template (config, "test_invoke_request_with_exceptionally_uncompressed_payload", GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, NULL); +static void test_invoke_request_with_exceptionally_uncompressed_payload( + grpc_end2end_test_config config) { + request_with_payload_template( + config, "test_invoke_request_with_exceptionally_uncompressed_payload", + GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, NULL); } -static void -test_invoke_request_with_uncompressed_payload (grpc_end2end_test_config config) -{ - request_with_payload_template (config, "test_invoke_request_with_uncompressed_payload", 0, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, NULL); +static void test_invoke_request_with_uncompressed_payload( + grpc_end2end_test_config config) { + request_with_payload_template( + config, "test_invoke_request_with_uncompressed_payload", 0, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, NULL); } -static void -test_invoke_request_with_compressed_payload (grpc_end2end_test_config config) -{ - request_with_payload_template (config, "test_invoke_request_with_compressed_payload", 0, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, NULL); +static void test_invoke_request_with_compressed_payload( + grpc_end2end_test_config config) { + request_with_payload_template( + config, "test_invoke_request_with_compressed_payload", 0, + GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, NULL); } -static void -test_invoke_request_with_compressed_payload_md_override (grpc_end2end_test_config config) -{ +static void test_invoke_request_with_compressed_payload_md_override( + grpc_end2end_test_config config) { grpc_metadata gzip_compression_override; grpc_metadata none_compression_override; gzip_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY; gzip_compression_override.value = "gzip"; gzip_compression_override.value_length = 4; - memset (&gzip_compression_override.internal_data, 0, sizeof (gzip_compression_override.internal_data)); + memset(&gzip_compression_override.internal_data, 0, + sizeof(gzip_compression_override.internal_data)); none_compression_override.key = GRPC_COMPRESS_REQUEST_ALGORITHM_KEY; none_compression_override.value = "identity"; none_compression_override.value_length = 4; - memset (&none_compression_override.internal_data, 0, sizeof (none_compression_override.internal_data)); + memset(&none_compression_override.internal_data, 0, + sizeof(none_compression_override.internal_data)); /* Channel default NONE (aka IDENTITY), call override to GZIP */ - request_with_payload_template (config, "test_invoke_request_with_compressed_payload_md_override_1", 0, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, &gzip_compression_override); + request_with_payload_template( + config, "test_invoke_request_with_compressed_payload_md_override_1", 0, + GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, &gzip_compression_override); /* Channel default DEFLATE, call override to GZIP */ - request_with_payload_template (config, "test_invoke_request_with_compressed_payload_md_override_2", 0, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP, &gzip_compression_override); + request_with_payload_template( + config, "test_invoke_request_with_compressed_payload_md_override_2", 0, + GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_GZIP, &gzip_compression_override); /* Channel default DEFLATE, call override to NONE (aka IDENTITY) */ - request_with_payload_template (config, "test_invoke_request_with_compressed_payload_md_override_3", 0, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, &none_compression_override); + request_with_payload_template( + config, "test_invoke_request_with_compressed_payload_md_override_3", 0, + GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, &none_compression_override); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_request_with_exceptionally_uncompressed_payload (config); - test_invoke_request_with_uncompressed_payload (config); - test_invoke_request_with_compressed_payload (config); - test_invoke_request_with_compressed_payload_md_override (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_request_with_exceptionally_uncompressed_payload(config); + test_invoke_request_with_uncompressed_payload(config); + test_invoke_request_with_compressed_payload(config); + test_invoke_request_with_compressed_payload_md_override(config); } diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index 2bffa8d692..7b62505a9a 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -45,87 +45,65 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_request_body (grpc_end2end_test_fixture f) -{ +static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -139,18 +117,19 @@ simple_request_body (grpc_end2end_test_fixture f) int was_cancelled = 2; char *peer; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", NULL, deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", NULL, deadline, NULL); + GPR_ASSERT(c); - peer = grpc_call_get_peer (c); - GPR_ASSERT (peer != NULL); - gpr_log (GPR_DEBUG, "client_peer_before_call=%s", peer); - gpr_free (peer); + peer = grpc_call_get_peer(c); + GPR_ASSERT(peer != NULL); + gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer); + gpr_free(peer); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -175,22 +154,24 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (error == GRPC_CALL_OK); - - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (error == GRPC_CALL_OK); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); - - peer = grpc_call_get_peer (s); - GPR_ASSERT (peer != NULL); - gpr_log (GPR_DEBUG, "server_peer=%s", peer); - gpr_free (peer); - peer = grpc_call_get_peer (c); - GPR_ASSERT (peer != NULL); - gpr_log (GPR_DEBUG, "client_peer=%s", peer); - gpr_free (peer); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(error == GRPC_CALL_OK); + + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(error == GRPC_CALL_OK); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); + + peer = grpc_call_get_peer(s); + GPR_ASSERT(peer != NULL); + gpr_log(GPR_DEBUG, "server_peer=%s", peer); + gpr_free(peer); + peer = grpc_call_get_peer(c); + GPR_ASSERT(peer != NULL); + gpr_log(GPR_DEBUG, "client_peer=%s", peer); + gpr_free(peer); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -210,48 +191,44 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (error == GRPC_CALL_OK); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(error == GRPC_CALL_OK); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strncmp (call_details.host, "localhost", 9)); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strncmp(call_details.host, "localhost", 9)); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_simple_request (grpc_end2end_test_config config) -{ +static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - f = begin_test (config, "test_invoke_simple_request", NULL, NULL); - simple_request_body (f); - end_test (&f); - config.tear_down_data (&f); + f = begin_test(config, "test_invoke_simple_request", NULL, NULL); + simple_request_body(f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { if ((config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) != 0) return; if ((config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) == 0) return; - test_invoke_simple_request (config); + test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index e1758706bc..de3ea16f66 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -43,73 +43,49 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -do_request_and_shutdown_server (grpc_end2end_test_fixture * f, cq_verifier * cqv) -{ +static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, + cq_verifier *cqv) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); + gpr_timespec deadline = five_seconds_time(); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -122,13 +98,15 @@ do_request_and_shutdown_server (grpc_end2end_test_fixture * f, cq_verifier * cqv size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, "/foo", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, + "/foo", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -153,17 +131,19 @@ do_request_and_shutdown_server (grpc_end2end_test_fixture * f, cq_verifier * cqv op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f->server, &s, &call_details, &request_metadata_recv, f->cq, f->cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f->server, &s, &call_details, + &request_metadata_recv, f->cq, f->cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); /* should be able to shut down the server early - and still complete the request */ - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -183,57 +163,53 @@ do_request_and_shutdown_server (grpc_end2end_test_fixture * f, cq_verifier * cqv op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_expect_completion (cqv, tag (1000), 1); - cq_verify (cqv); - - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); - - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); - - grpc_call_destroy (c); - grpc_call_destroy (s); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_expect_completion(cqv, tag(1000), 1); + cq_verify(cqv); + + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); + + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + grpc_call_destroy(c); + grpc_call_destroy(s); } -static void -disappearing_server_test (grpc_end2end_test_config config) -{ - grpc_end2end_test_fixture f = config.create_fixture (NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); +static void disappearing_server_test(grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); - gpr_log (GPR_INFO, "%s/%s", "disappearing_server_test", config.name); + gpr_log(GPR_INFO, "%s/%s", "disappearing_server_test", config.name); - config.init_client (&f, NULL); - config.init_server (&f, NULL); + config.init_client(&f, NULL); + config.init_server(&f, NULL); - do_request_and_shutdown_server (&f, cqv); + do_request_and_shutdown_server(&f, cqv); /* now destroy and recreate the server */ - config.init_server (&f, NULL); + config.init_server(&f, NULL); - do_request_and_shutdown_server (&f, cqv); + do_request_and_shutdown_server(&f, cqv); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - GPR_ASSERT (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); - disappearing_server_test (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); + disappearing_server_test(config); } diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index a73bdc7b3f..c93d236a6a 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -45,115 +45,90 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -empty_batch_body (grpc_end2end_test_fixture f) -{ +static void empty_batch_body(grpc_end2end_test_fixture f) { grpc_call *c; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_call_error error; grpc_op *op = NULL; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - error = grpc_call_start_batch (c, op, 0, tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + error = grpc_call_start_batch(c, op, 0, tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_empty_body (grpc_end2end_test_config config) -{ +static void test_invoke_empty_body(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - f = begin_test (config, "test_invoke_empty_body", NULL, NULL); - empty_batch_body (f); - end_test (&f); - config.tear_down_data (&f); + f = begin_test(config, "test_invoke_empty_body", NULL, NULL); + empty_batch_body(f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_empty_body (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_empty_body(config); } diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index b3e30964ae..df420a9846 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -43,86 +43,64 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config config) -{ +static void test_early_server_shutdown_finishes_inflight_calls( + grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - grpc_end2end_test_fixture f = begin_test (config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + grpc_end2end_test_fixture f = begin_test( + config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -135,13 +113,14 @@ test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config con size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -167,17 +146,19 @@ test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config con op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); /* shutdown and destroy the server */ - grpc_server_shutdown_and_notify (f.server, f.cq, tag (0xdead)); - cq_verify_empty (cqv); + grpc_server_shutdown_and_notify(f.server, f.cq, tag(0xdead)); + cq_verify_empty(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -197,37 +178,35 @@ test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config con op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (0xdead), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(0xdead), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - grpc_call_destroy (s); + grpc_call_destroy(s); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_early_server_shutdown_finishes_inflight_calls (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 4d9d09cd80..44d6a60c10 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -45,87 +45,65 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_request_body (grpc_end2end_test_fixture f) -{ +static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -138,13 +116,15 @@ simple_request_body (grpc_end2end_test_fixture f) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -169,13 +149,15 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -195,34 +177,33 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_10_simple_requests (grpc_end2end_test_config config, int initial_sequence_number) -{ +static void test_invoke_10_simple_requests(grpc_end2end_test_config config, + int initial_sequence_number) { int i; grpc_end2end_test_fixture f; grpc_arg client_arg; @@ -235,22 +216,18 @@ test_invoke_10_simple_requests (grpc_end2end_test_config config, int initial_seq client_args.num_args = 1; client_args.args = &client_arg; - f = begin_test (config, "test_invoke_10_simple_requests", &client_args, NULL); - for (i = 0; i < 10; i++) - { - simple_request_body (f); - gpr_log (GPR_INFO, "Passed simple request %d", i); - } - end_test (&f); - config.tear_down_data (&f); + f = begin_test(config, "test_invoke_10_simple_requests", &client_args, NULL); + for (i = 0; i < 10; i++) { + simple_request_body(f); + gpr_log(GPR_INFO, "Passed simple request %d", i); + } + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_10_simple_requests (config, 16777213); - if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) - { - test_invoke_10_simple_requests (config, 2147483645); - } +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_10_simple_requests(config, 16777213); + if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) { + test_invoke_10_simple_requests(config, 2147483645); + } } diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index da19222c53..f79d146da1 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -43,95 +43,78 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, n_seconds_time (5), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, n_seconds_time(5), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static gpr_slice -large_slice (void) -{ - gpr_slice slice = gpr_slice_malloc (1000000); - memset (GPR_SLICE_START_PTR (slice), 'x', GPR_SLICE_LENGTH (slice)); +static gpr_slice large_slice(void) { + gpr_slice slice = gpr_slice_malloc(1000000); + memset(GPR_SLICE_START_PTR(slice), 'x', GPR_SLICE_LENGTH(slice)); return slice; } -static void -test_invoke_large_request (grpc_end2end_test_config config) -{ - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_large_request", NULL, NULL); +static void test_invoke_large_request(grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = + begin_test(config, "test_invoke_large_request", NULL, NULL); - gpr_slice request_payload_slice = large_slice (); - gpr_slice response_payload_slice = large_slice (); + gpr_slice request_payload_slice = large_slice(); + gpr_slice response_payload_slice = large_slice(); grpc_call *c; grpc_call *s; - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); - gpr_timespec deadline = n_seconds_time (30); - cq_verifier *cqv = cq_verifier_create (f.cq); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + gpr_timespec deadline = n_seconds_time(30); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -146,13 +129,14 @@ test_invoke_large_request (grpc_end2end_test_config config) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -187,13 +171,15 @@ test_invoke_large_request (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -206,11 +192,11 @@ test_invoke_large_request (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -230,43 +216,41 @@ test_invoke_large_request (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); - gpr_slice_unref (request_payload_slice); - gpr_slice_unref (response_payload_slice); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + gpr_slice_unref(request_payload_slice); + gpr_slice_unref(response_payload_slice); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_large_request (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_large_request(config); } diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index ff7605ebe9..87529639a7 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -43,92 +43,72 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Request with a large amount of metadata.*/ -static void -test_request_with_large_metadata (grpc_end2end_test_config config) -{ +static void test_request_with_large_metadata(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - gpr_timespec deadline = five_seconds_time (); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + gpr_timespec deadline = five_seconds_time(); grpc_metadata meta; - grpc_end2end_test_fixture f = begin_test (config, "test_request_with_large_metadata", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + grpc_end2end_test_fixture f = + begin_test(config, "test_request_with_large_metadata", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -143,19 +123,20 @@ test_request_with_large_metadata (grpc_end2end_test_config config) int was_cancelled = 2; const size_t large_size = 64 * 1024; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); meta.key = "key"; - meta.value = gpr_malloc (large_size + 1); - memset ((char *) meta.value, 'a', large_size); - ((char *) meta.value)[large_size] = 0; + meta.value = gpr_malloc(large_size + 1); + memset((char *)meta.value, 'a', large_size); + ((char *)meta.value)[large_size] = 0; meta.value_length = large_size; - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -186,13 +167,15 @@ test_request_with_large_metadata (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -205,11 +188,11 @@ test_request_with_large_metadata (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -224,43 +207,41 @@ test_request_with_large_metadata (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 0); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world")); - GPR_ASSERT (contains_metadata (&request_metadata_recv, "key", meta.value)); + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 0); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); + GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value)); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (request_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(request_payload_recv); - gpr_free ((char *) meta.value); + gpr_free((char *)meta.value); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_request_with_large_metadata (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_request_with_large_metadata(config); } diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 1d4ba32ee0..87eb4dd451 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -43,87 +43,65 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_request_body (grpc_end2end_test_fixture f) -{ +static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -136,13 +114,15 @@ simple_request_body (grpc_end2end_test_fixture f) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -167,13 +147,15 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -193,34 +175,32 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_max_concurrent_streams (grpc_end2end_test_config config) -{ +static void test_max_concurrent_streams(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; grpc_arg server_arg; grpc_channel_args server_args; @@ -258,31 +238,37 @@ test_max_concurrent_streams (grpc_end2end_test_config config) server_args.num_args = 1; server_args.args = &server_arg; - f = begin_test (config, "test_max_concurrent_streams", NULL, &server_args); - cqv = cq_verifier_create (f.cq); + f = begin_test(config, "test_max_concurrent_streams", NULL, &server_args); + cqv = cq_verifier_create(f.cq); - grpc_metadata_array_init (&request_metadata_recv); - grpc_metadata_array_init (&initial_metadata_recv1); - grpc_metadata_array_init (&trailing_metadata_recv1); - grpc_metadata_array_init (&initial_metadata_recv2); - grpc_metadata_array_init (&trailing_metadata_recv2); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&request_metadata_recv); + grpc_metadata_array_init(&initial_metadata_recv1); + grpc_metadata_array_init(&trailing_metadata_recv1); + grpc_metadata_array_init(&initial_metadata_recv2); + grpc_metadata_array_init(&trailing_metadata_recv2); + grpc_call_details_init(&call_details); /* perform a ping-pong to ensure that settings have had a chance to round trip */ - simple_request_body (f); + simple_request_body(f); /* perform another one to make sure that the one stream case still works */ - simple_request_body (f); + simple_request_body(f); /* start two requests - ensuring that the second is not accepted until the first completes */ - deadline = n_seconds_time (1000); - c1 = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/alpha", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c1); - c2 = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/beta", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c2); - - GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s1, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101))); + deadline = n_seconds_time(1000); + c1 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/alpha", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c1); + c2 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/beta", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c2); + + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s1, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101))); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -294,8 +280,8 @@ test_max_concurrent_streams (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c1, ops, (size_t) (op - ops), tag (301), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(301), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -311,8 +297,8 @@ test_max_concurrent_streams (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c1, ops, (size_t) (op - ops), tag (302), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c1, ops, (size_t)(op - ops), tag(302), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -324,8 +310,8 @@ test_max_concurrent_streams (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c2, ops, (size_t) (op - ops), tag (401), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(401), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; @@ -341,35 +327,32 @@ test_max_concurrent_streams (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c2, ops, (size_t) (op - ops), tag (402), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c2, ops, (size_t)(op - ops), tag(402), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); got_client_start = 0; got_server_start = 0; live_call = -1; - while (!got_client_start || !got_server_start) - { - ev = grpc_completion_queue_next (f.cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE (3), NULL); - GPR_ASSERT (ev.type == GRPC_OP_COMPLETE); - GPR_ASSERT (ev.success); - if (ev.tag == tag (101)) - { - GPR_ASSERT (!got_server_start); - got_server_start = 1; - } - else - { - GPR_ASSERT (!got_client_start); - GPR_ASSERT (ev.tag == tag (301) || ev.tag == tag (401)); - /* The /alpha or /beta calls started above could be invoked (but NOT - * both); - * check this here */ - /* We'll get tag 303 or 403, we want 300, 400 */ - live_call = ((int) (gpr_intptr) ev.tag) - 1; - got_client_start = 1; - } + while (!got_client_start || !got_server_start) { + ev = grpc_completion_queue_next(f.cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(3), + NULL); + GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); + GPR_ASSERT(ev.success); + if (ev.tag == tag(101)) { + GPR_ASSERT(!got_server_start); + got_server_start = 1; + } else { + GPR_ASSERT(!got_client_start); + GPR_ASSERT(ev.tag == tag(301) || ev.tag == tag(401)); + /* The /alpha or /beta calls started above could be invoked (but NOT + * both); + * check this here */ + /* We'll get tag 303 or 403, we want 300, 400 */ + live_call = ((int)(gpr_intptr)ev.tag) - 1; + got_client_start = 1; } - GPR_ASSERT (live_call == 300 || live_call == 400); + } + GPR_ASSERT(live_call == 300 || live_call == 400); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -389,19 +372,21 @@ test_max_concurrent_streams (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s1, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s1, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (live_call + 2), 1); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(live_call + 2), 1); /* first request is finished, we should be able to start the second */ live_call = (live_call == 300) ? 400 : 300; - cq_expect_completion (cqv, tag (live_call + 1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(live_call + 1), 1); + cq_verify(cqv); - GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s2, &call_details, &request_metadata_recv, f.cq, f.cq, tag (201))); - cq_expect_completion (cqv, tag (201), 1); - cq_verify (cqv); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s2, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(201))); + cq_expect_completion(cqv, tag(201), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -421,35 +406,33 @@ test_max_concurrent_streams (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s2, ops, (size_t) (op - ops), tag (202), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - cq_expect_completion (cqv, tag (live_call + 2), 1); - cq_expect_completion (cqv, tag (202), 1); - cq_verify (cqv); - - cq_verifier_destroy (cqv); - - grpc_call_destroy (c1); - grpc_call_destroy (s1); - grpc_call_destroy (c2); - grpc_call_destroy (s2); - - gpr_free (details1); - gpr_free (details2); - grpc_metadata_array_destroy (&initial_metadata_recv1); - grpc_metadata_array_destroy (&trailing_metadata_recv1); - grpc_metadata_array_destroy (&initial_metadata_recv2); - grpc_metadata_array_destroy (&trailing_metadata_recv2); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); - - end_test (&f); - config.tear_down_data (&f); + error = grpc_call_start_batch(s2, ops, (size_t)(op - ops), tag(202), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + cq_expect_completion(cqv, tag(live_call + 2), 1); + cq_expect_completion(cqv, tag(202), 1); + cq_verify(cqv); + + cq_verifier_destroy(cqv); + + grpc_call_destroy(c1); + grpc_call_destroy(s1); + grpc_call_destroy(c2); + grpc_call_destroy(s2); + + gpr_free(details1); + gpr_free(details2); + grpc_metadata_array_destroy(&initial_metadata_recv1); + grpc_metadata_array_destroy(&trailing_metadata_recv1); + grpc_metadata_array_destroy(&initial_metadata_recv2); + grpc_metadata_array_destroy(&trailing_metadata_recv2); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_max_concurrent_streams (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_max_concurrent_streams(config); } diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index e1949692ca..782b9d0f26 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -43,83 +43,61 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -test_max_message_length (grpc_end2end_test_config config) -{ +static void test_max_message_length(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; grpc_arg server_arg; grpc_channel_args server_args; @@ -128,8 +106,9 @@ test_max_message_length (grpc_end2end_test_config config) cq_verifier *cqv; grpc_op ops[6]; grpc_op *op; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; grpc_metadata_array request_metadata_recv; @@ -147,16 +126,18 @@ test_max_message_length (grpc_end2end_test_config config) server_args.num_args = 1; server_args.args = &server_arg; - f = begin_test (config, "test_max_message_length", NULL, &server_args); - cqv = cq_verifier_create (f.cq); + f = begin_test(config, "test_max_message_length", NULL, &server_args); + cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", gpr_inf_future (GPR_CLOCK_REALTIME), NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr:1234", + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -186,13 +167,15 @@ test_max_message_length (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -200,36 +183,34 @@ test_max_message_length (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status != GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status != GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); - grpc_byte_buffer_destroy (request_payload); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + grpc_byte_buffer_destroy(request_payload); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_max_message_length (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_max_message_length(config); } diff --git a/test/core/end2end/tests/metadata.c b/test/core/end2end/tests/metadata.c index b1aefa77c6..d0604cc6b6 100644 --- a/test/core/end2end/tests/metadata.c +++ b/test/core/end2end/tests/metadata.c @@ -43,101 +43,81 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Request/response with metadata and payload.*/ -static void -test_request_response_with_metadata_and_payload (grpc_end2end_test_config config) -{ +static void test_request_response_with_metadata_and_payload( + grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); - gpr_timespec deadline = five_seconds_time (); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + gpr_timespec deadline = five_seconds_time(); grpc_metadata meta_c[2] = { - {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}} - }; + {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; grpc_metadata meta_s[2] = { - {"KeY3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"KeY4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}} - }; - grpc_end2end_test_fixture f = begin_test (config, "test_request_response_with_metadata_and_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + {"KeY3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"KeY4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_end2end_test_fixture f = begin_test( + config, "test_request_response_with_metadata_and_payload", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -152,13 +132,14 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -194,13 +175,15 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -214,11 +197,11 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -238,47 +221,45 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 0); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world")); - GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you")); - GPR_ASSERT (contains_metadata (&request_metadata_recv, "key1", "val1")); - GPR_ASSERT (contains_metadata (&request_metadata_recv, "key2", "val2")); - GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key3", "val3")); - GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key4", "val4")); + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 0); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); + GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); + GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1")); + GPR_ASSERT(contains_metadata(&request_metadata_recv, "key2", "val2")); + GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key3", "val3")); + GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key4", "val4")); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_request_response_with_metadata_and_payload (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index 0f15963a4a..157d0d5349 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -43,90 +43,64 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -test_no_op (grpc_end2end_test_config config) -{ - grpc_end2end_test_fixture f = begin_test (config, "no-op", NULL, NULL); - end_test (&f); - config.tear_down_data (&f); +static void test_no_op(grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = begin_test(config, "no-op", NULL, NULL); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_no_op (config); -} +void grpc_end2end_tests(grpc_end2end_test_config config) { test_no_op(config); } diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 1674974135..0b303268fc 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -43,91 +43,71 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -request_response_with_payload (grpc_end2end_test_fixture f) -{ - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); +static void request_response_with_payload(grpc_end2end_test_fixture f) { + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); grpc_call *c; grpc_call *s; - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -142,13 +122,14 @@ request_response_with_payload (grpc_end2end_test_fixture f) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -183,13 +164,15 @@ request_response_with_payload (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -202,11 +185,11 @@ request_response_with_payload (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -226,65 +209,62 @@ request_response_with_payload (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 0); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world")); - GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you")); + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 0); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); + GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); } /* Client sends a request with payload, server reads then returns a response payload and status. */ -static void -test_invoke_request_response_with_payload (grpc_end2end_test_config config) -{ - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_request_response_with_payload", NULL, NULL); - request_response_with_payload (f); - end_test (&f); - config.tear_down_data (&f); +static void test_invoke_request_response_with_payload( + grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = begin_test( + config, "test_invoke_request_response_with_payload", NULL, NULL); + request_response_with_payload(f); + end_test(&f); + config.tear_down_data(&f); } -static void -test_invoke_10_request_response_with_payload (grpc_end2end_test_config config) -{ +static void test_invoke_10_request_response_with_payload( + grpc_end2end_test_config config) { int i; - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_10_request_response_with_payload", NULL, NULL); - for (i = 0; i < 10; i++) - { - request_response_with_payload (f); - } - end_test (&f); - config.tear_down_data (&f); + grpc_end2end_test_fixture f = begin_test( + config, "test_invoke_10_request_response_with_payload", NULL, NULL); + for (i = 0; i < 10; i++) { + request_response_with_payload(f); + } + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_request_response_with_payload (config); - test_invoke_10_request_response_with_payload (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_request_response_with_payload(config); + test_invoke_10_request_response_with_payload(config); } diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index c3431dd03d..39682d8bc5 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -43,89 +43,69 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Client pings and server pongs. Repeat messages rounds before finishing. */ -static void -test_pingpong_streaming (grpc_end2end_test_config config, int messages) -{ - grpc_end2end_test_fixture f = begin_test (config, "test_pingpong_streaming", NULL, NULL); +static void test_pingpong_streaming(grpc_end2end_test_config config, + int messages) { + grpc_end2end_test_fixture f = + begin_test(config, "test_pingpong_streaming", NULL, NULL); grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -142,16 +122,18 @@ test_pingpong_streaming (grpc_end2end_test_config config, int messages) grpc_byte_buffer *response_payload; grpc_byte_buffer *response_payload_recv; int i; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -172,13 +154,15 @@ test_pingpong_streaming (grpc_end2end_test_config config, int messages) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (100)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (100), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(100)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(100), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -191,67 +175,66 @@ test_pingpong_streaming (grpc_end2end_test_config config, int messages) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (101), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - for (i = 0; i < messages; i++) - { - request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); - - op = ops; - op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; - op->flags = 0; - op->reserved = NULL; - op++; - op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &response_payload_recv; - op->flags = 0; - op->reserved = NULL; - op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (2), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - op = ops; - op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv; - op->flags = 0; - op->reserved = NULL; - op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); - - op = ops; - op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = response_payload; - op->flags = 0; - op->reserved = NULL; - op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (2), 1); - cq_verify (cqv); - - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); - } - - gpr_slice_unref (request_payload_slice); - gpr_slice_unref (response_payload_slice); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(101), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + for (i = 0; i < messages; i++) { + request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); + response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); + + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message = request_payload; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &response_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + op = ops; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &request_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); + + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message = response_payload; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(2), 1); + cq_verify(cqv); + + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + } + + gpr_slice_unref(request_payload_slice); + gpr_slice_unref(response_payload_slice); op = ops; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (3), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); op = ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; @@ -261,37 +244,34 @@ test_pingpong_streaming (grpc_end2end_test_config config, int messages) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (104), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(104), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (1), 1); - cq_expect_completion (cqv, tag (3), 1); - cq_expect_completion (cqv, tag (101), 1); - cq_expect_completion (cqv, tag (104), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(1), 1); + cq_expect_completion(cqv, tag(3), 1); + cq_expect_completion(cqv, tag(101), 1); + cq_expect_completion(cqv, tag(104), 1); + cq_verify(cqv); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); - gpr_free (details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + gpr_free(details); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { int i; - for (i = 1; i < 10; i++) - { - test_pingpong_streaming (config, i); - } + for (i = 1; i < 10; i++) { + test_pingpong_streaming(config, i); + } } diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index b30498a990..b3156e0248 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -45,87 +45,65 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_request_body (grpc_end2end_test_fixture f, void *rc) -{ +static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -138,13 +116,14 @@ simple_request_body (grpc_end2end_test_fixture f, void *rc) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_registered_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, rc, deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_registered_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, rc, deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -169,13 +148,15 @@ simple_request_body (grpc_end2end_test_fixture f, void *rc) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -195,63 +176,58 @@ simple_request_body (grpc_end2end_test_fixture f, void *rc) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_simple_request (grpc_end2end_test_config config) -{ - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_simple_request", NULL, NULL); - void *rc = grpc_channel_register_call (f.client, "/foo", - "foo.test.google.fr:1234", NULL); +static void test_invoke_simple_request(grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = + begin_test(config, "test_invoke_simple_request", NULL, NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", + "foo.test.google.fr:1234", NULL); - simple_request_body (f, rc); - end_test (&f); - config.tear_down_data (&f); + simple_request_body(f, rc); + end_test(&f); + config.tear_down_data(&f); } -static void -test_invoke_10_simple_requests (grpc_end2end_test_config config) -{ +static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { int i; - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_10_simple_requests", NULL, NULL); - void *rc = grpc_channel_register_call (f.client, "/foo", - "foo.test.google.fr:1234", NULL); - - for (i = 0; i < 10; i++) - { - simple_request_body (f, rc); - gpr_log (GPR_INFO, "Passed simple request %d", i); - } - end_test (&f); - config.tear_down_data (&f); + grpc_end2end_test_fixture f = + begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", + "foo.test.google.fr:1234", NULL); + + for (i = 0; i < 10; i++) { + simple_request_body(f, rc); + gpr_log(GPR_INFO, "Passed simple request %d", i); + } + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_simple_request (config); - test_invoke_10_simple_requests (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_simple_request(config); + test_invoke_10_simple_requests(config); } diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 49474bb14f..b9cdf5168c 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -44,89 +44,71 @@ #include "src/core/transport/stream_op.h" #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -test_invoke_request_with_flags (grpc_end2end_test_config config, gpr_uint32 * flags_for_op, grpc_call_error call_start_batch_expected_result) -{ +static void test_invoke_request_with_flags( + grpc_end2end_test_config config, gpr_uint32 *flags_for_op, + grpc_call_error call_start_batch_expected_result) { grpc_call *c; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - gpr_timespec deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE (10); - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_request_with_flags", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + gpr_timespec deadline = GRPC_TIMEOUT_MILLIS_TO_DEADLINE(10); + grpc_end2end_test_fixture f = + begin_test(config, "test_invoke_request_with_flags", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -140,13 +122,14 @@ test_invoke_request_with_flags (grpc_end2end_test_config config, gpr_uint32 * fl size_t details_capacity = 0; grpc_call_error expectation; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -177,63 +160,57 @@ test_invoke_request_with_flags (grpc_end2end_test_config config, gpr_uint32 * fl op->reserved = NULL; op++; expectation = call_start_batch_expected_result; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (expectation == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(expectation == error); - if (expectation == GRPC_CALL_OK) - { - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); - } + if (expectation == GRPC_CALL_OK) { + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); + } - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); + grpc_call_destroy(c); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (request_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(request_payload_recv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { size_t i; gpr_uint32 flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1]; { /* check that all grpc_op_types fail when their flag value is set to an * invalid value */ - int indices[] = { GRPC_OP_SEND_INITIAL_METADATA, GRPC_OP_SEND_MESSAGE, - GRPC_OP_SEND_CLOSE_FROM_CLIENT, - GRPC_OP_RECV_INITIAL_METADATA, - GRPC_OP_RECV_STATUS_ON_CLIENT - }; - for (i = 0; i < GPR_ARRAY_SIZE (indices); ++i) - { - memset (flags_for_op, 0, sizeof (flags_for_op)); - flags_for_op[indices[i]] = 0xDEADBEEF; - test_invoke_request_with_flags (config, flags_for_op, GRPC_CALL_ERROR_INVALID_FLAGS); - } + int indices[] = {GRPC_OP_SEND_INITIAL_METADATA, GRPC_OP_SEND_MESSAGE, + GRPC_OP_SEND_CLOSE_FROM_CLIENT, + GRPC_OP_RECV_INITIAL_METADATA, + GRPC_OP_RECV_STATUS_ON_CLIENT}; + for (i = 0; i < GPR_ARRAY_SIZE(indices); ++i) { + memset(flags_for_op, 0, sizeof(flags_for_op)); + flags_for_op[indices[i]] = 0xDEADBEEF; + test_invoke_request_with_flags(config, flags_for_op, + GRPC_CALL_ERROR_INVALID_FLAGS); + } } { /* check valid operation with allowed flags for GRPC_OP_SEND_BUFFER */ - gpr_uint32 flags[] = { GRPC_WRITE_BUFFER_HINT, GRPC_WRITE_NO_COMPRESS, - GRPC_WRITE_INTERNAL_COMPRESS - }; - for (i = 0; i < GPR_ARRAY_SIZE (flags); ++i) - { - memset (flags_for_op, 0, sizeof (flags_for_op)); - flags_for_op[GRPC_OP_SEND_MESSAGE] = flags[i]; - test_invoke_request_with_flags (config, flags_for_op, GRPC_CALL_OK); - } + gpr_uint32 flags[] = {GRPC_WRITE_BUFFER_HINT, GRPC_WRITE_NO_COMPRESS, + GRPC_WRITE_INTERNAL_COMPRESS}; + for (i = 0; i < GPR_ARRAY_SIZE(flags); ++i) { + memset(flags_for_op, 0, sizeof(flags_for_op)); + flags_for_op[GRPC_OP_SEND_MESSAGE] = flags[i]; + test_invoke_request_with_flags(config, flags_for_op, GRPC_CALL_OK); + } } } diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index bbfbae8140..a323b43ab0 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -43,91 +43,71 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Client sends a request with payload, server reads then returns status. */ -static void -test_invoke_request_with_payload (grpc_end2end_test_config config) -{ +static void test_invoke_request_with_payload(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - gpr_timespec deadline = five_seconds_time (); - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_request_with_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + gpr_timespec deadline = five_seconds_time(); + grpc_end2end_test_fixture f = + begin_test(config, "test_invoke_request_with_payload", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -141,13 +121,14 @@ test_invoke_request_with_payload (grpc_end2end_test_config config) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -177,12 +158,14 @@ test_invoke_request_with_payload (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101))); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101))); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -195,11 +178,11 @@ test_invoke_request_with_payload (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -214,40 +197,38 @@ test_invoke_request_with_payload (grpc_end2end_test_config config) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 0); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world")); + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 0); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (request_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(request_payload_recv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_request_with_payload (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_request_with_payload(config); } diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index 14830735a2..bdc18a5e38 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -45,87 +45,65 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_request_body (grpc_end2end_test_fixture f) -{ +static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -138,13 +116,15 @@ simple_request_body (grpc_end2end_test_fixture f) size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -165,13 +145,15 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -191,44 +173,40 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_simple_request (grpc_end2end_test_config config) -{ +static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - f = begin_test (config, "test_invoke_simple_request", NULL, NULL); - simple_request_body (f); - end_test (&f); - config.tear_down_data (&f); + f = begin_test(config, "test_invoke_simple_request", NULL, NULL); + simple_request_body(f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_invoke_simple_request (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index a9d8535e31..ad7def09a9 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -43,76 +43,57 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config config) -{ +static void test_early_server_shutdown_finishes_inflight_calls( + grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - grpc_end2end_test_fixture f = begin_test (config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + grpc_end2end_test_fixture f = begin_test( + config, "test_early_server_shutdown_finishes_inflight_calls", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -125,13 +106,14 @@ test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config con size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -157,13 +139,15 @@ test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config con op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -171,42 +155,40 @@ test_early_server_shutdown_finishes_inflight_calls (grpc_end2end_test_config con op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); /* shutdown and destroy the server */ - grpc_server_shutdown_and_notify (f.server, f.cq, tag (1000)); - grpc_server_cancel_all_calls (f.server); + grpc_server_shutdown_and_notify(f.server, f.cq, tag(1000)); + grpc_server_cancel_all_calls(f.server); - cq_expect_completion (cqv, tag (1000), 1); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(1000), 1); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - grpc_server_destroy (f.server); + grpc_server_destroy(f.server); - GPR_ASSERT (status == GRPC_STATUS_UNAVAILABLE); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_early_server_shutdown_finishes_inflight_calls (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.c index 9569d42424..9b678a1754 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.c +++ b/test/core/end2end/tests/shutdown_finishes_tags.c @@ -43,98 +43,79 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -test_early_server_shutdown_finishes_tags (grpc_end2end_test_config config) -{ - grpc_end2end_test_fixture f = begin_test (config, "test_early_server_shutdown_finishes_tags", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); - grpc_call *s = (void *) 1; +static void test_early_server_shutdown_finishes_tags( + grpc_end2end_test_config config) { + grpc_end2end_test_fixture f = begin_test( + config, "test_early_server_shutdown_finishes_tags", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); + grpc_call *s = (void *)1; grpc_call_details call_details; grpc_metadata_array request_metadata_recv; - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); /* upon shutdown, the server should finish all requested calls indicating no new call */ - GPR_ASSERT (GRPC_CALL_OK == grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101))); - grpc_server_shutdown_and_notify (f.server, f.cq, tag (1000)); - cq_expect_completion (cqv, tag (101), 0); - cq_expect_completion (cqv, tag (1000), 1); - cq_verify (cqv); - GPR_ASSERT (s == NULL); - - grpc_server_destroy (f.server); - - end_test (&f); - config.tear_down_data (&f); - cq_verifier_destroy (cqv); + GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( + f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101))); + grpc_server_shutdown_and_notify(f.server, f.cq, tag(1000)); + cq_expect_completion(cqv, tag(101), 0); + cq_expect_completion(cqv, tag(1000), 1); + cq_verify(cqv); + GPR_ASSERT(s == NULL); + + grpc_server_destroy(f.server); + + end_test(&f); + config.tear_down_data(&f); + cq_verifier_destroy(cqv); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_early_server_shutdown_finishes_tags (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_early_server_shutdown_finishes_tags(config); } diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index ea21827b3e..14e0ac8f66 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -43,76 +43,57 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_delayed_request_body (grpc_end2end_test_config config, grpc_end2end_test_fixture * f, grpc_channel_args * client_args, grpc_channel_args * server_args, long delay_us) -{ +static void simple_delayed_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture *f, + grpc_channel_args *client_args, + grpc_channel_args *server_args, + long delay_us) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f->cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f->cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -125,15 +106,16 @@ simple_delayed_request_body (grpc_end2end_test_config config, grpc_end2end_test_ size_t details_capacity = 0; int was_cancelled = 2; - config.init_client (f, client_args); + config.init_client(f, client_args); - c = grpc_channel_create_call (f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -158,15 +140,17 @@ simple_delayed_request_body (grpc_end2end_test_config config, grpc_end2end_test_ op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - config.init_server (f, server_args); + config.init_server(f, server_args); - error = grpc_server_request_call (f->server, &s, &call_details, &request_metadata_recv, f->cq, f->cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f->server, &s, &call_details, + &request_metadata_recv, f->cq, f->cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -186,60 +170,54 @@ simple_delayed_request_body (grpc_end2end_test_config config, grpc_end2end_test_ op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_simple_delayed_request_short (grpc_end2end_test_config config) -{ +static void test_simple_delayed_request_short(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", "test_simple_delayed_request_short", config.name); - f = config.create_fixture (NULL, NULL); - simple_delayed_request_body (config, &f, NULL, NULL, 100000); - end_test (&f); - config.tear_down_data (&f); + gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_short", config.name); + f = config.create_fixture(NULL, NULL); + simple_delayed_request_body(config, &f, NULL, NULL, 100000); + end_test(&f); + config.tear_down_data(&f); } -static void -test_simple_delayed_request_long (grpc_end2end_test_config config) -{ +static void test_simple_delayed_request_long(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", "test_simple_delayed_request_long", config.name); - f = config.create_fixture (NULL, NULL); + gpr_log(GPR_INFO, "%s/%s", "test_simple_delayed_request_long", config.name); + f = config.create_fixture(NULL, NULL); /* This timeout should be longer than a single retry */ - simple_delayed_request_body (config, &f, NULL, NULL, 1500000); - end_test (&f); - config.tear_down_data (&f); + simple_delayed_request_body(config, &f, NULL, NULL, 1500000); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - GPR_ASSERT (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); - test_simple_delayed_request_short (config); - test_simple_delayed_request_long (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); + test_simple_delayed_request_short(config); + test_simple_delayed_request_long(config); } diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 76f0091298..a874640837 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -45,87 +45,65 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } -static void -simple_request_body (grpc_end2end_test_fixture f) -{ +static void simple_request_body(grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; - gpr_timespec deadline = five_seconds_time (); - cq_verifier *cqv = cq_verifier_create (f.cq); + gpr_timespec deadline = five_seconds_time(); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -139,18 +117,20 @@ simple_request_body (grpc_end2end_test_fixture f) int was_cancelled = 2; char *peer; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr:1234", deadline, + NULL); + GPR_ASSERT(c); - peer = grpc_call_get_peer (c); - GPR_ASSERT (peer != NULL); - gpr_log (GPR_DEBUG, "client_peer_before_call=%s", peer); - gpr_free (peer); + peer = grpc_call_get_peer(c); + GPR_ASSERT(peer != NULL); + gpr_log(GPR_DEBUG, "client_peer_before_call=%s", peer); + gpr_free(peer); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -175,22 +155,24 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); - - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); - - peer = grpc_call_get_peer (s); - GPR_ASSERT (peer != NULL); - gpr_log (GPR_DEBUG, "server_peer=%s", peer); - gpr_free (peer); - peer = grpc_call_get_peer (c); - GPR_ASSERT (peer != NULL); - gpr_log (GPR_DEBUG, "client_peer=%s", peer); - gpr_free (peer); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); + + peer = grpc_call_get_peer(s); + GPR_ASSERT(peer != NULL); + gpr_log(GPR_DEBUG, "server_peer=%s", peer); + gpr_free(peer); + peer = grpc_call_get_peer(c); + GPR_ASSERT(peer != NULL); + gpr_log(GPR_DEBUG, "client_peer=%s", peer); + gpr_free(peer); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -210,63 +192,56 @@ simple_request_body (grpc_end2end_test_fixture f) op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_UNIMPLEMENTED); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr:1234")); - GPR_ASSERT (was_cancelled == 1); + GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + GPR_ASSERT(was_cancelled == 1); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); } -static void -test_invoke_simple_request (grpc_end2end_test_config config) -{ +static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; - f = begin_test (config, "test_invoke_simple_request", NULL, NULL); - simple_request_body (f); - end_test (&f); - config.tear_down_data (&f); + f = begin_test(config, "test_invoke_simple_request", NULL, NULL); + simple_request_body(f); + end_test(&f); + config.tear_down_data(&f); } -static void -test_invoke_10_simple_requests (grpc_end2end_test_config config) -{ +static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { int i; - grpc_end2end_test_fixture f = begin_test (config, "test_invoke_10_simple_requests", NULL, NULL); - for (i = 0; i < 10; i++) - { - simple_request_body (f); - gpr_log (GPR_INFO, "Passed simple request %d", i); - } - end_test (&f); - config.tear_down_data (&f); + grpc_end2end_test_fixture f = + begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); + for (i = 0; i < 10; i++) { + simple_request_body(f); + gpr_log(GPR_INFO, "Passed simple request %d", i); + } + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ +void grpc_end2end_tests(grpc_end2end_test_config config) { int i; - for (i = 0; i < 10; i++) - { - test_invoke_simple_request (config); - } - test_invoke_10_simple_requests (config); + for (i = 0; i < 10; i++) { + test_invoke_simple_request(config); + } + test_invoke_10_simple_requests(config); } diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 28bcfadc8a..c040b9fac1 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -43,105 +43,84 @@ #include <grpc/support/useful.h> #include "test/core/end2end/cq_verifier.h" -enum -{ TIMEOUT = 200000 }; +enum { TIMEOUT = 200000 }; -static void * -tag (gpr_intptr t) -{ - return (void *) t; -} +static void *tag(gpr_intptr t) { return (void *)t; } -static grpc_end2end_test_fixture -begin_test (grpc_end2end_test_config config, const char *test_name, grpc_channel_args * client_args, grpc_channel_args * server_args) -{ +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { grpc_end2end_test_fixture f; - gpr_log (GPR_INFO, "%s/%s", test_name, config.name); - f = config.create_fixture (client_args, server_args); - config.init_client (&f, client_args); - config.init_server (&f, server_args); + gpr_log(GPR_INFO, "%s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_client(&f, client_args); + config.init_server(&f, server_args); return f; } -static gpr_timespec -n_seconds_time (int n) -{ - return GRPC_TIMEOUT_SECONDS_TO_DEADLINE (n); +static gpr_timespec n_seconds_time(int n) { + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); } -static gpr_timespec -five_seconds_time (void) -{ - return n_seconds_time (5); -} +static gpr_timespec five_seconds_time(void) { return n_seconds_time(5); } -static void -drain_cq (grpc_completion_queue * cq) -{ +static void drain_cq(grpc_completion_queue *cq) { grpc_event ev; - do - { - ev = grpc_completion_queue_next (cq, five_seconds_time (), NULL); - } - while (ev.type != GRPC_QUEUE_SHUTDOWN); + do { + ev = grpc_completion_queue_next(cq, five_seconds_time(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); } -static void -shutdown_server (grpc_end2end_test_fixture * f) -{ - if (!f->server) - return; - grpc_server_shutdown_and_notify (f->server, f->cq, tag (1000)); - GPR_ASSERT (grpc_completion_queue_pluck (f->cq, tag (1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE (5), NULL).type == GRPC_OP_COMPLETE); - grpc_server_destroy (f->server); +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck( + f->cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); f->server = NULL; } -static void -shutdown_client (grpc_end2end_test_fixture * f) -{ - if (!f->client) - return; - grpc_channel_destroy (f->client); +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); f->client = NULL; } -static void -end_test (grpc_end2end_test_fixture * f) -{ - shutdown_server (f); - shutdown_client (f); +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); - grpc_completion_queue_shutdown (f->cq); - drain_cq (f->cq); - grpc_completion_queue_destroy (f->cq); + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); } /* Request/response with metadata and payload.*/ -static void -test_request_response_with_metadata_and_payload (grpc_end2end_test_config config) -{ +static void test_request_response_with_metadata_and_payload( + grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string ("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string ("hello you"); - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create (&request_payload_slice, 1); - grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create (&response_payload_slice, 1); - gpr_timespec deadline = five_seconds_time (); + gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + gpr_timespec deadline = five_seconds_time(); grpc_metadata meta_c[2] = { - {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}} - }; + {"key1", "val1", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key2", "val2", 4, 0, {{NULL, NULL, NULL, NULL}}}}; grpc_metadata meta_s[2] = { - {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}} - }; + {"key3", "val3", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key4", "val4", 4, 0, {{NULL, NULL, NULL, NULL}}}}; grpc_metadata meta_t[2] = { - {"key5", "val5", 4, 0, {{NULL, NULL, NULL, NULL}}}, - {"key6", "val6", 4, 0, {{NULL, NULL, NULL, NULL}}} - }; - grpc_end2end_test_fixture f = begin_test (config, "test_request_response_with_metadata_and_payload", NULL, NULL); - cq_verifier *cqv = cq_verifier_create (f.cq); + {"key5", "val5", 4, 0, {{NULL, NULL, NULL, NULL}}}, + {"key6", "val6", 4, 0, {{NULL, NULL, NULL, NULL}}}}; + grpc_end2end_test_fixture f = begin_test( + config, "test_request_response_with_metadata_and_payload", NULL, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); grpc_op ops[6]; grpc_op *op; grpc_metadata_array initial_metadata_recv; @@ -156,13 +135,14 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call (f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr", deadline, NULL); - GPR_ASSERT (c); + c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + "/foo", "foo.test.google.fr", deadline, NULL); + GPR_ASSERT(c); - grpc_metadata_array_init (&initial_metadata_recv); - grpc_metadata_array_init (&trailing_metadata_recv); - grpc_metadata_array_init (&request_metadata_recv); - grpc_call_details_init (&call_details); + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -198,13 +178,15 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (c, ops, (size_t) (op - ops), tag (1), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - error = grpc_server_request_call (f.server, &s, &call_details, &request_metadata_recv, f.cq, f.cq, tag (101)); - GPR_ASSERT (GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (101), 1); - cq_verify (cqv); + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -218,11 +200,11 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (102), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (102), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(102), 1); + cq_verify(cqv); op = ops; op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; @@ -243,48 +225,46 @@ test_request_response_with_metadata_and_payload (grpc_end2end_test_config config op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch (s, ops, (size_t) (op - ops), tag (103), NULL); - GPR_ASSERT (GRPC_CALL_OK == error); + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); - cq_expect_completion (cqv, tag (103), 1); - cq_expect_completion (cqv, tag (1), 1); - cq_verify (cqv); + cq_expect_completion(cqv, tag(103), 1); + cq_expect_completion(cqv, tag(1), 1); + cq_verify(cqv); - GPR_ASSERT (status == GRPC_STATUS_OK); - GPR_ASSERT (0 == strcmp (details, "xyz")); - GPR_ASSERT (0 == strcmp (call_details.method, "/foo")); - GPR_ASSERT (0 == strcmp (call_details.host, "foo.test.google.fr")); - GPR_ASSERT (byte_buffer_eq_string (request_payload_recv, "hello world")); - GPR_ASSERT (byte_buffer_eq_string (response_payload_recv, "hello you")); - GPR_ASSERT (contains_metadata (&request_metadata_recv, "key1", "val1")); - GPR_ASSERT (contains_metadata (&request_metadata_recv, "key2", "val2")); - GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key3", "val3")); - GPR_ASSERT (contains_metadata (&initial_metadata_recv, "key4", "val4")); - GPR_ASSERT (contains_metadata (&trailing_metadata_recv, "key5", "val5")); - GPR_ASSERT (contains_metadata (&trailing_metadata_recv, "key6", "val6")); + GPR_ASSERT(status == GRPC_STATUS_OK); + GPR_ASSERT(0 == strcmp(details, "xyz")); + GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); + GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); + GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1")); + GPR_ASSERT(contains_metadata(&request_metadata_recv, "key2", "val2")); + GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key3", "val3")); + GPR_ASSERT(contains_metadata(&initial_metadata_recv, "key4", "val4")); + GPR_ASSERT(contains_metadata(&trailing_metadata_recv, "key5", "val5")); + GPR_ASSERT(contains_metadata(&trailing_metadata_recv, "key6", "val6")); - gpr_free (details); - grpc_metadata_array_destroy (&initial_metadata_recv); - grpc_metadata_array_destroy (&trailing_metadata_recv); - grpc_metadata_array_destroy (&request_metadata_recv); - grpc_call_details_destroy (&call_details); + gpr_free(details); + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); - grpc_call_destroy (c); - grpc_call_destroy (s); + grpc_call_destroy(c); + grpc_call_destroy(s); - cq_verifier_destroy (cqv); + cq_verifier_destroy(cqv); - grpc_byte_buffer_destroy (request_payload); - grpc_byte_buffer_destroy (response_payload); - grpc_byte_buffer_destroy (request_payload_recv); - grpc_byte_buffer_destroy (response_payload_recv); + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); - end_test (&f); - config.tear_down_data (&f); + end_test(&f); + config.tear_down_data(&f); } -void -grpc_end2end_tests (grpc_end2end_test_config config) -{ - test_request_response_with_metadata_and_payload (config); +void grpc_end2end_tests(grpc_end2end_test_config config) { + test_request_response_with_metadata_and_payload(config); } |