aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Robbie Shade <rjshade@google.com>2015-08-04 19:20:41 -0400
committerGravatar Robbie Shade <rjshade@google.com>2015-08-04 19:20:41 -0400
commitaeb386ce7bd7e9a3d3b31a86ce0454c3a6ff78e4 (patch)
tree6064cbcaa00b1be087fdadb27de5d8a8359a6c59
parent3d4fc4abfe510d51ce477309f98412b8119bcaf6 (diff)
Ensure connect happens to server address
-rw-r--r--test/core/iomgr/udp_server_test.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index ee7ef038f2..192f754bbc 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -101,7 +101,7 @@ static void test_no_op_with_port_and_start(void) {
static void test_receive(int n) {
struct sockaddr_storage addr;
socklen_t addr_len = sizeof(addr);
- int clifd;
+ int clifd, svrfd;
grpc_udp_server *s = grpc_udp_server_create();
int i;
int number_of_reads_before;
@@ -114,6 +114,11 @@ static void test_receive(int n) {
addr.ss_family = AF_INET;
GPR_ASSERT(grpc_udp_server_add_port(s, (struct sockaddr *)&addr, addr_len, on_read));
+ svrfd = grpc_udp_server_get_fd(s, 0);
+ GPR_ASSERT(svrfd >= 0);
+ GPR_ASSERT(getsockname(svrfd, (struct sockaddr *)&addr, &addr_len) == 0);
+ GPR_ASSERT(addr_len <= sizeof(addr));
+
pollsets[0] = &g_pollset;
grpc_udp_server_start(s, pollsets, 1, on_connect, NULL);
@@ -127,7 +132,7 @@ static void test_receive(int n) {
clifd = socket(addr.ss_family, SOCK_DGRAM, 0);
GPR_ASSERT(clifd >= 0);
GPR_ASSERT(connect(clifd, (struct sockaddr *)&addr, addr_len) == 0);
- GPR_ASSERT(write(clifd, "hello", 5));
+ GPR_ASSERT(5 == write(clifd, "hello", 5));
while (g_number_of_reads == number_of_reads_before &&
gpr_time_cmp(deadline, gpr_now()) > 0) {
grpc_pollset_work(&g_pollset, deadline);