Fix lame client test

pull/1397/head
Craig Tiller 10 years ago
parent 72f7646358
commit 2365c7d467
  1. 35
      test/core/surface/lame_client_test.c

@ -42,30 +42,43 @@ static void *tag(gpr_intptr x) { return (void *)x; }
int main(int argc, char **argv) {
grpc_channel *chan;
grpc_call *call;
grpc_metadata md = {"a", "b", 1, {{NULL, NULL, NULL}}};
grpc_completion_queue *cq;
cq_verifier *cqv;
grpc_op ops[6];
grpc_op *op;
grpc_metadata_array trailing_metadata_recv;
grpc_status_code status;
char *details = NULL;
size_t details_capacity = 0;
grpc_test_init(argc, argv);
grpc_init();
grpc_metadata_array_init(&trailing_metadata_recv);
chan = grpc_lame_client_channel_create();
GPR_ASSERT(chan);
call = grpc_channel_create_call_old(chan, "/Foo", "anywhere",
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100));
GPR_ASSERT(call);
cq = grpc_completion_queue_create();
call = grpc_channel_create_call(chan, cq, "/Foo", "anywhere",
GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100));
GPR_ASSERT(call);
cqv = cq_verifier_create(cq);
/* we should be able to add metadata */
GPR_ASSERT(GRPC_CALL_OK == grpc_call_add_metadata_old(call, &md, 0));
/* and invoke the call */
GPR_ASSERT(GRPC_CALL_OK == grpc_call_invoke_old(call, cq, tag(2), tag(3), 0));
op = ops;
op->op = GRPC_OP_SEND_INITIAL_METADATA;
op->data.send_initial_metadata.count = 0;
op++;
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT;
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv;
op->data.recv_status_on_client.status = &status;
op->data.recv_status_on_client.status_details = &details;
op->data.recv_status_on_client.status_details_capacity = &details_capacity;
op++;
GPR_ASSERT(GRPC_CALL_OK ==
grpc_call_start_batch(call, ops, op - ops, tag(1)));
/* the call should immediately fail */
cq_expect_client_metadata_read(cqv, tag(2), NULL);
cq_expect_finished(cqv, tag(3), NULL);
cq_expect_completion(cqv, tag(1), GRPC_OP_OK);
cq_verify(cqv);
grpc_call_destroy(call);

Loading…
Cancel
Save