diff options
Diffstat (limited to 'test/core/end2end/cq_verifier.c')
-rw-r--r-- | test/core/end2end/cq_verifier.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 904ed77283..de65ef317d 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -70,7 +70,7 @@ typedef struct expectation { union { grpc_op_error finish_accepted; grpc_op_error write_accepted; - grpc_op_error ioreq; + grpc_op_error op_complete; struct { const char *method; const char *host; @@ -123,6 +123,10 @@ static int has_metadata(const grpc_metadata *md, size_t count, const char *key, return 0; } +int contains_metadata(grpc_metadata_array *array, const char *key, const char *value) { + return has_metadata(array->metadata, array->count, key, value); +} + static void verify_and_destroy_metadata(metadata *md, grpc_metadata *elems, size_t count) { size_t i; @@ -166,6 +170,10 @@ static int byte_buffer_eq_slice(grpc_byte_buffer *bb, gpr_slice b) { return ok; } +int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) { + return byte_buffer_eq_slice(bb, gpr_slice_from_copied_string(str)); +} + static int string_equivalent(const char *a, const char *b) { if (a == NULL) return b == NULL || b[0] == 0; if (b == NULL) return a[0] == 0; @@ -220,8 +228,8 @@ static void verify_matches(expectation *e, grpc_event *ev) { GPR_ASSERT(ev->data.read == NULL); } break; - case GRPC_IOREQ: - GPR_ASSERT(e->data.ioreq == ev->data.ioreq); + case GRPC_OP_COMPLETE: + GPR_ASSERT(e->data.op_complete == ev->data.op_complete); break; case GRPC_SERVER_SHUTDOWN: break; @@ -256,23 +264,23 @@ static void expectation_to_strvec(gpr_strvec *buf, expectation *e) { switch (e->type) { case GRPC_FINISH_ACCEPTED: gpr_asprintf(&tmp, "GRPC_FINISH_ACCEPTED result=%d", - e->data.finish_accepted); + e->data.finish_accepted); gpr_strvec_add(buf, tmp); break; case GRPC_WRITE_ACCEPTED: gpr_asprintf(&tmp, "GRPC_WRITE_ACCEPTED result=%d", - e->data.write_accepted); + e->data.write_accepted); gpr_strvec_add(buf, tmp); break; - case GRPC_IOREQ: - gpr_asprintf(&tmp, "GRPC_IOREQ result=%d", e->data.ioreq); + case GRPC_OP_COMPLETE: + gpr_asprintf(&tmp, "GRPC_OP_COMPLETE result=%d", e->data.op_complete); gpr_strvec_add(buf, tmp); break; case GRPC_SERVER_RPC_NEW: timeout = gpr_time_sub(e->data.server_rpc_new.deadline, gpr_now()); gpr_asprintf(&tmp, "GRPC_SERVER_RPC_NEW method=%s host=%s timeout=%fsec", - e->data.server_rpc_new.method, e->data.server_rpc_new.host, - timeout.tv_sec + 1e-9 * timeout.tv_nsec); + e->data.server_rpc_new.method, e->data.server_rpc_new.host, + timeout.tv_sec + 1e-9 * timeout.tv_nsec); gpr_strvec_add(buf, tmp); break; case GRPC_CLIENT_METADATA_READ: @@ -281,14 +289,16 @@ static void expectation_to_strvec(gpr_strvec *buf, expectation *e) { break; case GRPC_FINISHED: gpr_asprintf(&tmp, "GRPC_FINISHED status=%d details=%s ", - e->data.finished.status, e->data.finished.details); + e->data.finished.status, e->data.finished.details); gpr_strvec_add(buf, tmp); metadata_expectation(buf, e->data.finished.metadata); break; case GRPC_READ: gpr_strvec_add(buf, gpr_strdup("GRPC_READ data=")); - gpr_strvec_add(buf, gpr_hexdump((char *)GPR_SLICE_START_PTR(*e->data.read), - GPR_SLICE_LENGTH(*e->data.read), GPR_HEXDUMP_PLAINTEXT)); + gpr_strvec_add( + buf, + gpr_hexdump((char *)GPR_SLICE_START_PTR(*e->data.read), + GPR_SLICE_LENGTH(*e->data.read), GPR_HEXDUMP_PLAINTEXT)); break; case GRPC_SERVER_SHUTDOWN: gpr_strvec_add(buf, gpr_strdup("GRPC_SERVER_SHUTDOWN")); @@ -422,6 +432,10 @@ void cq_expect_write_accepted(cq_verifier *v, void *tag, grpc_op_error result) { add(v, GRPC_WRITE_ACCEPTED, tag)->data.write_accepted = result; } +void cq_expect_completion(cq_verifier *v, void *tag, grpc_op_error result) { + add(v, GRPC_OP_COMPLETE, tag)->data.op_complete = result; +} + void cq_expect_finish_accepted(cq_verifier *v, void *tag, grpc_op_error result) { add(v, GRPC_FINISH_ACCEPTED, tag)->data.finish_accepted = result; |