aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/fling/client.c2
-rw-r--r--test/core/iomgr/endpoint_tests.c6
-rw-r--r--test/core/iomgr/fd_posix_test.c3
-rw-r--r--test/core/iomgr/tcp_posix_test.c10
-rw-r--r--test/core/iomgr/udp_server_test.c2
-rw-r--r--test/core/json/json_rewrite.c6
-rw-r--r--test/core/json/json_rewrite_test.c3
-rw-r--r--test/core/support/slice_test.c6
-rw-r--r--test/core/transport/chttp2/stream_encoder_test.c8
-rw-r--r--test/core/util/parse_hexstring.c4
-rw-r--r--test/core/util/port_posix.c2
-rw-r--r--test/core/util/reconnect_server.c2
-rw-r--r--test/core/util/test_config.h18
13 files changed, 39 insertions, 33 deletions
diff --git a/test/core/fling/client.c b/test/core/fling/client.c
index ed80544e3c..a53411c2f5 100644
--- a/test/core/fling/client.c
+++ b/test/core/fling/client.c
@@ -130,7 +130,7 @@ static void step_ping_pong_stream(void) {
static double now(void) {
gpr_timespec tv = gpr_now(GPR_CLOCK_REALTIME);
- return 1e9 * tv.tv_sec + tv.tv_nsec;
+ return 1e9 * (double)tv.tv_sec + tv.tv_nsec;
}
typedef struct {
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index 27123eb216..853b9a32c2 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -86,7 +86,7 @@ static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config,
static void end_test(grpc_endpoint_test_config config) { config.clean_up(); }
static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
- size_t *num_blocks, int *current_data) {
+ size_t *num_blocks, gpr_uint8 *current_data) {
size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0);
gpr_slice *slices = malloc(sizeof(gpr_slice) * nslices);
size_t num_bytes_left = num_bytes;
@@ -102,7 +102,7 @@ static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
buf = GPR_SLICE_START_PTR(slices[i]);
for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) {
buf[j] = *current_data;
- *current_data = (*current_data + 1) % 256;
+ (*current_data)++;
}
}
GPR_ASSERT(num_bytes_left == 0);
@@ -117,7 +117,7 @@ struct read_and_write_test_state {
size_t current_write_size;
size_t bytes_written;
int current_read_data;
- int current_write_data;
+ gpr_uint8 current_write_data;
int read_done;
int write_done;
gpr_slice_buffer incoming;
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index af66ef0997..75959069c0 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -83,7 +83,8 @@ 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 = htonl(0x7f000001);
- sin->sin_port = htons(port);
+ GPR_ASSERT(port >= 0 && port < 65536);
+ sin->sin_port = htons((gpr_uint16)port);
}
/* Dummy gRPC callback */
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index b94f5987ca..59c498edff 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -81,7 +81,7 @@ static ssize_t fill_socket(int fd) {
int i;
unsigned char buf[256];
for (i = 0; i < 256; ++i) {
- buf[i] = i;
+ buf[i] = (gpr_uint8)i;
}
do {
write_bytes = write(fd, buf, 256);
@@ -99,7 +99,7 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
unsigned char *buf = malloc(bytes);
unsigned i;
for (i = 0; i < bytes; ++i) {
- buf[i] = i % 256;
+ buf[i] = (gpr_uint8)(i % 256);
}
do {
@@ -276,7 +276,7 @@ struct write_socket_state {
};
static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
- size_t *num_blocks, int *current_data) {
+ size_t *num_blocks, gpr_uint8 *current_data) {
size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u);
gpr_slice *slices = gpr_malloc(sizeof(gpr_slice) * nslices);
size_t num_bytes_left = num_bytes;
@@ -291,7 +291,7 @@ static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
buf = GPR_SLICE_START_PTR(slices[i]);
for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) {
buf[j] = *current_data;
- *current_data = (*current_data + 1) % 256;
+ (*current_data)++;
}
}
GPR_ASSERT(num_bytes_left == 0);
@@ -373,7 +373,7 @@ static void write_test(size_t num_bytes, size_t slice_size) {
ssize_t read_bytes;
size_t num_blocks;
gpr_slice *slices;
- int current_data = 0;
+ gpr_uint8 current_data = 0;
gpr_slice_buffer outgoing;
grpc_iomgr_closure write_done_closure;
gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20);
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 8c964246c7..c4f1896ba6 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -59,7 +59,7 @@ static void on_read(int fd, grpc_udp_server_cb new_transport_cb, void *cb_arg) {
byte_count = recv(fd, read_buffer, sizeof(read_buffer), 0);
g_number_of_reads++;
- g_number_of_bytes_read += byte_count;
+ g_number_of_bytes_read += (int)byte_count;
grpc_pollset_kick(&g_pollset, NULL);
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c
index 561bf487b9..82cc4090f3 100644
--- a/test/core/json/json_rewrite.c
+++ b/test/core/json/json_rewrite.c
@@ -34,8 +34,9 @@
#include <stdio.h>
#include <stdlib.h>
-#include <grpc/support/cmdline.h>
#include <grpc/support/alloc.h>
+#include <grpc/support/cmdline.h>
+#include <grpc/support/log.h>
#include "src/core/json/json_reader.h"
#include "src/core/json/json_writer.h"
@@ -96,7 +97,8 @@ static void json_reader_string_clear(void* userdata) {
static void json_reader_string_add_char(void* userdata, gpr_uint32 c) {
json_reader_userdata* state = userdata;
check_string(state, 1);
- state->scratchpad[state->string_len++] = c;
+ GPR_ASSERT(c < 256);
+ state->scratchpad[state->string_len++] = (char)c;
}
static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.c
index 7cf184950e..d26ef53b2d 100644
--- a/test/core/json/json_rewrite_test.c
+++ b/test/core/json/json_rewrite_test.c
@@ -108,7 +108,8 @@ static void json_reader_string_clear(void* userdata) {
static void json_reader_string_add_char(void* userdata, gpr_uint32 c) {
json_reader_userdata* state = userdata;
check_string(state, 1);
- state->scratchpad[state->string_len++] = c;
+ GPR_ASSERT(c <= 256);
+ state->scratchpad[state->string_len++] = (char)c;
}
static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c
index a84ad50cf3..1d202f0618 100644
--- a/test/core/support/slice_test.c
+++ b/test/core/support/slice_test.c
@@ -116,7 +116,7 @@ static void test_slice_sub_works(unsigned length) {
beginning of the slice. */
slice = gpr_slice_malloc(length);
for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = i;
+ GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i;
}
/* Ensure that for all subsets length is correct and that we start on the
@@ -155,7 +155,7 @@ static void test_slice_split_head_works(size_t length) {
beginning of the slice. */
slice = gpr_slice_malloc(length);
for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = i;
+ GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i;
}
/* Ensure that for all subsets length is correct and that we start on the
@@ -183,7 +183,7 @@ static void test_slice_split_tail_works(size_t length) {
beginning of the slice. */
slice = gpr_slice_malloc(length);
for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = i;
+ GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i;
}
/* Ensure that for all subsets length is correct and that we start on the
diff --git a/test/core/transport/chttp2/stream_encoder_test.c b/test/core/transport/chttp2/stream_encoder_test.c
index a723b90084..71db98c69e 100644
--- a/test/core/transport/chttp2/stream_encoder_test.c
+++ b/test/core/transport/chttp2/stream_encoder_test.c
@@ -59,7 +59,7 @@ static gpr_slice create_test_slice(size_t length) {
gpr_slice slice = gpr_slice_malloc(length);
size_t i;
for (i = 0; i < length; i++) {
- GPR_SLICE_START_PTR(slice)[i] = i;
+ GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i;
}
return slice;
}
@@ -196,10 +196,10 @@ static void test_basic_headers(void) {
}
static void encode_int_to_str(int i, char *p) {
- p[0] = 'a' + i % 26;
+ p[0] = (char)('a' + i % 26);
i /= 26;
GPR_ASSERT(i < 26);
- p[1] = 'a' + i;
+ p[1] = (char)('a' + i);
p[2] = 0;
}
@@ -246,7 +246,7 @@ static void randstr(char *p, int bufsz) {
int i;
int len = 1 + rand() % bufsz;
for (i = 0; i < len; i++) {
- p[i] = 'a' + rand() % 26;
+ p[i] = (char)('a' + rand() % 26);
}
p[len] = 0;
}
diff --git a/test/core/util/parse_hexstring.c b/test/core/util/parse_hexstring.c
index 0bac8fef32..eced3173d1 100644
--- a/test/core/util/parse_hexstring.c
+++ b/test/core/util/parse_hexstring.c
@@ -54,10 +54,10 @@ gpr_slice parse_hexstring(const char *hexstring) {
temp = 0;
for (p = hexstring; *p; p++) {
if (*p >= '0' && *p <= '9') {
- temp = (temp << 4) | (*p - '0');
+ temp = (gpr_uint8)(temp << 4) | (gpr_uint8)(*p - '0');
nibbles++;
} else if (*p >= 'a' && *p <= 'f') {
- temp = (temp << 4) | (*p - 'a' + 10);
+ temp = (gpr_uint8)(temp << 4) | (gpr_uint8)(*p - 'a' + 10);
nibbles++;
}
if (nibbles == 2) {
diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c
index 4781d334e2..be45bae496 100644
--- a/test/core/util/port_posix.c
+++ b/test/core/util/port_posix.c
@@ -102,7 +102,7 @@ static int is_port_available(int *port, int is_tcp) {
/* Try binding to port */
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
- addr.sin_port = htons(*port);
+ addr.sin_port = htons((gpr_uint16)*port);
if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
gpr_log(GPR_DEBUG, "bind(port=%d) failed: %s", *port, strerror(errno));
close(fd);
diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c
index aa7f77eadf..71fb69b54f 100644
--- a/test/core/util/reconnect_server.c
+++ b/test/core/util/reconnect_server.c
@@ -116,7 +116,7 @@ void reconnect_server_start(reconnect_server *server, int port) {
int port_added;
addr.sin_family = AF_INET;
- addr.sin_port = htons(port);
+ addr.sin_port = htons((gpr_uint16)port);
memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
server->tcp_server = grpc_tcp_server_create();
diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h
index ccef8620c1..15b71747fb 100644
--- a/test/core/util/test_config.h
+++ b/test/core/util/test_config.h
@@ -54,15 +54,17 @@ extern double g_fixture_slowdown_factor;
(GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR * \
g_fixture_slowdown_factor)
-#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), \
- gpr_time_from_millis(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x), \
- GPR_TIMESPAN))
+#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
+ gpr_time_add( \
+ gpr_now(GPR_CLOCK_MONOTONIC), \
+ gpr_time_from_millis((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \
+ GPR_TIMESPAN))
-#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
- gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), \
- gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x), \
- GPR_TIMESPAN))
+#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
+ gpr_time_add( \
+ gpr_now(GPR_CLOCK_MONOTONIC), \
+ gpr_time_from_micros((long)(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)), \
+ GPR_TIMESPAN))
#ifndef GRPC_TEST_CUSTOM_PICK_PORT
#define GRPC_TEST_PICK_PORT