Connectivity check

pull/6160/head
Craig Tiller 9 years ago
parent 99f67d1a08
commit e62826125b
  1. 23
      src/core/lib/iomgr/tcp_client_posix.c
  2. 28
      test/core/end2end/fuzzers/api_fuzzer.c

@ -211,11 +211,11 @@ finish:
grpc_exec_ctx_enqueue(exec_ctx, closure, *ep != NULL, NULL);
}
void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
grpc_endpoint **ep,
static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties,
const struct sockaddr *addr, size_t addr_len,
gpr_timespec deadline) {
const struct sockaddr *addr,
size_t addr_len, gpr_timespec deadline) {
int fd;
grpc_dualstack_mode dsmode;
int err;
@ -303,4 +303,19 @@ done:
gpr_free(addr_str);
}
// overridden by api_fuzzer.c
void (*grpc_tcp_client_connect_impl)(
grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, const struct sockaddr *addr,
size_t addr_len, gpr_timespec deadline) = tcp_client_connect_impl;
void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
grpc_endpoint **ep,
grpc_pollset_set *interested_parties,
const struct sockaddr *addr, size_t addr_len,
gpr_timespec deadline) {
grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, addr,
addr_len, deadline);
}
#endif

@ -40,6 +40,7 @@
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/transport/metadata.h"
#include "test/core/util/mock_endpoint.h"
@ -172,10 +173,21 @@ static grpc_resolved_addresses *my_resolve_address(const char *name,
}
////////////////////////////////////////////////////////////////////////////////
// test state
typedef struct { grpc_channel *channel; } channel_state;
typedef struct { grpc_server *server; } server_state;
// client connection
// defined in tcp_client_posix.c
extern void (*grpc_tcp_client_connect_impl)(
grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, const struct sockaddr *addr,
size_t addr_len, gpr_timespec deadline);
static void my_tcp_client_connect(grpc_exec_ctx *exec_ctx,
grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties,
const struct sockaddr *addr, size_t addr_len,
gpr_timespec deadline) {
abort();
}
////////////////////////////////////////////////////////////////////////////////
// test driver
@ -191,6 +203,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (squelch) gpr_set_log_function(dont_log);
input_stream inp = {data, data + size};
grpc_blocking_resolve_address = my_resolve_address;
grpc_tcp_client_connect_impl = my_tcp_client_connect;
gpr_mu_init(&g_mu);
gpr_cv_init(&g_cv);
gpr_now_impl = now_impl;
@ -319,6 +332,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
}
break;
}
// check connectivity
case 8: {
if (channel != NULL) {
grpc_channel_check_connectivity_state(channel, next_byte(&inp) > 127);
}
break;
}
}
}

Loading…
Cancel
Save