aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-01-23 08:08:45 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-01-23 08:08:45 -0800
commit3cc24a6d7f1352dce0d13d229ddb911114030aa6 (patch)
treee351a1da8a68297ad5a5a2148019de4961b5b5c5 /test/core
parent59963419c4a0448c10122bed4de0e4a1eac6c005 (diff)
parentac139dead15bf9cb8da75340c6fb93225a11ef7c (diff)
Merge github.com:google/grpc into javascript
Diffstat (limited to 'test/core')
-rw-r--r--test/core/end2end/cq_verifier.c12
-rw-r--r--test/core/iomgr/fd_posix_test.c25
-rw-r--r--test/core/iomgr/resolve_address_test.c5
-rw-r--r--test/core/iomgr/sockaddr_utils_test.c6
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c4
-rw-r--r--test/core/transport/transport_end2end_tests.c5
-rw-r--r--test/core/util/test_config.c2
7 files changed, 38 insertions, 21 deletions
diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c
index 9fa513126f..7a7f197907 100644
--- a/test/core/end2end/cq_verifier.c
+++ b/test/core/end2end/cq_verifier.c
@@ -56,8 +56,8 @@
typedef struct metadata {
size_t count;
size_t cap;
- const char **keys;
- const char **values;
+ char **keys;
+ char **values;
} metadata;
/* details what we expect to find on a single event - and forms a linked
@@ -409,11 +409,11 @@ static metadata *metadata_from_args(va_list args) {
if (md->cap == md->count) {
md->cap = GPR_MAX(md->cap + 1, md->cap * 3 / 2);
- md->keys = gpr_realloc(md->keys, sizeof(const char *) * md->cap);
- md->values = gpr_realloc(md->values, sizeof(const char *) * md->cap);
+ md->keys = gpr_realloc(md->keys, sizeof(char *) * md->cap);
+ md->values = gpr_realloc(md->values, sizeof(char *) * md->cap);
}
- md->keys[md->count] = key;
- md->values[md->count] = value;
+ md->keys[md->count] = (char *)key;
+ md->values[md->count] = (char *)value;
md->count++;
}
}
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index 136f34a8b0..05c91ffdd4 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -37,6 +37,7 @@
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
+#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -79,7 +80,7 @@ static void create_test_socket(int port, int *socket_fd,
/* Use local address for test */
sin->sin_family = AF_INET;
- sin->sin_addr.s_addr = 0;
+ sin->sin_addr.s_addr = htonl(0x7f000001);
sin->sin_port = htons(port);
}
@@ -164,7 +165,7 @@ static void session_read_cb(void *arg, /*session*/
grpc_fd_notify_on_read(se->em_fd, session_read_cb, se);
} else {
gpr_log(GPR_ERROR, "Unhandled read error %s", strerror(errno));
- GPR_ASSERT(0);
+ abort();
}
}
}
@@ -316,7 +317,7 @@ static void client_session_write(void *arg, /*client*/
gpr_mu_unlock(&cl->mu);
} else {
gpr_log(GPR_ERROR, "unknown errno %s", strerror(errno));
- GPR_ASSERT(0);
+ abort();
}
}
@@ -325,10 +326,20 @@ static void client_start(client *cl, int port) {
int fd;
struct sockaddr_in sin;
create_test_socket(port, &fd, &sin);
- if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1 &&
- errno != EINPROGRESS) {
- gpr_log(GPR_ERROR, "Failed to connect to the server");
- GPR_ASSERT(0);
+ if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
+ if (errno == EINPROGRESS) {
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = POLLOUT;
+ pfd.revents = 0;
+ if (poll(&pfd, 1, -1) == -1) {
+ gpr_log(GPR_ERROR, "poll() failed during connect; errno=%d", errno);
+ abort();
+ }
+ } else {
+ gpr_log(GPR_ERROR, "Failed to connect to the server (errno=%d)", errno);
+ abort();
+ }
}
cl->em_fd = grpc_fd_create(fd);
diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c
index 26a4bc67e6..319ee634d6 100644
--- a/test/core/iomgr/resolve_address_test.c
+++ b/test/core/iomgr/resolve_address_test.c
@@ -32,6 +32,7 @@
*/
#include "src/core/iomgr/resolve_address.h"
+#include "src/core/iomgr/iomgr.h"
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/time.h>
@@ -122,7 +123,7 @@ static void test_unparseable_hostports(void) {
int main(int argc, char** argv) {
grpc_test_init(argc, argv);
-
+ grpc_iomgr_init();
test_localhost();
test_default_port();
test_missing_default_port();
@@ -130,6 +131,6 @@ int main(int argc, char** argv) {
test_ipv6_without_port();
test_invalid_ip_addresses();
test_unparseable_hostports();
-
+ grpc_iomgr_shutdown();
return 0;
}
diff --git a/test/core/iomgr/sockaddr_utils_test.c b/test/core/iomgr/sockaddr_utils_test.c
index 14018ed66c..3e653da4c9 100644
--- a/test/core/iomgr/sockaddr_utils_test.c
+++ b/test/core/iomgr/sockaddr_utils_test.c
@@ -213,9 +213,9 @@ static void test_sockaddr_to_string(void) {
expect_sockaddr_str("[::fffe:c000:263]:12345", &input6, 1);
memset(&dummy, 0, sizeof(dummy));
- dummy.sa_family = 999;
- expect_sockaddr_str("(sockaddr family=999)", &dummy, 0);
- expect_sockaddr_str("(sockaddr family=999)", &dummy, 1);
+ dummy.sa_family = 123;
+ expect_sockaddr_str("(sockaddr family=123)", &dummy, 0);
+ expect_sockaddr_str("(sockaddr family=123)", &dummy, 1);
GPR_ASSERT(errno == 0xDEADBEEF);
}
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 79ba777e85..f9212e7373 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -40,6 +40,7 @@
#include <unistd.h>
#include "src/core/iomgr/iomgr.h"
+#include "src/core/iomgr/socket_utils_posix.h"
#include <grpc/support/log.h>
#include <grpc/support/time.h>
@@ -138,7 +139,8 @@ void test_times_out(void) {
/* tie up the listen buffer, which is somewhat arbitrarily sized. */
for (i = 0; i < NUM_CLIENT_CONNECTS; ++i) {
- client_fd[i] = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
+ client_fd[i] = socket(AF_INET, SOCK_STREAM, 0);
+ grpc_set_socket_nonblocking(client_fd[i], 1);
do {
r = connect(client_fd[i], (struct sockaddr *)&addr, addr_len);
} while (r == -1 && errno == EINTR);
diff --git a/test/core/transport/transport_end2end_tests.c b/test/core/transport/transport_end2end_tests.c
index 712081bc8a..5d26ef53b9 100644
--- a/test/core/transport/transport_end2end_tests.c
+++ b/test/core/transport/transport_end2end_tests.c
@@ -129,7 +129,8 @@ static void expect_metadata(test_stream *s, int from_client, const char *key,
/* Convert some number of seconds into a gpr_timespec that many seconds in the
future */
static gpr_timespec deadline_from_seconds(double deadline_seconds) {
- return gpr_time_add(gpr_now(), gpr_time_from_micros(deadline_seconds * 1e6));
+ return gpr_time_add(gpr_now(),
+ gpr_time_from_micros((long)(deadline_seconds * 1e6)));
}
/* Init a test_user_data instance */
@@ -573,7 +574,7 @@ static grpc_transport_setup_result setup_client_transport(
name - the name of this test */
static void begin_test(test_fixture *f, grpc_transport_test_config *config,
const char *name) {
- gpr_timespec timeout = gpr_time_add(gpr_now(), gpr_time_from_micros(100e6));
+ gpr_timespec timeout = gpr_time_add(gpr_now(), gpr_time_from_seconds(100));
gpr_log(GPR_INFO, "BEGIN: %s/%s", name, config->name);
diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c
index 6df86b593f..5f3b55da75 100644
--- a/test/core/util/test_config.c
+++ b/test/core/util/test_config.c
@@ -48,8 +48,10 @@ static int seed(void) { return _getpid(); }
#endif
void grpc_test_init(int argc, char **argv) {
+#ifndef GPR_WIN32
/* disable SIGPIPE */
signal(SIGPIPE, SIG_IGN);
+#endif
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
srand(seed());