add test for lame client transport op

pull/4410/head
yang-g 9 years ago
parent e73499782a
commit e682c3eea4
  1. 39
      test/core/surface/lame_client_test.c

@ -36,11 +36,47 @@
#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/channel/channel_stack.h"
#include "src/core/iomgr/closure.h"
#include "src/core/surface/channel.h"
#include "src/core/transport/transport.h"
#include "test/core/end2end/cq_verifier.h"
#include "test/core/util/test_config.h"
grpc_closure transport_op_cb;
static void *tag(gpr_intptr x) { return (void *)x; }
void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg, int success) {
grpc_transport_op* op = arg;
GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE == *op->connectivity_state);
GPR_ASSERT(success);
}
void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, int success) { }
void test_transport_op(grpc_channel *channel) {
grpc_transport_op op;
grpc_channel_element *elem;
grpc_connectivity_state state = GRPC_CHANNEL_IDLE;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
memset(&op, 0, sizeof(op));
grpc_closure_init(&transport_op_cb, verify_connectivity, &op);
op.on_connectivity_state_change = &transport_op_cb;
op.connectivity_state = &state;
elem = grpc_channel_stack_element(grpc_channel_get_channel_stack(channel), 0);
elem->filter->start_transport_op(&exec_ctx, elem, &op);
grpc_exec_ctx_finish(&exec_ctx);
memset(&op, 0, sizeof(op));
grpc_closure_init(&transport_op_cb, do_nothing, NULL);
op.on_consumed = &transport_op_cb;
elem->filter->start_transport_op(&exec_ctx, elem, &op);
grpc_exec_ctx_finish(&exec_ctx);
}
int main(int argc, char **argv) {
grpc_channel *chan;
grpc_call *call;
@ -65,6 +101,9 @@ int main(int argc, char **argv) {
chan = grpc_lame_client_channel_create(
"lampoon:national", GRPC_STATUS_UNKNOWN, "Rpc sent on a lame channel.");
GPR_ASSERT(chan);
test_transport_op(chan);
cq = grpc_completion_queue_create(NULL);
call = grpc_channel_create_call(chan, NULL, GRPC_PROPAGATE_DEFAULTS, cq,

Loading…
Cancel
Save