aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/end2end/cq_verifier_native.c5
-rw-r--r--test/core/end2end/cq_verifier_uv.c11
-rw-r--r--test/core/end2end/dualstack_socket_test.c4
-rw-r--r--test/core/end2end/fake_resolver.c5
-rw-r--r--test/core/end2end/fixtures/h2_fd.c4
-rw-r--r--test/core/end2end/fixtures/h2_full+pipe.c4
-rw-r--r--test/core/end2end/fixtures/h2_full+trace.c6
-rw-r--r--test/core/end2end/fixtures/h2_sockpair+trace.c6
-rw-r--r--test/core/iomgr/fd_posix_test.c4
-rw-r--r--test/core/iomgr/socket_utils_test.c4
-rw-r--r--test/core/iomgr/tcp_posix_test.c4
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c4
-rw-r--r--test/core/iomgr/timer_heap_test.c4
-rw-r--r--test/core/iomgr/udp_server_test.c50
-rw-r--r--test/core/util/port_uv.c4
15 files changed, 63 insertions, 56 deletions
diff --git a/test/core/end2end/cq_verifier_native.c b/test/core/end2end/cq_verifier_native.c
index fa9a87d6e4..b1fcb4beed 100644
--- a/test/core/end2end/cq_verifier_native.c
+++ b/test/core/end2end/cq_verifier_native.c
@@ -48,7 +48,7 @@ struct cq_verifier {
cq_verifier *cq_verifier_create(grpc_completion_queue *cq) {
cq_verifier *v = gpr_malloc(sizeof(cq_verifier));
v->cq = cq;
- cq_verifier_set_first_expectation(v,NULL);
+ cq_verifier_set_first_expectation(v, NULL);
return v;
}
@@ -66,7 +66,8 @@ void cq_verifier_set_first_expectation(cq_verifier *v, expectation *e) {
}
grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) {
- const gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(timeout_seconds);
+ const gpr_timespec deadline =
+ GRPC_TIMEOUT_SECONDS_TO_DEADLINE(timeout_seconds);
return grpc_completion_queue_next(v->cq, deadline, NULL);
}
diff --git a/test/core/end2end/cq_verifier_uv.c b/test/core/end2end/cq_verifier_uv.c
index 74ac673f20..2b5a2ca495 100644
--- a/test/core/end2end/cq_verifier_uv.c
+++ b/test/core/end2end/cq_verifier_uv.c
@@ -92,16 +92,19 @@ static void timer_run_cb(uv_timer_t *timer) {
}
grpc_event cq_verifier_next_event(cq_verifier *v, int timeout_seconds) {
- uint64_t timeout_ms = timeout_seconds < 0 ? 0 : (uint64_t)timeout_seconds * 1000;
+ uint64_t timeout_ms =
+ timeout_seconds < 0 ? 0 : (uint64_t)timeout_seconds * 1000;
grpc_event ev;
v->timer.data = (void *)TIMER_STARTED;
uv_timer_start(&v->timer, timer_run_cb, timeout_ms, 0);
- ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC), NULL);
+ ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC),
+ NULL);
// Stop the loop if the timer goes off or we get a non-timeout event
while (((timer_state)v->timer.data != TIMER_TRIGGERED) &&
- ev.type == GRPC_QUEUE_TIMEOUT){
+ ev.type == GRPC_QUEUE_TIMEOUT) {
uv_run(uv_default_loop(), UV_RUN_ONCE);
- ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC), NULL);
+ ev = grpc_completion_queue_next(v->cq, gpr_inf_past(GPR_CLOCK_MONOTONIC),
+ NULL);
}
return ev;
}
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c
index 3fb25360fe..f427202a7b 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.c
@@ -361,8 +361,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/end2end/fake_resolver.c b/test/core/end2end/fake_resolver.c
index 8a6624a49a..350cd4a36b 100644
--- a/test/core/end2end/fake_resolver.c
+++ b/test/core/end2end/fake_resolver.c
@@ -165,10 +165,7 @@ static grpc_resolver* fake_resolver_create(grpc_resolver_factory* factory,
grpc_uri ith_uri = *args->uri;
char* part_str = gpr_dump_slice(path_parts.slices[i], GPR_DUMP_ASCII);
ith_uri.path = part_str;
- if (!parse_ipv4(
- &ith_uri,
- (struct sockaddr_storage*)(&addresses->addresses[i].address.addr),
- &addresses->addresses[i].address.len)) {
+ if (!parse_ipv4(&ith_uri, &addresses->addresses[i].address)) {
errors_found = true;
}
gpr_free(part_str);
diff --git a/test/core/end2end/fixtures/h2_fd.c b/test/core/end2end/fixtures/h2_fd.c
index 0eaf042aa2..e9fd6668ed 100644
--- a/test/core/end2end/fixtures/h2_fd.c
+++ b/test/core/end2end/fixtures/h2_fd.c
@@ -134,8 +134,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c
index 11619b099e..0a9a5f4dd3 100644
--- a/test/core/end2end/fixtures/h2_full+pipe.c
+++ b/test/core/end2end/fixtures/h2_full+pipe.c
@@ -127,8 +127,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_WAKEUP_FD */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_POSIX_WAKEUP_FD */
diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c
index e25b5e3347..78a33c7e9a 100644
--- a/test/core/end2end/fixtures/h2_full+trace.c
+++ b/test/core/end2end/fixtures/h2_full+trace.c
@@ -31,9 +31,14 @@
*
*/
+#include "src/core/lib/iomgr/port.h"
+
#include "test/core/end2end/end2end_tests.h"
#include <string.h>
+#ifdef GRPC_POSIX_SOCKET
+#include <unistd.h>
+#endif
#include <grpc/support/alloc.h>
#include <grpc/support/host_port.h>
@@ -45,7 +50,6 @@
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h"
#include "src/core/lib/channel/connected_channel.h"
#include "src/core/lib/channel/http_server_filter.h"
-#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/support/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/server.h"
diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c
index d0925e5109..4f3fbf22bf 100644
--- a/test/core/end2end/fixtures/h2_sockpair+trace.c
+++ b/test/core/end2end/fixtures/h2_sockpair+trace.c
@@ -31,9 +31,14 @@
*
*/
+#include "src/core/lib/iomgr/port.h"
+
#include "test/core/end2end/end2end_tests.h"
#include <string.h>
+#ifdef GRPC_POSIX_SOCKET
+#include <unistd.h>
+#endif
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
@@ -48,7 +53,6 @@
#include "src/core/lib/channel/http_server_filter.h"
#include "src/core/lib/iomgr/endpoint_pair.h"
#include "src/core/lib/iomgr/iomgr.h"
-#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/support/env.h"
#include "src/core/lib/surface/channel.h"
#include "src/core/lib/surface/completion_queue.h"
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index bf6d5377a6..6166699fe6 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -556,8 +556,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/socket_utils_test.c b/test/core/iomgr/socket_utils_test.c
index bb789e4c5a..67bc914c15 100644
--- a/test/core/iomgr/socket_utils_test.c
+++ b/test/core/iomgr/socket_utils_test.c
@@ -75,8 +75,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 495e648090..d998958744 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -552,8 +552,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index d1c0af55fe..e246816435 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -368,8 +368,6 @@ int main(int argc, char **argv) {
#else /* GRPC_POSIX_SOCKET */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/iomgr/timer_heap_test.c b/test/core/iomgr/timer_heap_test.c
index a68988df77..410d972313 100644
--- a/test/core/iomgr/timer_heap_test.c
+++ b/test/core/iomgr/timer_heap_test.c
@@ -323,8 +323,6 @@ int main(int argc, char **argv) {
#else /* GRPC_TIMER_USE_GENERIC */
-int main(int argc, char **argv) {
- return 1;
-}
+int main(int argc, char **argv) { return 1; }
#endif /* GRPC_TIMER_USE_GENERIC */
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 2a30427504..ac92f53f51 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -31,6 +31,11 @@
*
*/
+#include "src/core/lib/iomgr/port.h"
+
+// This test won't work except with posix sockets enabled
+#ifdef GRPC_POSIX_SOCKET
+
#include "src/core/lib/iomgr/udp_server.h"
#include <netinet/in.h>
@@ -98,13 +103,15 @@ static void test_no_op_with_start(void) {
static void test_no_op_with_port(void) {
g_number_of_orphan_calls = 0;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- struct sockaddr_in addr;
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
grpc_udp_server *s = grpc_udp_server_create();
LOG_TEST("test_no_op_with_port");
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, (struct sockaddr *)&addr, sizeof(addr),
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr,
on_read, on_fd_orphaned));
grpc_udp_server_destroy(&exec_ctx, s, NULL);
@@ -117,13 +124,15 @@ static void test_no_op_with_port(void) {
static void test_no_op_with_port_and_start(void) {
g_number_of_orphan_calls = 0;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- struct sockaddr_in addr;
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr;
grpc_udp_server *s = grpc_udp_server_create();
LOG_TEST("test_no_op_with_port_and_start");
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, (struct sockaddr *)&addr, sizeof(addr),
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = sizeof(struct sockaddr_in);
+ addr->sin_family = AF_INET;
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr,
on_read, on_fd_orphaned));
grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL);
@@ -137,8 +146,8 @@ static void test_no_op_with_port_and_start(void) {
static void test_receive(int number_of_clients) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- struct sockaddr_storage addr;
- socklen_t addr_len = sizeof(addr);
+ grpc_resolved_address resolved_addr;
+ struct sockaddr_storage *addr = (struct sockaddr_storage *)resolved_addr.addr;
int clifd, svrfd;
grpc_udp_server *s = grpc_udp_server_create();
int i;
@@ -151,15 +160,16 @@ static void test_receive(int number_of_clients) {
g_number_of_bytes_read = 0;
g_number_of_orphan_calls = 0;
- memset(&addr, 0, sizeof(addr));
- addr.ss_family = AF_INET;
- GPR_ASSERT(grpc_udp_server_add_port(s, (struct sockaddr *)&addr, addr_len,
+ memset(&resolved_addr, 0, sizeof(resolved_addr));
+ resolved_addr.len = sizeof(struct sockaddr_storage);
+ addr->ss_family = AF_INET;
+ GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr,
on_read, on_fd_orphaned));
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));
+ GPR_ASSERT(getsockname(svrfd, (struct sockaddr *)addr, (socklen_t *)&resolved_addr.len) == 0);
+ GPR_ASSERT(resolved_addr.len <= sizeof(struct sockaddr_storage));
pollsets[0] = g_pollset;
grpc_udp_server_start(&exec_ctx, s, pollsets, 1, NULL);
@@ -171,9 +181,9 @@ static void test_receive(int number_of_clients) {
number_of_reads_before = g_number_of_reads;
/* Create a socket, send a packet to the UDP server. */
- clifd = socket(addr.ss_family, SOCK_DGRAM, 0);
+ clifd = socket(addr->ss_family, SOCK_DGRAM, 0);
GPR_ASSERT(clifd >= 0);
- GPR_ASSERT(connect(clifd, (struct sockaddr *)&addr, addr_len) == 0);
+ GPR_ASSERT(connect(clifd, (struct sockaddr *)&addr, (socklen_t)resolved_addr.len) == 0);
GPR_ASSERT(5 == write(clifd, "hello", 5));
while (g_number_of_reads == number_of_reads_before &&
gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
@@ -227,3 +237,9 @@ int main(int argc, char **argv) {
grpc_iomgr_shutdown();
return 0;
}
+
+#else /* GRPC_POSIX_SOCKET */
+
+int main(int argc, char **argv) { return 1; }
+
+#endif /* GRPC_POSIX_SOCKET */
diff --git a/test/core/util/port_uv.c b/test/core/util/port_uv.c
index cab31b3f4e..0c9c0d87d6 100644
--- a/test/core/util/port_uv.c
+++ b/test/core/util/port_uv.c
@@ -112,8 +112,6 @@ int grpc_pick_unused_port_or_die(void) {
return port;
}
-void grpc_recycle_unused_port(int port) {
- GPR_ASSERT(free_chosen_port(port));
-}
+void grpc_recycle_unused_port(int port) { GPR_ASSERT(free_chosen_port(port)); }
#endif /* GRPC_UV && GRPC_TEST_PICK_PORT */