diff options
Diffstat (limited to 'test')
130 files changed, 1466 insertions, 487 deletions
diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index e1a4b8ed90..832570a81d 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -49,13 +49,14 @@ typedef struct { grpc_server *server; grpc_completion_queue *cq; grpc_bad_client_server_side_validator validator; + void *registered_method; gpr_event done_thd; gpr_event done_write; } thd_args; static void thd_func(void *arg) { thd_args *a = arg; - a->validator(a->server, a->cq); + a->validator(a->server, a->cq, a->registered_method); gpr_event_set(&a->done_thd, (void *)1); } @@ -77,7 +78,7 @@ static void server_setup_transport(void *ts, grpc_transport *transport) { void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, const char *client_payload, - size_t client_payload_length, gpr_uint32 flags) { + size_t client_payload_length, uint32_t flags) { grpc_endpoint_pair sfd; thd_args a; gpr_thd_id id; @@ -110,6 +111,9 @@ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, gpr_event_init(&a.done_write); a.validator = validator; grpc_server_register_completion_queue(a.server, a.cq, NULL); + a.registered_method = + grpc_server_register_method(a.server, GRPC_BAD_CLIENT_REGISTERED_METHOD, + GRPC_BAD_CLIENT_REGISTERED_HOST); grpc_server_start(a.server); transport = grpc_create_chttp2_transport(&exec_ctx, NULL, sfd.server, 0); server_setup_transport(&a, transport); diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h index 01beda60ee..19ddba83bf 100644 --- a/test/core/bad_client/bad_client.h +++ b/test/core/bad_client/bad_client.h @@ -37,8 +37,12 @@ #include <grpc/grpc.h> #include "test/core/util/test_config.h" -typedef void (*grpc_bad_client_server_side_validator)( - grpc_server *server, grpc_completion_queue *cq); +#define GRPC_BAD_CLIENT_REGISTERED_METHOD "/registered/bar" +#define GRPC_BAD_CLIENT_REGISTERED_HOST "localhost" + +typedef void (*grpc_bad_client_server_side_validator)(grpc_server *server, + grpc_completion_queue *cq, + void *registered_method); #define GRPC_BAD_CLIENT_DISCONNECT 1 @@ -49,7 +53,7 @@ typedef void (*grpc_bad_client_server_side_validator)( handled as expected. */ void grpc_run_bad_client_test(grpc_bad_client_server_side_validator validator, const char *client_payload, - size_t client_payload_length, gpr_uint32 flags); + size_t client_payload_length, uint32_t flags); #define GRPC_RUN_BAD_CLIENT_TEST(validator, payload, flags) \ grpc_run_bad_client_test(validator, payload, sizeof(payload) - 1, flags) diff --git a/test/core/bad_client/gen_build_yaml.py b/test/core/bad_client/gen_build_yaml.py index 386a8965db..a86a50065d 100755 --- a/test/core/bad_client/gen_build_yaml.py +++ b/test/core/bad_client/gen_build_yaml.py @@ -44,7 +44,9 @@ BAD_CLIENT_TESTS = { 'connection_prefix': default_test_options, 'headers': default_test_options, 'initial_settings_frame': default_test_options, + 'server_registered_method': default_test_options, 'simple_request': default_test_options, + 'window_overflow': default_test_options, 'unknown_frame': default_test_options, } @@ -62,7 +64,7 @@ def main(): 'headers': [ 'test/core/bad_client/bad_client.h' ], - 'vs_proj_dir': 'test', + 'vs_proj_dir': 'test/bad_client', 'deps': [ 'grpc_test_util_unsecure', 'grpc_unsecure', diff --git a/test/core/bad_client/tests/badreq.c b/test/core/bad_client/tests/badreq.c index f0d7dac0f5..6d59d25b92 100644 --- a/test/core/bad_client/tests/badreq.c +++ b/test/core/bad_client/tests/badreq.c @@ -42,7 +42,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ -static void verifier(grpc_server *server, grpc_completion_queue *cq) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/connection_prefix.c b/test/core/bad_client/tests/connection_prefix.c index 90d37a3735..66ff8c2936 100644 --- a/test/core/bad_client/tests/connection_prefix.c +++ b/test/core/bad_client/tests/connection_prefix.c @@ -34,7 +34,8 @@ #include "test/core/bad_client/bad_client.h" #include "src/core/surface/server.h" -static void verifier(grpc_server *server, grpc_completion_queue *cq) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/headers.c b/test/core/bad_client/tests/headers.c index c404fd2d67..2186a4ffcb 100644 --- a/test/core/bad_client/tests/headers.c +++ b/test/core/bad_client/tests/headers.c @@ -38,7 +38,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.c index cd8771e88e..fb6149cc3b 100644 --- a/test/core/bad_client/tests/initial_settings_frame.c +++ b/test/core/bad_client/tests/initial_settings_frame.c @@ -37,7 +37,8 @@ #define PFX_STR "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" #define ONE_SETTING_HDR "\x00\x00\x06\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/server_registered_method.c b/test/core/bad_client/tests/server_registered_method.c new file mode 100644 index 0000000000..dc6ecc51f0 --- /dev/null +++ b/test/core/bad_client/tests/server_registered_method.c @@ -0,0 +1,155 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "test/core/bad_client/bad_client.h" + +#include <string.h> + +#include "test/core/end2end/cq_verifier.h" +#include "src/core/surface/server.h" + +#define PFX_STR \ + "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ + "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ \ + "\x00\x00\xd0\x01\x04\x00\x00\x00\x01" \ + "\x10\x05:path\x0f/registered/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" \ + "\x10\x02te\x08trailers" \ + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" + +static void *tag(intptr_t t) { return (void *)t; } + +static void verifier_succeeds(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { + grpc_call_error error; + grpc_call *s; + cq_verifier *cqv = cq_verifier_create(cq); + grpc_metadata_array request_metadata_recv; + gpr_timespec deadline; + grpc_byte_buffer *payload = NULL; + + grpc_metadata_array_init(&request_metadata_recv); + + error = grpc_server_request_registered_call(server, registered_method, &s, + &deadline, &request_metadata_recv, + &payload, cq, cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); + + GPR_ASSERT(payload != NULL); + + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_destroy(s); + grpc_byte_buffer_destroy(payload); + cq_verifier_destroy(cqv); +} + +static void verifier_fails(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { + grpc_call_error error; + grpc_call *s; + cq_verifier *cqv = cq_verifier_create(cq); + grpc_metadata_array request_metadata_recv; + gpr_timespec deadline; + grpc_byte_buffer *payload = NULL; + + grpc_metadata_array_init(&request_metadata_recv); + + error = grpc_server_request_registered_call(server, registered_method, &s, + &deadline, &request_metadata_recv, + &payload, cq, cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + cq_expect_completion(cqv, tag(101), 1); + cq_verify(cqv); + + GPR_ASSERT(payload == NULL); + + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_destroy(s); + cq_verifier_destroy(cqv); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + + /* body generated with + * tools/codegen/core/gen_server_registered_method_bad_client_test_body.py */ + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, + PFX_STR "\x00\x00\x00\x00\x00\x00\x00\x00\x01", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, + PFX_STR "\x00\x00\x01\x00\x00\x00\x00\x00\x01\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR + "\x00\x00\x02\x00\x00\x00\x00\x00\x01\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST(verifier_fails, PFX_STR + "\x00\x00\x03\x00\x00\x00\x00\x00\x01\x00\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x04\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_succeeds, + PFX_STR "\x00\x00\x05\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00", 0); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x01", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_succeeds, + PFX_STR "\x00\x00\x06\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x01\x00", + 0); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x05\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_fails, + PFX_STR "\x00\x00\x06\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00", + GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier_succeeds, PFX_STR + "\x00\x00\x07\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x02\x00\x00", + 0); + + return 0; +} diff --git a/test/core/bad_client/tests/server_registered_method.headers b/test/core/bad_client/tests/server_registered_method.headers new file mode 100644 index 0000000000..06ee73c82e --- /dev/null +++ b/test/core/bad_client/tests/server_registered_method.headers @@ -0,0 +1,12 @@ +# headers used in simple_request.c +# use tools/codegen/core/gen_header_frame.py to generate the binary strings +# contained in the source code +:path: /registered/bar +:scheme: http +:method: POST +:authority: localhost +content-type: application/grpc +grpc-accept-encoding: identity,deflate,gzip +te: trailers +user-agent: bad-client grpc-c/0.12.0.0 (linux) + diff --git a/test/core/bad_client/tests/simple_request.c b/test/core/bad_client/tests/simple_request.c index 125a9fa1f2..c04319edc5 100644 --- a/test/core/bad_client/tests/simple_request.c +++ b/test/core/bad_client/tests/simple_request.c @@ -77,9 +77,10 @@ "\x10\x0cgrpc-timeout\x02" \ "5S" -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } -static void verifier(grpc_server *server, grpc_completion_queue *cq) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { grpc_call_error error; grpc_call *s; grpc_call_details call_details; @@ -104,7 +105,8 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) { cq_verifier_destroy(cqv); } -static void failure_verifier(grpc_server *server, grpc_completion_queue *cq) { +static void failure_verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/unknown_frame.c b/test/core/bad_client/tests/unknown_frame.c index 3f8658b337..2ef340eeb5 100644 --- a/test/core/bad_client/tests/unknown_frame.c +++ b/test/core/bad_client/tests/unknown_frame.c @@ -38,7 +38,8 @@ "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" -static void verifier(grpc_server *server, grpc_completion_queue *cq) { +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { while (grpc_server_has_open_connections(server)) { GPR_ASSERT(grpc_completion_queue_next(cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), diff --git a/test/core/bad_client/tests/window_overflow.c b/test/core/bad_client/tests/window_overflow.c new file mode 100644 index 0000000000..646d5c5f4c --- /dev/null +++ b/test/core/bad_client/tests/window_overflow.c @@ -0,0 +1,105 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "test/core/bad_client/bad_client.h" + +#include <string.h> + +#include <grpc/support/alloc.h> + +#include "src/core/surface/server.h" + +#define PFX_STR \ + "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ + "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ \ + "\x00\x00\xc9\x01\x04\x00\x00\x00\x01" /* headers: generated from \ + simple_request.headers in this \ + directory */ \ + "\x10\x05:path\x08/foo/bar" \ + "\x10\x07:scheme\x04http" \ + "\x10\x07:method\x04POST" \ + "\x10\x0a:authority\x09localhost" \ + "\x10\x0c" \ + "content-type\x10" \ + "application/grpc" \ + "\x10\x14grpc-accept-encoding\x15" \ + "deflate,identity,gzip" \ + "\x10\x02te\x08trailers" \ + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" + +static void verifier(grpc_server *server, grpc_completion_queue *cq, + void *registered_method) { + while (grpc_server_has_open_connections(server)) { + GPR_ASSERT(grpc_completion_queue_next(cq, + GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), + NULL).type == GRPC_QUEUE_TIMEOUT); + } +} + +char *g_buffer; +size_t g_cap = 0; +size_t g_count = 0; + +static void addbuf(const void *data, size_t len) { + if (g_count + len > g_cap) { + g_cap = GPR_MAX(g_count + len, g_cap * 2); + g_buffer = gpr_realloc(g_buffer, g_cap); + } + memcpy(g_buffer + g_count, data, len); + g_count += len; +} + +int main(int argc, char **argv) { + int i, j; +#define MAX_FRAME_SIZE 16384 +#define MESSAGES_PER_FRAME (MAX_FRAME_SIZE / 5) +#define FRAME_SIZE (MESSAGES_PER_FRAME * 5) +#define SEND_SIZE (100 * 1024) +#define NUM_FRAMES (SEND_SIZE / FRAME_SIZE + 1) + grpc_test_init(argc, argv); + + addbuf(PFX_STR, sizeof(PFX_STR) - 1); + for (i = 0; i < NUM_FRAMES; i++) { + uint8_t hdr[9] = {(uint8_t)(FRAME_SIZE >> 16), (uint8_t)(FRAME_SIZE >> 8), + (uint8_t)FRAME_SIZE, 0, 0, 0, 0, 0, 1}; + addbuf(hdr, sizeof(hdr)); + for (j = 0; j < MESSAGES_PER_FRAME; j++) { + uint8_t message[5] = {0, 0, 0, 0, 0}; + addbuf(message, sizeof(message)); + } + } + grpc_run_bad_client_test(verifier, g_buffer, g_count, 0); + gpr_free(g_buffer); + + return 0; +} diff --git a/test/core/bad_ssl/bad_ssl_test.c b/test/core/bad_ssl/bad_ssl_test.c index 54ac6d0e1c..a78a0798ae 100644 --- a/test/core/bad_ssl/bad_ssl_test.c +++ b/test/core/bad_ssl/bad_ssl_test.c @@ -46,7 +46,7 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/util/test_config.h" -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static void run_test(const char *target, size_t nops) { grpc_channel_credentials *ssl_creds = @@ -163,7 +163,7 @@ int main(int argc, char **argv) { grpc_shutdown(); } gpr_free(args[2]); - + gpr_subprocess_interrupt(svr); status = gpr_subprocess_join(svr); gpr_subprocess_destroy(svr); diff --git a/test/core/bad_ssl/gen_build_yaml.py b/test/core/bad_ssl/gen_build_yaml.py index d12722439e..15189d8b79 100755 --- a/test/core/bad_ssl/gen_build_yaml.py +++ b/test/core/bad_ssl/gen_build_yaml.py @@ -71,7 +71,7 @@ def main(): 'language': 'c', 'run': False, 'src': ['test/core/bad_ssl/servers/%s.c' % t], - 'vs_proj_dir': 'test', + 'vs_proj_dir': 'test/bad_ssl', 'platforms': ['linux', 'posix', 'mac'], 'deps': [ 'bad_ssl_test_server', diff --git a/test/core/bad_ssl/server.c b/test/core/bad_ssl/server.c index 2ed94de099..6113d364c9 100644 --- a/test/core/bad_ssl/server.c +++ b/test/core/bad_ssl/server.c @@ -74,9 +74,8 @@ void bad_ssl_run(grpc_server *server) { grpc_server_register_completion_queue(server, cq, NULL); grpc_server_start(server); - error = - grpc_server_request_call(server, &s, &call_details, - &request_metadata_recv, cq, cq, (void*)1); + error = grpc_server_request_call(server, &s, &call_details, + &request_metadata_recv, cq, cq, (void *)1); GPR_ASSERT(GRPC_CALL_OK == error); signal(SIGINT, sigint_handler); @@ -96,7 +95,7 @@ void bad_ssl_run(grpc_server *server) { NULL); switch (ev.type) { case GRPC_OP_COMPLETE: - GPR_ASSERT(ev.tag == (void*)1); + GPR_ASSERT(ev.tag == (void *)1); GPR_ASSERT(ev.success == 0); break; case GRPC_QUEUE_SHUTDOWN: diff --git a/test/core/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c index 9da4a4eec7..cb99b3da3e 100644 --- a/test/core/client_config/lb_policies_test.c +++ b/test/core/client_config/lb_policies_test.c @@ -119,7 +119,7 @@ static void test_spec_destroy(test_spec *spec) { gpr_free(spec); } -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_millis_time(int n) { return gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), @@ -137,9 +137,8 @@ static void kill_server(const servers_fixture *f, size_t i) { gpr_log(GPR_INFO, "KILLING SERVER %d", i); GPR_ASSERT(f->servers[i] != NULL); grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000)); - GPR_ASSERT( - grpc_completion_queue_pluck(f->cq, tag(10000), n_millis_time(5000), NULL) - .type == GRPC_OP_COMPLETE); + GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000), n_millis_time(5000), + NULL).type == GRPC_OP_COMPLETE); grpc_server_destroy(f->servers[i]); f->servers[i] = NULL; } @@ -205,8 +204,8 @@ static void teardown_servers(servers_fixture *f) { if (f->servers[i] == NULL) continue; grpc_server_shutdown_and_notify(f->servers[i], f->cq, tag(10000)); GPR_ASSERT(grpc_completion_queue_pluck(f->cq, tag(10000), - n_millis_time(5000), NULL) - .type == GRPC_OP_COMPLETE); + n_millis_time(5000), + NULL).type == GRPC_OP_COMPLETE); grpc_server_destroy(f->servers[i]); } grpc_completion_queue_shutdown(f->cq); @@ -304,10 +303,10 @@ static int *perform_request(servers_fixture *f, grpc_channel *client, s_idx = -1; while ((ev = grpc_completion_queue_next( - f->cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), NULL)) - .type != GRPC_QUEUE_TIMEOUT) { + f->cq, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1), NULL)).type != + GRPC_QUEUE_TIMEOUT) { GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); - read_tag = ((int)(gpr_intptr)ev.tag); + read_tag = ((int)(intptr_t)ev.tag); gpr_log(GPR_DEBUG, "EVENT: success:%d, type:%d, tag:%d iter:%d", ev.success, ev.type, read_tag, iter_num); if (ev.success && read_tag >= 1000) { @@ -377,6 +376,10 @@ static int *perform_request(servers_fixture *f, grpc_channel *client, } } + GPR_ASSERT(grpc_completion_queue_next(f->cq, + GRPC_TIMEOUT_MILLIS_TO_DEADLINE(200), + NULL).type == GRPC_QUEUE_TIMEOUT); + grpc_metadata_array_destroy(&rdata->initial_metadata_recv); grpc_metadata_array_destroy(&rdata->trailing_metadata_recv); @@ -771,6 +774,23 @@ static void verify_partial_carnage_round_robin( gpr_free(expected_connection_sequence); } +static void dump_array(const char *desc, const int *data, const size_t count) { + gpr_strvec s; + char *tmp; + size_t i; + gpr_strvec_init(&s); + gpr_strvec_add(&s, gpr_strdup(desc)); + gpr_strvec_add(&s, gpr_strdup(":")); + for (i = 0; i < count; i++) { + gpr_asprintf(&tmp, " %d", data[i]); + gpr_strvec_add(&s, tmp); + } + tmp = gpr_strvec_flatten(&s, NULL); + gpr_strvec_destroy(&s); + gpr_log(GPR_DEBUG, "%s", tmp); + gpr_free(tmp); +} + static void verify_rebirth_round_robin(const servers_fixture *f, grpc_channel *client, const int *actual_connection_sequence, @@ -778,7 +798,10 @@ static void verify_rebirth_round_robin(const servers_fixture *f, int *expected_connection_sequence; size_t i, j, unique_seq_last_idx, unique_seq_first_idx; const size_t expected_seq_length = f->num_servers; - uint8_t *seen_elements; + int *seen_elements; + + dump_array("actual_connection_sequence", actual_connection_sequence, + num_iters); /* verify conn. seq. expectation */ /* get the first unique run of length "num_servers". */ @@ -787,12 +810,12 @@ static void verify_rebirth_round_robin(const servers_fixture *f, unique_seq_last_idx = ~(size_t)0; - memset(seen_elements, 0, sizeof(uint8_t) * expected_seq_length); + memset(seen_elements, 0, sizeof(int) * expected_seq_length); for (i = 0; i < num_iters; i++) { if (actual_connection_sequence[i] < 0 || seen_elements[actual_connection_sequence[i]] != 0) { /* if anything breaks the uniqueness of the run, back to square zero */ - memset(seen_elements, 0, sizeof(uint8_t) * expected_seq_length); + memset(seen_elements, 0, sizeof(int) * expected_seq_length); continue; } seen_elements[actual_connection_sequence[i]] = 1; @@ -805,6 +828,7 @@ static void verify_rebirth_round_robin(const servers_fixture *f, } } /* make sure we found a valid run */ + dump_array("seen_elements", seen_elements, expected_seq_length); for (j = 0; j < expected_seq_length; j++) { GPR_ASSERT(seen_elements[j] != 0); } diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index e5a01ef69e..6d3d16128a 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -172,7 +172,7 @@ static void test_bad_decompression_data_crc(void) { gpr_slice_buffer corrupted; gpr_slice_buffer output; size_t idx; - const gpr_uint32 bad = 0xdeadbeef; + const uint32_t bad = 0xdeadbeef; gpr_slice_buffer_init(&input); gpr_slice_buffer_init(&corrupted); diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 922de268f4..724d419a7a 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -110,7 +110,7 @@ int contains_metadata(grpc_metadata_array *array, const char *key, static gpr_slice merge_slices(gpr_slice *slices, size_t nslices) { size_t i; size_t len = 0; - gpr_uint8 *cursor; + uint8_t *cursor; gpr_slice out; for (i = 0; i < nslices; i++) { diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index e5ee7c4375..58e13a4098 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -49,7 +49,7 @@ /* This test exercises IPv4, IPv6, and dualstack sockets in various ways. */ -static void *tag(gpr_intptr i) { return (void *)i; } +static void *tag(intptr_t i) { return (void *)i; } static gpr_timespec ms_from_now(int ms) { return GRPC_TIMEOUT_MILLIS_TO_DEADLINE(ms); diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c new file mode 100644 index 0000000000..d9df5fd7f0 --- /dev/null +++ b/test/core/end2end/end2end_nosec_tests.c @@ -0,0 +1,264 @@ + +/* + * + * Copyright 2015-2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* This file is auto-generated */ + +#include "test/core/end2end/end2end_tests.h" +#include <string.h> +#include <grpc/support/log.h> + +extern void bad_hostname(grpc_end2end_test_config config); +extern void binary_metadata(grpc_end2end_test_config config); +extern void cancel_after_accept(grpc_end2end_test_config config); +extern void cancel_after_client_done(grpc_end2end_test_config config); +extern void cancel_after_invoke(grpc_end2end_test_config config); +extern void cancel_before_invoke(grpc_end2end_test_config config); +extern void cancel_in_a_vacuum(grpc_end2end_test_config config); +extern void cancel_with_status(grpc_end2end_test_config config); +extern void channel_connectivity(grpc_end2end_test_config config); +extern void channel_ping(grpc_end2end_test_config config); +extern void compressed_payload(grpc_end2end_test_config config); +extern void default_host(grpc_end2end_test_config config); +extern void disappearing_server(grpc_end2end_test_config config); +extern void empty_batch(grpc_end2end_test_config config); +extern void graceful_server_shutdown(grpc_end2end_test_config config); +extern void high_initial_seqno(grpc_end2end_test_config config); +extern void hpack_size(grpc_end2end_test_config config); +extern void invoke_large_request(grpc_end2end_test_config config); +extern void large_metadata(grpc_end2end_test_config config); +extern void max_concurrent_streams(grpc_end2end_test_config config); +extern void max_message_length(grpc_end2end_test_config config); +extern void metadata(grpc_end2end_test_config config); +extern void negative_deadline(grpc_end2end_test_config config); +extern void no_op(grpc_end2end_test_config config); +extern void payload(grpc_end2end_test_config config); +extern void ping_pong_streaming(grpc_end2end_test_config config); +extern void registered_call(grpc_end2end_test_config config); +extern void request_with_flags(grpc_end2end_test_config config); +extern void request_with_payload(grpc_end2end_test_config config); +extern void server_finishes_request(grpc_end2end_test_config config); +extern void shutdown_finishes_calls(grpc_end2end_test_config config); +extern void shutdown_finishes_tags(grpc_end2end_test_config config); +extern void simple_delayed_request(grpc_end2end_test_config config); +extern void simple_request(grpc_end2end_test_config config); +extern void trailing_metadata(grpc_end2end_test_config config); + +void grpc_end2end_tests(int argc, char **argv, + grpc_end2end_test_config config) { + int i; + + if (argc <= 1) { + bad_hostname(config); + binary_metadata(config); + cancel_after_accept(config); + cancel_after_client_done(config); + cancel_after_invoke(config); + cancel_before_invoke(config); + cancel_in_a_vacuum(config); + cancel_with_status(config); + channel_connectivity(config); + channel_ping(config); + compressed_payload(config); + default_host(config); + disappearing_server(config); + empty_batch(config); + graceful_server_shutdown(config); + high_initial_seqno(config); + hpack_size(config); + invoke_large_request(config); + large_metadata(config); + max_concurrent_streams(config); + max_message_length(config); + metadata(config); + negative_deadline(config); + no_op(config); + payload(config); + ping_pong_streaming(config); + registered_call(config); + request_with_flags(config); + request_with_payload(config); + server_finishes_request(config); + shutdown_finishes_calls(config); + shutdown_finishes_tags(config); + simple_delayed_request(config); + simple_request(config); + trailing_metadata(config); + return; + } + + for (i = 1; i < argc; i++) { + if (0 == strcmp("bad_hostname", argv[i])) { + bad_hostname(config); + continue; + } + if (0 == strcmp("binary_metadata", argv[i])) { + binary_metadata(config); + continue; + } + if (0 == strcmp("cancel_after_accept", argv[i])) { + cancel_after_accept(config); + continue; + } + if (0 == strcmp("cancel_after_client_done", argv[i])) { + cancel_after_client_done(config); + continue; + } + if (0 == strcmp("cancel_after_invoke", argv[i])) { + cancel_after_invoke(config); + continue; + } + if (0 == strcmp("cancel_before_invoke", argv[i])) { + cancel_before_invoke(config); + continue; + } + if (0 == strcmp("cancel_in_a_vacuum", argv[i])) { + cancel_in_a_vacuum(config); + continue; + } + if (0 == strcmp("cancel_with_status", argv[i])) { + cancel_with_status(config); + continue; + } + if (0 == strcmp("channel_connectivity", argv[i])) { + channel_connectivity(config); + continue; + } + if (0 == strcmp("channel_ping", argv[i])) { + channel_ping(config); + continue; + } + if (0 == strcmp("compressed_payload", argv[i])) { + compressed_payload(config); + continue; + } + if (0 == strcmp("default_host", argv[i])) { + default_host(config); + continue; + } + if (0 == strcmp("disappearing_server", argv[i])) { + disappearing_server(config); + continue; + } + if (0 == strcmp("empty_batch", argv[i])) { + empty_batch(config); + continue; + } + if (0 == strcmp("graceful_server_shutdown", argv[i])) { + graceful_server_shutdown(config); + continue; + } + if (0 == strcmp("high_initial_seqno", argv[i])) { + high_initial_seqno(config); + continue; + } + if (0 == strcmp("hpack_size", argv[i])) { + hpack_size(config); + continue; + } + if (0 == strcmp("invoke_large_request", argv[i])) { + invoke_large_request(config); + continue; + } + if (0 == strcmp("large_metadata", argv[i])) { + large_metadata(config); + continue; + } + if (0 == strcmp("max_concurrent_streams", argv[i])) { + max_concurrent_streams(config); + continue; + } + if (0 == strcmp("max_message_length", argv[i])) { + max_message_length(config); + continue; + } + if (0 == strcmp("metadata", argv[i])) { + metadata(config); + continue; + } + if (0 == strcmp("negative_deadline", argv[i])) { + negative_deadline(config); + continue; + } + if (0 == strcmp("no_op", argv[i])) { + no_op(config); + continue; + } + if (0 == strcmp("payload", argv[i])) { + payload(config); + continue; + } + if (0 == strcmp("ping_pong_streaming", argv[i])) { + ping_pong_streaming(config); + continue; + } + if (0 == strcmp("registered_call", argv[i])) { + registered_call(config); + continue; + } + if (0 == strcmp("request_with_flags", argv[i])) { + request_with_flags(config); + continue; + } + if (0 == strcmp("request_with_payload", argv[i])) { + request_with_payload(config); + continue; + } + if (0 == strcmp("server_finishes_request", argv[i])) { + server_finishes_request(config); + continue; + } + if (0 == strcmp("shutdown_finishes_calls", argv[i])) { + shutdown_finishes_calls(config); + continue; + } + if (0 == strcmp("shutdown_finishes_tags", argv[i])) { + shutdown_finishes_tags(config); + continue; + } + if (0 == strcmp("simple_delayed_request", argv[i])) { + simple_delayed_request(config); + continue; + } + if (0 == strcmp("simple_request", argv[i])) { + simple_request(config); + continue; + } + if (0 == strcmp("trailing_metadata", argv[i])) { + trailing_metadata(config); + continue; + } + gpr_log(GPR_DEBUG, "not a test: '%%s'", argv[i]); + abort(); + } +} diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c new file mode 100644 index 0000000000..7b1471eb89 --- /dev/null +++ b/test/core/end2end/end2end_tests.c @@ -0,0 +1,270 @@ + +/* + * + * Copyright 2015-2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +/* This file is auto-generated */ + +#include "test/core/end2end/end2end_tests.h" +#include <string.h> +#include <grpc/support/log.h> + +extern void bad_hostname(grpc_end2end_test_config config); +extern void binary_metadata(grpc_end2end_test_config config); +extern void call_creds(grpc_end2end_test_config config); +extern void cancel_after_accept(grpc_end2end_test_config config); +extern void cancel_after_client_done(grpc_end2end_test_config config); +extern void cancel_after_invoke(grpc_end2end_test_config config); +extern void cancel_before_invoke(grpc_end2end_test_config config); +extern void cancel_in_a_vacuum(grpc_end2end_test_config config); +extern void cancel_with_status(grpc_end2end_test_config config); +extern void channel_connectivity(grpc_end2end_test_config config); +extern void channel_ping(grpc_end2end_test_config config); +extern void compressed_payload(grpc_end2end_test_config config); +extern void default_host(grpc_end2end_test_config config); +extern void disappearing_server(grpc_end2end_test_config config); +extern void empty_batch(grpc_end2end_test_config config); +extern void graceful_server_shutdown(grpc_end2end_test_config config); +extern void high_initial_seqno(grpc_end2end_test_config config); +extern void hpack_size(grpc_end2end_test_config config); +extern void invoke_large_request(grpc_end2end_test_config config); +extern void large_metadata(grpc_end2end_test_config config); +extern void max_concurrent_streams(grpc_end2end_test_config config); +extern void max_message_length(grpc_end2end_test_config config); +extern void metadata(grpc_end2end_test_config config); +extern void negative_deadline(grpc_end2end_test_config config); +extern void no_op(grpc_end2end_test_config config); +extern void payload(grpc_end2end_test_config config); +extern void ping_pong_streaming(grpc_end2end_test_config config); +extern void registered_call(grpc_end2end_test_config config); +extern void request_with_flags(grpc_end2end_test_config config); +extern void request_with_payload(grpc_end2end_test_config config); +extern void server_finishes_request(grpc_end2end_test_config config); +extern void shutdown_finishes_calls(grpc_end2end_test_config config); +extern void shutdown_finishes_tags(grpc_end2end_test_config config); +extern void simple_delayed_request(grpc_end2end_test_config config); +extern void simple_request(grpc_end2end_test_config config); +extern void trailing_metadata(grpc_end2end_test_config config); + +void grpc_end2end_tests(int argc, char **argv, + grpc_end2end_test_config config) { + int i; + + if (argc <= 1) { + bad_hostname(config); + binary_metadata(config); + call_creds(config); + cancel_after_accept(config); + cancel_after_client_done(config); + cancel_after_invoke(config); + cancel_before_invoke(config); + cancel_in_a_vacuum(config); + cancel_with_status(config); + channel_connectivity(config); + channel_ping(config); + compressed_payload(config); + default_host(config); + disappearing_server(config); + empty_batch(config); + graceful_server_shutdown(config); + high_initial_seqno(config); + hpack_size(config); + invoke_large_request(config); + large_metadata(config); + max_concurrent_streams(config); + max_message_length(config); + metadata(config); + negative_deadline(config); + no_op(config); + payload(config); + ping_pong_streaming(config); + registered_call(config); + request_with_flags(config); + request_with_payload(config); + server_finishes_request(config); + shutdown_finishes_calls(config); + shutdown_finishes_tags(config); + simple_delayed_request(config); + simple_request(config); + trailing_metadata(config); + return; + } + + for (i = 1; i < argc; i++) { + if (0 == strcmp("bad_hostname", argv[i])) { + bad_hostname(config); + continue; + } + if (0 == strcmp("binary_metadata", argv[i])) { + binary_metadata(config); + continue; + } + if (0 == strcmp("call_creds", argv[i])) { + call_creds(config); + continue; + } + if (0 == strcmp("cancel_after_accept", argv[i])) { + cancel_after_accept(config); + continue; + } + if (0 == strcmp("cancel_after_client_done", argv[i])) { + cancel_after_client_done(config); + continue; + } + if (0 == strcmp("cancel_after_invoke", argv[i])) { + cancel_after_invoke(config); + continue; + } + if (0 == strcmp("cancel_before_invoke", argv[i])) { + cancel_before_invoke(config); + continue; + } + if (0 == strcmp("cancel_in_a_vacuum", argv[i])) { + cancel_in_a_vacuum(config); + continue; + } + if (0 == strcmp("cancel_with_status", argv[i])) { + cancel_with_status(config); + continue; + } + if (0 == strcmp("channel_connectivity", argv[i])) { + channel_connectivity(config); + continue; + } + if (0 == strcmp("channel_ping", argv[i])) { + channel_ping(config); + continue; + } + if (0 == strcmp("compressed_payload", argv[i])) { + compressed_payload(config); + continue; + } + if (0 == strcmp("default_host", argv[i])) { + default_host(config); + continue; + } + if (0 == strcmp("disappearing_server", argv[i])) { + disappearing_server(config); + continue; + } + if (0 == strcmp("empty_batch", argv[i])) { + empty_batch(config); + continue; + } + if (0 == strcmp("graceful_server_shutdown", argv[i])) { + graceful_server_shutdown(config); + continue; + } + if (0 == strcmp("high_initial_seqno", argv[i])) { + high_initial_seqno(config); + continue; + } + if (0 == strcmp("hpack_size", argv[i])) { + hpack_size(config); + continue; + } + if (0 == strcmp("invoke_large_request", argv[i])) { + invoke_large_request(config); + continue; + } + if (0 == strcmp("large_metadata", argv[i])) { + large_metadata(config); + continue; + } + if (0 == strcmp("max_concurrent_streams", argv[i])) { + max_concurrent_streams(config); + continue; + } + if (0 == strcmp("max_message_length", argv[i])) { + max_message_length(config); + continue; + } + if (0 == strcmp("metadata", argv[i])) { + metadata(config); + continue; + } + if (0 == strcmp("negative_deadline", argv[i])) { + negative_deadline(config); + continue; + } + if (0 == strcmp("no_op", argv[i])) { + no_op(config); + continue; + } + if (0 == strcmp("payload", argv[i])) { + payload(config); + continue; + } + if (0 == strcmp("ping_pong_streaming", argv[i])) { + ping_pong_streaming(config); + continue; + } + if (0 == strcmp("registered_call", argv[i])) { + registered_call(config); + continue; + } + if (0 == strcmp("request_with_flags", argv[i])) { + request_with_flags(config); + continue; + } + if (0 == strcmp("request_with_payload", argv[i])) { + request_with_payload(config); + continue; + } + if (0 == strcmp("server_finishes_request", argv[i])) { + server_finishes_request(config); + continue; + } + if (0 == strcmp("shutdown_finishes_calls", argv[i])) { + shutdown_finishes_calls(config); + continue; + } + if (0 == strcmp("shutdown_finishes_tags", argv[i])) { + shutdown_finishes_tags(config); + continue; + } + if (0 == strcmp("simple_delayed_request", argv[i])) { + simple_delayed_request(config); + continue; + } + if (0 == strcmp("simple_request", argv[i])) { + simple_request(config); + continue; + } + if (0 == strcmp("trailing_metadata", argv[i])) { + trailing_metadata(config); + continue; + } + gpr_log(GPR_DEBUG, "not a test: '%%s'", argv[i]); + abort(); + } +} diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index 3f1665613c..bc44f43a17 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -54,7 +54,7 @@ struct grpc_end2end_test_fixture { struct grpc_end2end_test_config { const char *name; - gpr_uint32 feature_mask; + uint32_t feature_mask; grpc_end2end_test_fixture (*create_fixture)(grpc_channel_args *client_args, grpc_channel_args *server_args); void (*init_client)(grpc_end2end_test_fixture *f, @@ -64,6 +64,6 @@ struct grpc_end2end_test_config { void (*tear_down_data)(grpc_end2end_test_fixture *f); }; -void grpc_end2end_tests(grpc_end2end_test_config config); +void grpc_end2end_tests(int argc, char **argv, grpc_end2end_test_config config); #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index 90f3713cc8..e74c9ae243 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -123,7 +123,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index 6e7a1faf55..fea8a4f751 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -127,7 +127,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_fakesec.c b/test/core/end2end/fixtures/h2_fakesec.c index bc009e1df1..2767f1df4a 100644 --- a/test/core/end2end/fixtures/h2_fakesec.c +++ b/test/core/end2end/fixtures/h2_fakesec.c @@ -154,7 +154,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 83cde49305..4b93581899 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -111,7 +111,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_full+poll+pipe.c b/test/core/end2end/fixtures/h2_full+poll+pipe.c index ffae11f90d..d475a7bb55 100644 --- a/test/core/end2end/fixtures/h2_full+poll+pipe.c +++ b/test/core/end2end/fixtures/h2_full+poll+pipe.c @@ -111,7 +111,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_full+poll.c b/test/core/end2end/fixtures/h2_full+poll.c index 48feefc931..3f5e6096f6 100644 --- a/test/core/end2end/fixtures/h2_full+poll.c +++ b/test/core/end2end/fixtures/h2_full+poll.c @@ -109,7 +109,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index 0170dcf0e5..ebaa1c6a2c 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -108,7 +108,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_oauth2.c b/test/core/end2end/fixtures/h2_oauth2.c index 7a34cc67d8..e2c82917ef 100644 --- a/test/core/end2end/fixtures/h2_oauth2.c +++ b/test/core/end2end/fixtures/h2_oauth2.c @@ -230,7 +230,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index 44083e2676..8bcc1b6ee0 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -123,7 +123,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index ccc8631d94..511c8b1a46 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -169,7 +169,7 @@ int main(int argc, char **argv) { GPR_ASSERT(1 == grpc_tracer_set_enabled("all", 1)); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index a6a84c9b1a..6b4787b1e5 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -153,7 +153,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index 4b8f9054ef..3ae8e96683 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -153,7 +153,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_ssl+poll.c b/test/core/end2end/fixtures/h2_ssl+poll.c index 37e1758f00..614654ed52 100644 --- a/test/core/end2end/fixtures/h2_ssl+poll.c +++ b/test/core/end2end/fixtures/h2_ssl+poll.c @@ -179,7 +179,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_ssl.c b/test/core/end2end/fixtures/h2_ssl.c index f5a006bd08..5c63dfb6aa 100644 --- a/test/core/end2end/fixtures/h2_ssl.c +++ b/test/core/end2end/fixtures/h2_ssl.c @@ -176,7 +176,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_ssl_proxy.c b/test/core/end2end/fixtures/h2_ssl_proxy.c index 7233cdbe2d..a93bd83a1f 100644 --- a/test/core/end2end/fixtures/h2_ssl_proxy.c +++ b/test/core/end2end/fixtures/h2_ssl_proxy.c @@ -206,7 +206,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_uchannel.c b/test/core/end2end/fixtures/h2_uchannel.c index ea630c3275..9b622e80d6 100644 --- a/test/core/end2end/fixtures/h2_uchannel.c +++ b/test/core/end2end/fixtures/h2_uchannel.c @@ -348,7 +348,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_uds+poll.c b/test/core/end2end/fixtures/h2_uds+poll.c index 05b9ea0949..155017c887 100644 --- a/test/core/end2end/fixtures/h2_uds+poll.c +++ b/test/core/end2end/fixtures/h2_uds+poll.c @@ -115,7 +115,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index 59d39bbb0f..30928270e5 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) { grpc_init(); for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { - grpc_end2end_tests(configs[i]); + grpc_end2end_tests(argc, argv, configs[i]); } grpc_shutdown(); diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index 9f94cfe6be..6a4038da73 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -77,8 +77,8 @@ END2END_FIXTURES = { } TestOptions = collections.namedtuple( - 'TestOptions', 'needs_fullstack needs_dns proxyable flaky secure traceable') -default_test_options = TestOptions(False, False, True, False, False, True) + 'TestOptions', 'needs_fullstack needs_dns proxyable secure traceable') +default_test_options = TestOptions(False, False, True, False, True) connectivity_test_options = default_test_options._replace(needs_fullstack=True) # maps test names to options @@ -164,56 +164,33 @@ def main(): '#': 'generated with test/end2end/gen_build_json.py', 'libs': [ { - 'name': 'end2end_fixture_%s' % f, + 'name': 'end2end_tests', 'build': 'private', 'language': 'c', - 'secure': 'check' if END2END_FIXTURES[f].secure else False, - 'src': ['test/core/end2end/fixtures/%s.c' % f], - 'platforms': ['linux', 'mac', 'posix'] if f.endswith('_posix') - else END2END_FIXTURES[f].platforms, - 'deps': sec_deps, - 'headers': ['test/core/end2end/end2end_tests.h'], - 'vs_proj_dir': 'test', - } for f in sorted(END2END_FIXTURES.keys()) - ] + [ - { - 'name': 'end2end_nosec_fixture_%s' % f, - 'build': 'private', - 'language': 'c', - 'secure': False, - 'src': ['test/core/end2end/fixtures/%s.c' % f], - 'platforms': ['linux', 'mac', 'posix'] if f.endswith('_posix') - else END2END_FIXTURES[f].platforms, - 'deps': unsec_deps, - 'headers': ['test/core/end2end/end2end_tests.h'], - 'vs_proj_dir': 'test', - } for f in sorted(END2END_FIXTURES.keys()) - if not END2END_FIXTURES[f].secure - ] + [ - { - 'name': 'end2end_test_%s' % t, - 'build': 'private', - 'language': 'c', - 'secure': 'check' if END2END_TESTS[t].secure else False, - 'src': ['test/core/end2end/tests/%s.c' % t], + 'secure': True, + 'src': ['test/core/end2end/end2end_tests.c'] + [ + 'test/core/end2end/tests/%s.c' % t + for t in sorted(END2END_TESTS.keys())], 'headers': ['test/core/end2end/tests/cancel_test_helpers.h', 'test/core/end2end/end2end_tests.h'], 'deps': sec_deps, - 'vs_proj_dir': 'test', - } for t in sorted(END2END_TESTS.keys()) + 'vs_proj_dir': 'test/end2end/tests', + } ] + [ { - 'name': 'end2end_nosec_test_%s' % t, + 'name': 'end2end_nosec_tests', 'build': 'private', 'language': 'c', 'secure': False, - 'src': ['test/core/end2end/tests/%s.c' % t], + 'src': ['test/core/end2end/end2end_nosec_tests.c'] + [ + 'test/core/end2end/tests/%s.c' % t + for t in sorted(END2END_TESTS.keys()) + if not END2END_TESTS[t].secure], 'headers': ['test/core/end2end/tests/cancel_test_helpers.h', 'test/core/end2end/end2end_tests.h'], 'deps': unsec_deps, - 'vs_proj_dir': 'test', - } for t in sorted(END2END_TESTS.keys()) - if not END2END_TESTS[t].secure + 'vs_proj_dir': 'test/end2end/tests', + } ] + [ { 'name': 'end2end_certs', @@ -224,49 +201,81 @@ def main(): "test/core/end2end/data/server1_cert.c", "test/core/end2end/data/server1_key.c" ], - 'vs_proj_dir': 'test', + 'vs_proj_dir': 'test/end2end', } ], 'targets': [ { - 'name': '%s_%s_test' % (f, t), + 'name': '%s_test' % f, 'build': 'test', 'language': 'c', - 'src': [], - 'flaky': END2END_TESTS[t].flaky, + 'run': False, + 'src': ['test/core/end2end/fixtures/%s.c' % f], 'platforms': END2END_FIXTURES[f].platforms, 'ci_platforms': (END2END_FIXTURES[f].platforms if END2END_FIXTURES[f].ci_mac else without( END2END_FIXTURES[f].platforms, 'mac')), 'deps': [ - 'end2end_fixture_%s' % f, 'end2end_test_%s' % t + 'end2end_tests' ] + sec_deps, - 'vs_proj_dir': 'test', + 'vs_proj_dir': 'test/end2end/fixtures', } for f in sorted(END2END_FIXTURES.keys()) - for t in sorted(END2END_TESTS.keys()) if compatible(f, t) ] + [ { - 'name': '%s_%s_nosec_test' % (f, t), + 'name': '%s_nosec_test' % f, 'build': 'test', 'language': 'c', 'secure': 'no', - 'src': [], - 'flaky': END2END_TESTS[t].flaky, + 'src': ['test/core/end2end/fixtures/%s.c' % f], + 'run': False, 'platforms': END2END_FIXTURES[f].platforms, 'ci_platforms': (END2END_FIXTURES[f].platforms if END2END_FIXTURES[f].ci_mac else without( END2END_FIXTURES[f].platforms, 'mac')), 'deps': [ - 'end2end_nosec_fixture_%s' % f, 'end2end_nosec_test_%s' % t + 'end2end_nosec_tests' ] + unsec_deps, - 'vs_proj_dir': 'test', + 'vs_proj_dir': 'test/end2end/fixtures', + } + for f in sorted(END2END_FIXTURES.keys()) + if not END2END_FIXTURES[f].secure + ], + 'tests': [ + { + 'name': '%s_test' % f, + 'args': [t], + 'exclude_configs': [], + 'platforms': END2END_FIXTURES[f].platforms, + 'ci_platforms': (END2END_FIXTURES[f].platforms + if END2END_FIXTURES[f].ci_mac else without( + END2END_FIXTURES[f].platforms, 'mac')), + 'flaky': False, + 'language': 'c', + } + for f in sorted(END2END_FIXTURES.keys()) + for t in sorted(END2END_TESTS.keys()) if compatible(f, t) + ] + [ + { + 'name': '%s_test' % f, + 'args': [t], + 'exclude_configs': [], + 'platforms': END2END_FIXTURES[f].platforms, + 'ci_platforms': (END2END_FIXTURES[f].platforms + if END2END_FIXTURES[f].ci_mac else without( + END2END_FIXTURES[f].platforms, 'mac')), + 'flaky': False, + 'language': 'c', } for f in sorted(END2END_FIXTURES.keys()) if not END2END_FIXTURES[f].secure for t in sorted(END2END_TESTS.keys()) if compatible(f, t) and not END2END_TESTS[t].secure - ] + ], + 'core_end2end_tests': dict( + (t, END2END_TESTS[t].secure) + for t in END2END_TESTS.keys() + ) } print yaml.dump(json) diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 1fd4c0145a..4029e96a41 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -39,7 +39,7 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static void *tag(gpr_intptr i) { return (void *)i; } +static void *tag(intptr_t i) { return (void *)i; } struct test_state { int is_client; diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c index 775fb221d0..5c971eac6a 100644 --- a/test/core/end2end/no_server_test.c +++ b/test/core/end2end/no_server_test.c @@ -37,7 +37,7 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/util/test_config.h" -static void *tag(gpr_intptr i) { return (void *)i; } +static void *tag(intptr_t i) { return (void *)i; } int main(int argc, char **argv) { grpc_channel *chan; diff --git a/test/core/end2end/tests/bad_hostname.c b/test/core/end2end/tests/bad_hostname.c index ca4c1a9805..14587389c7 100644 --- a/test/core/end2end/tests/bad_hostname.c +++ b/test/core/end2end/tests/bad_hostname.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -174,7 +174,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void bad_hostname(grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index e6404d6f51..4eccd16c4c 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -284,6 +284,6 @@ static void test_request_response_with_metadata_and_payload( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void binary_metadata(grpc_end2end_test_config config) { test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index bbfad21b62..c9d4251b68 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -55,7 +55,7 @@ typedef enum { NONE, OVERRIDE, DESTROY } override_mode; enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -467,7 +467,7 @@ static void test_request_with_server_rejecting_client_creds( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void call_creds(grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) { test_request_response_with_payload_and_call_creds(config); test_request_response_with_payload_and_overridden_call_creds(config); diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 68bd4bc36e..4646bf7bca 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -46,7 +46,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -226,7 +226,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void cancel_after_accept(grpc_end2end_test_config config) { unsigned i; for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 1e919ce19e..364598a76a 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -46,7 +46,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -230,7 +230,7 @@ static void test_cancel_after_accept_and_writes_closed( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void cancel_after_client_done(grpc_end2end_test_config config) { unsigned i; for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index a84f9be14e..ec0b0dea4c 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -46,7 +46,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -190,7 +190,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void cancel_after_invoke(grpc_end2end_test_config config) { unsigned i, j; for (j = 2; j < 6; j++) { diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 61574df3d0..7b432fe87e 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -188,7 +188,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void cancel_before_invoke(grpc_end2end_test_config config) { size_t i; for (i = 1; i <= 6; i++) { test_cancel_before_invoke(config, i); diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 6435d22ee9..214ab2b9e8 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -46,7 +46,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -120,7 +120,7 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void cancel_in_a_vacuum(grpc_end2end_test_config config) { unsigned i; for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index 2e36902a51..1541ca099f 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -176,7 +176,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void cancel_with_status(grpc_end2end_test_config config) { size_t i; for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); diff --git a/test/core/end2end/tests/channel_connectivity.c b/test/core/end2end/tests/channel_connectivity.c index 0e0ac03015..0e21e65557 100644 --- a/test/core/end2end/tests/channel_connectivity.c +++ b/test/core/end2end/tests/channel_connectivity.c @@ -40,7 +40,7 @@ #include "test/core/end2end/cq_verifier.h" -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } typedef struct { gpr_event started; @@ -168,7 +168,7 @@ static void test_connectivity(grpc_end2end_test_config config) { cq_verifier_destroy(cqv); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void channel_connectivity(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_connectivity(config); } diff --git a/test/core/end2end/tests/channel_ping.c b/test/core/end2end/tests/channel_ping.c index 441e49ee7a..73fab206fb 100644 --- a/test/core/end2end/tests/channel_ping.c +++ b/test/core/end2end/tests/channel_ping.c @@ -40,7 +40,7 @@ #include "test/core/end2end/cq_verifier.h" -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static void test_ping(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = config.create_fixture(NULL, NULL); @@ -91,7 +91,7 @@ static void test_ping(grpc_end2end_test_config config) { cq_verifier_destroy(cqv); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void channel_ping(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_ping(config); } diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 0d07110aef..33b1d8f9fe 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -50,7 +50,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -104,7 +104,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static void request_with_payload_template( grpc_end2end_test_config config, const char *test_name, - gpr_uint32 send_flags_bitmask, + uint32_t send_flags_bitmask, grpc_compression_algorithm requested_compression_algorithm, grpc_compression_algorithm expected_compression_algorithm, grpc_metadata *client_metadata) { @@ -330,7 +330,7 @@ static void test_invoke_request_with_compressed_payload_md_override( GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, &none_compression_override); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void compressed_payload(grpc_end2end_test_config config) { test_invoke_request_with_exceptionally_uncompressed_payload(config); test_invoke_request_with_uncompressed_payload(config); test_invoke_request_with_compressed_payload(config); diff --git a/test/core/end2end/tests/default_host.c b/test/core/end2end/tests/default_host.c index fc06b8950d..dc3303436b 100644 --- a/test/core/end2end/tests/default_host.c +++ b/test/core/end2end/tests/default_host.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -225,7 +225,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void default_host(grpc_end2end_test_config config) { if ((config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) == 0) return; if ((config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) == 0) diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index de3ea16f66..5b2bbaf70c 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); @@ -209,7 +209,7 @@ static void disappearing_server_test(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void disappearing_server(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); disappearing_server_test(config); } diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index f331aa92e0..24320c0f32 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -129,6 +129,6 @@ static void test_invoke_empty_body(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void empty_batch(grpc_end2end_test_config config) { test_invoke_empty_body(config); } diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 8efa5a34d0..cc6a9d44f8 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -207,6 +207,6 @@ static void test_early_server_shutdown_finishes_inflight_calls( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void graceful_server_shutdown(grpc_end2end_test_config config) { test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 399b6e2183..8d16ef5f5e 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -49,7 +49,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -231,7 +231,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, gpr_free(name); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void high_initial_seqno(grpc_end2end_test_config config) { test_invoke_10_simple_requests(config, 16777213); if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) { test_invoke_10_simple_requests(config, 2147483645); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index f16883ecfd..fd4fe3419f 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -47,7 +47,7 @@ #include "src/core/support/string.h" #include "test/core/end2end/cq_verifier.h" -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } const char *hobbits[][2] = {{"Adaldrida", "Brandybuck"}, {"Adamanta", "Took"}, @@ -433,7 +433,7 @@ static void test_size(grpc_end2end_test_config config, int encode_size, gpr_free(name); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void hpack_size(grpc_end2end_test_config config) { static const int interesting_sizes[] = {4096, 0, 100, 1000, 32768, 4 * 1024 * 1024}; size_t i, j; diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index c612af91e3..f0b019821d 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -251,6 +251,6 @@ static void test_invoke_large_request(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void invoke_large_request(grpc_end2end_test_config config) { test_invoke_large_request(config); } diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 763f75d59d..1b41e89b26 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -242,6 +242,6 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void large_metadata(grpc_end2end_test_config config) { test_request_with_large_metadata(config); } diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index d39aabaf70..d6b2a06f9b 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -348,7 +348,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { * both); * check this here */ /* We'll get tag 303 or 403, we want 300, 400 */ - live_call = ((int)(gpr_intptr)ev.tag) - 1; + live_call = ((int)(intptr_t)ev.tag) - 1; got_client_start = 1; } } @@ -433,6 +433,6 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void max_concurrent_streams(grpc_end2end_test_config config) { test_max_concurrent_streams(config); } diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index c311f0a44e..59ab7f476c 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -218,6 +218,6 @@ static void test_max_message_length(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void max_message_length(grpc_end2end_test_config config) { test_max_message_length(config); } diff --git a/test/core/end2end/tests/metadata.c b/test/core/end2end/tests/metadata.c index 2593cde027..5e92091eb7 100644 --- a/test/core/end2end/tests/metadata.c +++ b/test/core/end2end/tests/metadata.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -260,6 +260,6 @@ static void test_request_response_with_metadata_and_payload( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void metadata(grpc_end2end_test_config config) { test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index 23b8591e25..2109310634 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -173,7 +173,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void negative_deadline(grpc_end2end_test_config config) { size_t i; for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); diff --git a/test/core/end2end/tests/no_op.c b/test/core/end2end/tests/no_op.c index dbaad3004e..4bc1d631d1 100644 --- a/test/core/end2end/tests/no_op.c +++ b/test/core/end2end/tests/no_op.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -103,4 +103,4 @@ static void test_no_op(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { test_no_op(config); } +void no_op(grpc_end2end_test_config config) { test_no_op(config); } diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index df44c0de1e..bc220cbdc9 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -264,7 +264,7 @@ static void test_invoke_10_request_response_with_payload( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void payload(grpc_end2end_test_config config) { test_invoke_request_response_with_payload(config); test_invoke_10_request_response_with_payload(config); } diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 27180dd679..8351f508c5 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -268,7 +268,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void ping_pong_streaming(grpc_end2end_test_config config) { int i; for (i = 1; i < 10; i++) { diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index ef4d5063b5..d9d2b19d12 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -227,7 +227,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void registered_call(grpc_end2end_test_config config) { test_invoke_simple_request(config); test_invoke_10_simple_requests(config); } diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 0ad5a4612e..340aba6cdb 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -46,7 +46,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -99,7 +99,7 @@ static void end_test(grpc_end2end_test_fixture *f) { } static void test_invoke_request_with_flags( - grpc_end2end_test_config config, gpr_uint32 *flags_for_op, + grpc_end2end_test_config config, uint32_t *flags_for_op, grpc_call_error call_start_batch_expected_result) { grpc_call *c; gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); @@ -185,9 +185,9 @@ static void test_invoke_request_with_flags( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void request_with_flags(grpc_end2end_test_config config) { size_t i; - gpr_uint32 flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1]; + uint32_t flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1]; { /* check that all grpc_op_types fail when their flag value is set to an @@ -205,8 +205,8 @@ void grpc_end2end_tests(grpc_end2end_test_config config) { } { /* check valid operation with allowed flags for GRPC_OP_SEND_BUFFER */ - gpr_uint32 flags[] = {GRPC_WRITE_BUFFER_HINT, GRPC_WRITE_NO_COMPRESS, - GRPC_WRITE_INTERNAL_COMPRESS}; + uint32_t flags[] = {GRPC_WRITE_BUFFER_HINT, GRPC_WRITE_NO_COMPRESS, + GRPC_WRITE_INTERNAL_COMPRESS}; for (i = 0; i < GPR_ARRAY_SIZE(flags); ++i) { memset(flags_for_op, 0, sizeof(flags_for_op)); flags_for_op[GRPC_OP_SEND_MESSAGE] = flags[i]; diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index ee5b071372..1aced6a875 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -229,6 +229,6 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void request_with_payload(grpc_end2end_test_config config) { test_invoke_request_with_payload(config); } diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index 94863e7280..6bca8d476c 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -207,6 +207,6 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void server_finishes_request(grpc_end2end_test_config config) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index aa679081ec..b56ba464b9 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -189,6 +189,6 @@ static void test_early_server_shutdown_finishes_inflight_calls( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void shutdown_finishes_calls(grpc_end2end_test_config config) { test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/shutdown_finishes_tags.c b/test/core/end2end/tests/shutdown_finishes_tags.c index 53a1573e16..4a060de716 100644 --- a/test/core/end2end/tests/shutdown_finishes_tags.c +++ b/test/core/end2end/tests/shutdown_finishes_tags.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -116,6 +116,6 @@ static void test_early_server_shutdown_finishes_tags( cq_verifier_destroy(cqv); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void shutdown_finishes_tags(grpc_end2end_test_config config) { test_early_server_shutdown_finishes_tags(config); } diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 04447f9df4..0afef7503b 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(n); @@ -216,7 +216,7 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void simple_delayed_request(grpc_end2end_test_config config) { GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_simple_delayed_request_short(config); test_simple_delayed_request_long(config); diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index ce5df86a92..3720cd1631 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -47,7 +47,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -238,7 +238,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void simple_request(grpc_end2end_test_config config) { int i; for (i = 0; i < 10; i++) { test_invoke_simple_request(config); diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 71f10eb8f5..78525e9538 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -45,7 +45,7 @@ enum { TIMEOUT = 200000 }; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, const char *test_name, @@ -265,6 +265,6 @@ static void test_request_response_with_metadata_and_payload( config.tear_down_data(&f); } -void grpc_end2end_tests(grpc_end2end_test_config config) { +void trailing_metadata(grpc_end2end_test_config config) { test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/fling/server.c b/test/core/fling/server.c index ae218b4cc1..42be20e42d 100644 --- a/test/core/fling/server.c +++ b/test/core/fling/server.c @@ -73,7 +73,7 @@ static int was_cancelled = 2; static grpc_op unary_ops[6]; static int got_sigint = 0; -static void *tag(gpr_intptr t) { return (void *)t; } +static void *tag(intptr_t t) { return (void *)t; } typedef enum { FLING_SERVER_NEW_REQUEST = 1, @@ -87,7 +87,7 @@ typedef enum { typedef struct { gpr_refcount pending_ops; - gpr_uint32 flags; + uint32_t flags; } call_state; static void request_call(void) { @@ -256,7 +256,7 @@ int main(int argc, char **argv) { s = ev.tag; switch (ev.type) { case GRPC_OP_COMPLETE: - switch ((gpr_intptr)s) { + switch ((intptr_t)s) { case FLING_SERVER_NEW_REQUEST: if (call != NULL) { if (0 == diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index 4b72590819..a66fe32fde 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, gpr_uint8 *current_data) { + size_t *num_blocks, uint8_t *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; @@ -117,7 +117,7 @@ struct read_and_write_test_state { size_t current_write_size; size_t bytes_written; int current_read_data; - gpr_uint8 current_write_data; + uint8_t 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 4be6957a83..b186520729 100644 --- a/test/core/iomgr/fd_posix_test.c +++ b/test/core/iomgr/fd_posix_test.c @@ -84,7 +84,7 @@ static void create_test_socket(int port, int *socket_fd, sin->sin_family = AF_INET; sin->sin_addr.s_addr = htonl(0x7f000001); GPR_ASSERT(port >= 0 && port < 65536); - sin->sin_port = htons((gpr_uint16)port); + sin->sin_port = htons((uint16_t)port); } /* Dummy gRPC callback */ diff --git a/test/core/iomgr/sockaddr_utils_test.c b/test/core/iomgr/sockaddr_utils_test.c index 5cf0994f39..a7b57c1466 100644 --- a/test/core/iomgr/sockaddr_utils_test.c +++ b/test/core/iomgr/sockaddr_utils_test.c @@ -41,7 +41,7 @@ #include <grpc/support/port_platform.h> #include "test/core/util/test_config.h" -static struct sockaddr_in make_addr4(const gpr_uint8 *data, size_t data_len) { +static struct sockaddr_in make_addr4(const uint8_t *data, size_t data_len) { struct sockaddr_in addr4; memset(&addr4, 0, sizeof(addr4)); addr4.sin_family = AF_INET; @@ -51,7 +51,7 @@ static struct sockaddr_in make_addr4(const gpr_uint8 *data, size_t data_len) { return addr4; } -static struct sockaddr_in6 make_addr6(const gpr_uint8 *data, size_t data_len) { +static struct sockaddr_in6 make_addr6(const uint8_t *data, size_t data_len) { struct sockaddr_in6 addr6; memset(&addr6, 0, sizeof(addr6)); addr6.sin6_family = AF_INET6; @@ -61,15 +61,15 @@ static struct sockaddr_in6 make_addr6(const gpr_uint8 *data, size_t data_len) { return addr6; } -static const gpr_uint8 kMapped[] = {0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0xff, 0xff, 192, 0, 2, 1}; +static const uint8_t kMapped[] = {0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0xff, 0xff, 192, 0, 2, 1}; -static const gpr_uint8 kNotQuiteMapped[] = {0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0xff, 0xfe, 192, 0, 2, 99}; -static const gpr_uint8 kIPv4[] = {192, 0, 2, 1}; +static const uint8_t kNotQuiteMapped[] = {0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0xff, 0xfe, 192, 0, 2, 99}; +static const uint8_t kIPv4[] = {192, 0, 2, 1}; -static const gpr_uint8 kIPv6[] = {0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1}; +static const uint8_t kIPv6[] = {0x20, 0x01, 0x0d, 0xb8, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1}; static void test_sockaddr_is_v4mapped(void) { struct sockaddr_in input4; diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index 9feac931a3..b59ba1014b 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] = (gpr_uint8)i; + buf[i] = (uint8_t)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] = (gpr_uint8)(i % 256); + buf[i] = (uint8_t)(i % 256); } do { @@ -257,7 +257,7 @@ struct write_socket_state { }; static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, gpr_uint8 *current_data) { + size_t *num_blocks, uint8_t *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; @@ -337,7 +337,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { struct write_socket_state state; size_t num_blocks; gpr_slice *slices; - gpr_uint8 current_data = 0; + uint8_t current_data = 0; gpr_slice_buffer outgoing; grpc_closure write_done_closure; gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); @@ -389,7 +389,8 @@ void on_fd_released(grpc_exec_ctx *exec_ctx, void *arg, int success) { grpc_pollset_kick(&g_pollset, NULL); } -/* Do a read_test, then release fd and try to read/write again. */ +/* Do a read_test, then release fd and try to read/write again. Verify that + grpc_tcp_fd() is available before the fd is released. */ static void release_fd_test(size_t num_bytes, size_t slice_size) { int sv[2]; grpc_endpoint *ep; @@ -408,6 +409,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { create_sockets(sv); ep = grpc_tcp_create(grpc_fd_create(sv[1], "read_test"), slice_size, "test"); + GPR_ASSERT(grpc_tcp_fd(ep) == sv[1] && sv[1] >= 0); grpc_endpoint_add_to_pollset(&exec_ctx, ep, &g_pollset); written_bytes = fill_socket_partial(sv[0], num_bytes); diff --git a/test/core/iomgr/timer_heap_test.c b/test/core/iomgr/timer_heap_test.c index 941f61c5c7..077a9fd6bd 100644 --- a/test/core/iomgr/timer_heap_test.c +++ b/test/core/iomgr/timer_heap_test.c @@ -102,7 +102,7 @@ static size_t *all_top(grpc_timer_heap *pq, size_t *n) { } static void check_pq_top(grpc_timer *elements, grpc_timer_heap *pq, - gpr_uint8 *inpq, size_t num_elements) { + uint8_t *inpq, size_t num_elements) { gpr_timespec max_deadline = gpr_inf_past(GPR_CLOCK_REALTIME); size_t *max_deadline_indices = gpr_malloc(num_elements * sizeof(*max_deadline_indices)); @@ -160,7 +160,7 @@ static void test1(void) { const size_t num_test_operations = 10000; size_t i; grpc_timer *test_elements = create_test_elements(num_test_elements); - gpr_uint8 *inpq = gpr_malloc(num_test_elements); + uint8_t *inpq = gpr_malloc(num_test_elements); grpc_timer_heap_init(&pq); memset(inpq, 0, num_test_elements); diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c index 5a2d5b5a17..63014c3939 100644 --- a/test/core/iomgr/timer_list_test.c +++ b/test/core/iomgr/timer_list_test.c @@ -44,7 +44,7 @@ static int cb_called[MAX_CB][2]; static void cb(grpc_exec_ctx *exec_ctx, void *arg, int success) { - cb_called[(gpr_intptr)arg][success]++; + cb_called[(intptr_t)arg][success]++; } static void add_test(void) { @@ -60,7 +60,7 @@ static void add_test(void) { for (i = 0; i < 10; i++) { grpc_timer_init(&exec_ctx, &timers[i], gpr_time_add(start, gpr_time_from_millis(10, GPR_TIMESPAN)), - cb, (void *)(gpr_intptr)i, start); + cb, (void *)(intptr_t)i, start); } /* 1010 ms timers. will expire in the next epoch */ @@ -68,7 +68,7 @@ static void add_test(void) { grpc_timer_init( &exec_ctx, &timers[i], gpr_time_add(start, gpr_time_from_millis(1010, GPR_TIMESPAN)), cb, - (void *)(gpr_intptr)i, start); + (void *)(intptr_t)i, start); } /* collect timers. Only the first batch should be ready. */ @@ -130,15 +130,15 @@ void destruction_test(void) { grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME)); memset(cb_called, 0, sizeof(cb_called)); - grpc_timer_init(&exec_ctx, &timers[0], tfm(100), cb, (void *)(gpr_intptr)0, + grpc_timer_init(&exec_ctx, &timers[0], tfm(100), cb, (void *)(intptr_t)0, gpr_time_0(GPR_CLOCK_REALTIME)); - grpc_timer_init(&exec_ctx, &timers[1], tfm(3), cb, (void *)(gpr_intptr)1, + grpc_timer_init(&exec_ctx, &timers[1], tfm(3), cb, (void *)(intptr_t)1, gpr_time_0(GPR_CLOCK_REALTIME)); - grpc_timer_init(&exec_ctx, &timers[2], tfm(100), cb, (void *)(gpr_intptr)2, + grpc_timer_init(&exec_ctx, &timers[2], tfm(100), cb, (void *)(intptr_t)2, gpr_time_0(GPR_CLOCK_REALTIME)); - grpc_timer_init(&exec_ctx, &timers[3], tfm(3), cb, (void *)(gpr_intptr)3, + grpc_timer_init(&exec_ctx, &timers[3], tfm(3), cb, (void *)(intptr_t)3, gpr_time_0(GPR_CLOCK_REALTIME)); - grpc_timer_init(&exec_ctx, &timers[4], tfm(1), cb, (void *)(gpr_intptr)4, + grpc_timer_init(&exec_ctx, &timers[4], tfm(1), cb, (void *)(intptr_t)4, gpr_time_0(GPR_CLOCK_REALTIME)); GPR_ASSERT(1 == grpc_timer_check(&exec_ctx, tfm(2), NULL)); grpc_exec_ctx_finish(&exec_ctx); diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c index 42fdbd6d54..0c615a9975 100644 --- a/test/core/json/json_rewrite.c +++ b/test/core/json/json_rewrite.c @@ -94,33 +94,33 @@ static void json_reader_string_clear(void *userdata) { state->string_len = 0; } -static void json_reader_string_add_char(void *userdata, gpr_uint32 c) { +static void json_reader_string_add_char(void *userdata, uint32_t c) { json_reader_userdata *state = userdata; check_string(state, 1); GPR_ASSERT(c < 256); state->scratchpad[state->string_len++] = (char)c; } -static void json_reader_string_add_utf32(void *userdata, gpr_uint32 c) { +static void json_reader_string_add_utf32(void *userdata, uint32_t c) { if (c <= 0x7f) { json_reader_string_add_char(userdata, c); } else if (c <= 0x7ff) { - gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu); - gpr_uint32 b2 = 0x80u | (c & 0x3fu); + uint32_t b1 = 0xc0u | ((c >> 6u) & 0x1fu); + uint32_t b2 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); } else if (c <= 0xffffu) { - gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu); - gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu); - gpr_uint32 b3 = 0x80u | (c & 0x3fu); + uint32_t b1 = 0xe0u | ((c >> 12u) & 0x0fu); + uint32_t b2 = 0x80u | ((c >> 6u) & 0x3fu); + uint32_t b3 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); } else if (c <= 0x1fffffu) { - gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u); - gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu); - gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu); - gpr_uint32 b4 = 0x80u | (c & 0x3fu); + uint32_t b1 = 0xf0u | ((c >> 18u) & 0x07u); + uint32_t b2 = 0x80u | ((c >> 12u) & 0x3fu); + uint32_t b3 = 0x80u | ((c >> 6u) & 0x3fu); + uint32_t b4 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); @@ -128,13 +128,13 @@ static void json_reader_string_add_utf32(void *userdata, gpr_uint32 c) { } } -static gpr_uint32 json_reader_read_char(void *userdata) { +static uint32_t json_reader_read_char(void *userdata) { int r; json_reader_userdata *state = userdata; r = fgetc(state->in); if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF; - return (gpr_uint32)r; + return (uint32_t)r; } static void json_reader_container_begins(void *userdata, grpc_json_type type) { diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.c index 644a1426e9..d99cb0dd03 100644 --- a/test/core/json/json_rewrite_test.c +++ b/test/core/json/json_rewrite_test.c @@ -105,33 +105,33 @@ static void json_reader_string_clear(void *userdata) { state->string_len = 0; } -static void json_reader_string_add_char(void *userdata, gpr_uint32 c) { +static void json_reader_string_add_char(void *userdata, uint32_t c) { json_reader_userdata *state = userdata; check_string(state, 1); GPR_ASSERT(c <= 256); state->scratchpad[state->string_len++] = (char)c; } -static void json_reader_string_add_utf32(void *userdata, gpr_uint32 c) { +static void json_reader_string_add_utf32(void *userdata, uint32_t c) { if (c <= 0x7f) { json_reader_string_add_char(userdata, c); } else if (c <= 0x7ffu) { - gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu); - gpr_uint32 b2 = 0x80u | (c & 0x3fu); + uint32_t b1 = 0xc0u | ((c >> 6u) & 0x1fu); + uint32_t b2 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); } else if (c <= 0xffffu) { - gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu); - gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu); - gpr_uint32 b3 = 0x80u | (c & 0x3fu); + uint32_t b1 = 0xe0u | ((c >> 12u) & 0x0fu); + uint32_t b2 = 0x80u | ((c >> 6u) & 0x3fu); + uint32_t b3 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); } else if (c <= 0x1fffffu) { - gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u); - gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu); - gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu); - gpr_uint32 b4 = 0x80u | (c & 0x3fu); + uint32_t b1 = 0xf0u | ((c >> 18u) & 0x07u); + uint32_t b2 = 0x80u | ((c >> 12u) & 0x3fu); + uint32_t b3 = 0x80u | ((c >> 6u) & 0x3fu); + uint32_t b4 = 0x80u | (c & 0x3fu); json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b3); @@ -139,7 +139,7 @@ static void json_reader_string_add_utf32(void *userdata, gpr_uint32 c) { } } -static gpr_uint32 json_reader_read_char(void *userdata) { +static uint32_t json_reader_read_char(void *userdata) { int r; json_reader_userdata *state = userdata; @@ -152,7 +152,7 @@ static gpr_uint32 json_reader_read_char(void *userdata) { r = fgetc(state->in); if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF; - return (gpr_uint32)r; + return (uint32_t)r; } static void json_reader_container_begins(void *userdata, grpc_json_type type) { diff --git a/test/core/json/json_stream_error_test.c b/test/core/json/json_stream_error_test.c index 3464eb2a9c..400776759d 100644 --- a/test/core/json/json_stream_error_test.c +++ b/test/core/json/json_stream_error_test.c @@ -49,9 +49,7 @@ static void string_clear(void *userdata) { g_string_clear_once = 1; } -static gpr_uint32 read_char(void *userdata) { - return GRPC_JSON_READ_CHAR_ERROR; -} +static uint32_t read_char(void *userdata) { return GRPC_JSON_READ_CHAR_ERROR; } static grpc_json_reader_vtable reader_vtable = { string_clear, NULL, NULL, read_char, NULL, NULL, diff --git a/test/core/security/base64_test.c b/test/core/security/base64_test.c index a8f784d4fa..e656d4c947 100644 --- a/test/core/security/base64_test.c +++ b/test/core/security/base64_test.c @@ -71,7 +71,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) { size_t i; char *b64; gpr_slice orig_decoded; - for (i = 0; i < sizeof(orig); i++) orig[i] = (gpr_uint8)i; + for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; /* Try all the different paddings. */ for (i = 0; i < 3; i++) { @@ -123,7 +123,7 @@ static void test_url_safe_unsafe_mismtach_failure(void) { char *b64; gpr_slice orig_decoded; int url_safe = 1; - for (i = 0; i < sizeof(orig); i++) orig[i] = (gpr_uint8)i; + for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0); orig_decoded = grpc_base64_decode(b64, !url_safe); diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index d36dda37ed..9f37e0374c 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -487,7 +487,7 @@ static void test_jwt_verifier_bad_json_key(void) { static void corrupt_jwt_sig(char *jwt) { gpr_slice sig; char *bad_b64_sig; - gpr_uint8 *sig_bytes; + uint8_t *sig_bytes; char *last_dot = strrchr(jwt, '.'); GPR_ASSERT(last_dot != NULL); sig = grpc_base64_decode(last_dot + 1, 1); diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c index 8aa80cca18..240c4596b4 100644 --- a/test/core/security/secure_endpoint_test.c +++ b/test/core/security/secure_endpoint_test.c @@ -68,12 +68,12 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( size_t still_pending_size; size_t total_buffer_size = 8192; size_t buffer_size = total_buffer_size; - gpr_uint8 *encrypted_buffer = gpr_malloc(buffer_size); - gpr_uint8 *cur = encrypted_buffer; + uint8_t *encrypted_buffer = gpr_malloc(buffer_size); + uint8_t *cur = encrypted_buffer; gpr_slice encrypted_leftover; for (i = 0; i < leftover_nslices; i++) { gpr_slice plain = leftover_slices[i]; - gpr_uint8 *message_bytes = GPR_SLICE_START_PTR(plain); + uint8_t *message_bytes = GPR_SLICE_START_PTR(plain); size_t message_size = GPR_SLICE_LENGTH(plain); while (message_size > 0) { size_t protected_buffer_size_to_send = buffer_size; diff --git a/test/core/statistics/census_log_tests.c b/test/core/statistics/census_log_tests.c index 6968a5646d..aac20fd96a 100644 --- a/test/core/statistics/census_log_tests.c +++ b/test/core/statistics/census_log_tests.c @@ -47,22 +47,22 @@ /* Fills in 'record' of size 'size'. Each byte in record is filled in with the same value. The value is extracted from 'record' pointer. */ static void write_record(char *record, size_t size) { - char data = (gpr_uintptr)record % 255; + char data = (uintptr_t)record % 255; memset(record, data, size); } /* Reads fixed size records. Returns the number of records read in 'num_records'. */ static void read_records(size_t record_size, const char *buffer, - size_t buffer_size, gpr_int32 *num_records) { - gpr_int32 ix; + size_t buffer_size, int32_t *num_records) { + int32_t ix; GPR_ASSERT(buffer_size >= record_size); GPR_ASSERT(buffer_size % record_size == 0); *num_records = buffer_size / record_size; for (ix = 0; ix < *num_records; ++ix) { size_t jx; const char *record = buffer + (record_size * ix); - char data = (gpr_uintptr)record % 255; + char data = (uintptr_t)record % 255; for (jx = 0; jx < record_size; ++jx) { GPR_ASSERT(data == record[jx]); } @@ -72,14 +72,14 @@ static void read_records(size_t record_size, const char *buffer, /* Tries to write the specified number of records. Stops when the log gets full. Returns the number of records written. Spins for random number of times, up to 'max_spin_count', between writes. */ -static size_t write_records_to_log(int writer_id, gpr_int32 record_size, - gpr_int32 num_records, - gpr_int32 max_spin_count) { - gpr_int32 ix; +static size_t write_records_to_log(int writer_id, int32_t record_size, + int32_t num_records, + int32_t max_spin_count) { + int32_t ix; int counter = 0; for (ix = 0; ix < num_records; ++ix) { - gpr_int32 jx; - gpr_int32 spin_count = max_spin_count ? rand() % max_spin_count : 0; + int32_t jx; + int32_t spin_count = max_spin_count ? rand() % max_spin_count : 0; char *record; if (counter++ == num_records / 10) { printf(" Writer %d: %d out of %d written\n", writer_id, ix, @@ -106,7 +106,7 @@ static size_t perform_read_iteration(size_t record_size) { size_t records_read = 0; census_log_init_reader(); while ((read_buffer = census_log_read_next(&bytes_available))) { - gpr_int32 num_records = 0; + int32_t num_records = 0; read_records(record_size, (const char *)read_buffer, bytes_available, &num_records); records_read += num_records; @@ -122,14 +122,14 @@ static void assert_log_empty(void) { } /* Given log size and record size, computes the minimum usable space. */ -static gpr_int32 min_usable_space(size_t log_size, size_t record_size) { - gpr_int32 usable_space; - gpr_int32 num_blocks = +static int32_t min_usable_space(size_t log_size, size_t record_size) { + int32_t usable_space; + int32_t num_blocks = GPR_MAX(log_size / CENSUS_LOG_MAX_RECORD_SIZE, gpr_cpu_num_cores()); - gpr_int32 waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size; + int32_t waste_per_block = CENSUS_LOG_MAX_RECORD_SIZE % record_size; /* In the worst case, all except one core-local block is full. */ - gpr_int32 num_full_blocks = num_blocks - 1; - usable_space = (gpr_int32)log_size - + int32_t num_full_blocks = num_blocks - 1; + usable_space = (int32_t)log_size - (num_full_blocks * CENSUS_LOG_MAX_RECORD_SIZE) - ((num_blocks - num_full_blocks) * waste_per_block); GPR_ASSERT(usable_space > 0); @@ -142,9 +142,9 @@ static gpr_int32 min_usable_space(size_t log_size, size_t record_size) { match the number of records read. */ static void fill_log(size_t log_size, int no_fragmentation, int circular_log) { int size; - gpr_int32 records_written; - gpr_int32 usable_space; - gpr_int32 records_read; + int32_t records_written; + int32_t usable_space; + int32_t records_read; if (no_fragmentation) { int log2size = rand() % (CENSUS_LOG_2_MAX_RECORD_SIZE + 1); size = (1 << log2size); @@ -175,7 +175,7 @@ typedef struct writer_thread_args { /* Record size. */ size_t record_size; /* Number of records to write. */ - gpr_int32 num_records; + int32_t num_records; /* Used to signal when writer is complete */ gpr_cv *done; gpr_mu *mu; @@ -187,7 +187,7 @@ typedef struct writer_thread_args { static void writer_thread(void *arg) { writer_thread_args *args = (writer_thread_args *)arg; /* Maximum number of times to spin between writes. */ - static const gpr_int32 MAX_SPIN_COUNT = 50; + static const int32_t MAX_SPIN_COUNT = 50; int records_written = 0; printf(" Writer: %d\n", args->index); while (records_written < args->num_records) { @@ -215,9 +215,9 @@ typedef struct reader_thread_args { /* Record size. */ size_t record_size; /* Interval between read iterations. */ - gpr_int32 read_iteration_interval_in_msec; + int32_t read_iteration_interval_in_msec; /* Total number of records. */ - gpr_int32 total_records; + int32_t total_records; /* Signalled when reader should stop. */ gpr_cv stop; int stop_flag; @@ -231,9 +231,9 @@ typedef struct reader_thread_args { stopped via gpr_cv_signal(&args->stop). Sleeps for 'read_interval_in_msec' between read iterations. */ static void reader_thread(void *arg) { - gpr_int32 records_read = 0; + int32_t records_read = 0; reader_thread_args *args = (reader_thread_args *)arg; - gpr_int32 num_iterations = 0; + int32_t num_iterations = 0; gpr_timespec interval; int counter = 0; printf(" Reader starting\n"); @@ -268,9 +268,9 @@ static void reader_thread(void *arg) { #define NUM_WRITERS 5 static void multiple_writers_single_reader(int circular_log) { /* Sleep interval between read iterations. */ - static const gpr_int32 READ_ITERATION_INTERVAL_IN_MSEC = 10; + static const int32_t READ_ITERATION_INTERVAL_IN_MSEC = 10; /* Number of records written by each writer. */ - static const gpr_int32 NUM_RECORDS_PER_WRITER = 10 * 1024 * 1024; + static const int32_t NUM_RECORDS_PER_WRITER = 10 * 1024 * 1024; /* Maximum record size. */ static const size_t MAX_RECORD_SIZE = 10; int ix; @@ -282,7 +282,7 @@ static void multiple_writers_single_reader(int circular_log) { gpr_cv reader_done; gpr_mu reader_mu; /* protects reader_done and reader.running */ reader_thread_args reader; - gpr_int32 record_size = 1 + rand() % MAX_RECORD_SIZE; + int32_t record_size = 1 + rand() % MAX_RECORD_SIZE; printf(" Record size: %d\n", record_size); /* Create and start writers. */ gpr_cv_init(&writers_done); @@ -417,8 +417,8 @@ void test_read_pending_record(void) { /* Tries reading beyond pending write. */ void test_read_beyond_pending_record(void) { /* Start a write. */ - gpr_uint32 incomplete_record_size = 10; - gpr_uint32 complete_record_size = 20; + uint32_t incomplete_record_size = 10; + uint32_t complete_record_size = 20; size_t bytes_available; void *complete_record; const void *record_read; @@ -459,7 +459,7 @@ void test_detached_while_reading(void) { size_t bytes_available; const void *record_read; void *record_written; - gpr_uint32 block_read = 0; + uint32_t block_read = 0; printf("Starting test: detached while reading\n"); setup_test(0); /* Start a write. */ diff --git a/test/core/statistics/hash_table_test.c b/test/core/statistics/hash_table_test.c index efebd790f2..3b119dbc0c 100644 --- a/test/core/statistics/hash_table_test.c +++ b/test/core/statistics/hash_table_test.c @@ -44,9 +44,9 @@ #include <grpc/support/time.h> #include "test/core/util/test_config.h" -static gpr_uint64 hash64(const void *k) { +static uint64_t hash64(const void *k) { size_t len = strlen(k); - gpr_uint64 higher = gpr_murmur_hash3((const char *)k, len / 2, 0); + uint64_t higher = gpr_murmur_hash3((const char *)k, len / 2, 0); return higher << 32 | gpr_murmur_hash3((const char *)(k) + len / 2, len - len / 2, 0); } @@ -55,7 +55,7 @@ static int cmp_str_keys(const void *k1, const void *k2) { return strcmp((const char *)k1, (const char *)k2); } -static gpr_uint64 force_collision(const void *k) { +static uint64_t force_collision(const void *k) { return (1997 + hash64(k) % 3); } @@ -85,8 +85,8 @@ static void test_create_table(void) { static void test_table_with_int_key(void) { census_ht_option opt = {CENSUS_HT_UINT64, 7, NULL, NULL, NULL, NULL}; census_ht *ht = census_ht_create(&opt); - gpr_uint64 i = 0; - gpr_uint64 sum_of_keys = 0; + uint64_t i = 0; + uint64_t sum_of_keys = 0; size_t num_elements; census_ht_kv *elements = NULL; GPR_ASSERT(ht != NULL); @@ -97,15 +97,15 @@ static void test_table_with_int_key(void) { for (i = 0; i < 20; ++i) { census_ht_key key; key.val = i; - census_ht_insert(ht, key, (void *)(gpr_intptr)i); + census_ht_insert(ht, key, (void *)(intptr_t)i); GPR_ASSERT(census_ht_get_size(ht) == i + 1); } for (i = 0; i < 20; i++) { - gpr_uint64 *val = NULL; + uint64_t *val = NULL; census_ht_key key; key.val = i; val = census_ht_find(ht, key); - GPR_ASSERT(val == (void *)(gpr_intptr)i); + GPR_ASSERT(val == (void *)(intptr_t)i); } elements = census_ht_get_all_elements(ht, &num_elements); GPR_ASSERT(elements != NULL); @@ -189,7 +189,7 @@ static void test_insertion_and_deletion_with_high_collision_rate(void) { &cmp_str_keys, NULL, NULL}; census_ht *ht = census_ht_create(&opt); char key_str[1000][GPR_LTOA_MIN_BUFSIZE]; - gpr_uint64 val = 0; + uint64_t val = 0; unsigned i = 0; for (i = 0; i < 1000; i++) { census_ht_key key; @@ -246,7 +246,7 @@ static void test_table_with_string_key(void) { for (i = 0; i < 9; i++) { census_ht_key key; int *val_ptr; - gpr_uint32 expected_tbl_sz = 9 - i; + uint32_t expected_tbl_sz = 9 - i; GPR_ASSERT(census_ht_get_size(ht) == expected_tbl_sz); key.ptr = (void *)(keys[i]); val_ptr = census_ht_find(ht, key); diff --git a/test/core/support/alloc_test.c b/test/core/support/alloc_test.c index b950f0ab49..a7051a46a1 100644 --- a/test/core/support/alloc_test.c +++ b/test/core/support/alloc_test.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,17 +39,17 @@ static void *fake_malloc(size_t size) { return (void *)size; } static void *fake_realloc(void *addr, size_t size) { return (void *)size; } -static void fake_free(void *addr) { *((gpr_intptr *)addr) = 0xdeadd00d; } +static void fake_free(void *addr) { *((intptr_t *)addr) = 0xdeadd00d; } static void test_custom_allocs() { const gpr_allocation_functions default_fns = gpr_get_allocation_functions(); - gpr_intptr addr_to_free = 0; + intptr_t addr_to_free = 0; int *i; gpr_allocation_functions fns = {fake_malloc, fake_realloc, fake_free}; gpr_set_allocation_functions(fns); - GPR_ASSERT((void *)0xdeadbeef == gpr_malloc(0xdeadbeef)); - GPR_ASSERT((void *)0xcafed00d == gpr_realloc(0, 0xcafed00d)); + GPR_ASSERT((void *)(size_t)0xdeadbeef == gpr_malloc(0xdeadbeef)); + GPR_ASSERT((void *)(size_t)0xcafed00d == gpr_realloc(0, 0xcafed00d)); gpr_free(&addr_to_free); GPR_ASSERT(addr_to_free == 0xdeadd00d); diff --git a/test/core/support/cpu_test.c b/test/core/support/cpu_test.c index fa83878a15..a5c52442ad 100644 --- a/test/core/support/cpu_test.c +++ b/test/core/support/cpu_test.c @@ -69,18 +69,18 @@ struct cpu_test { gpr_mu mu; int nthreads; - gpr_uint32 ncores; + uint32_t ncores; int is_done; gpr_cv done_cv; - int *used; /* is this core used? */ - int r; /* random number */ + int *used; /* is this core used? */ + unsigned r; /* random number */ }; static void worker_thread(void *arg) { struct cpu_test *ct = (struct cpu_test *)arg; - gpr_uint32 cpu; - int r = 12345678; - int i, j; + uint32_t cpu; + unsigned r = 12345678; + unsigned i, j; for (i = 0; i < 1000 / GRPC_TEST_SLOWDOWN_FACTOR; i++) { /* run for a bit - just calculate something random. */ for (j = 0; j < 1000000 / GRPC_TEST_SLOWDOWN_FACTOR; j++) { @@ -90,7 +90,13 @@ static void worker_thread(void *arg) { GPR_ASSERT(cpu < ct->ncores); gpr_mu_lock(&ct->mu); ct->used[cpu] = 1; + for (j = 0; j < ct->ncores; j++) { + if (!ct->used[j]) break; + } gpr_mu_unlock(&ct->mu); + if (j == ct->ncores) { + break; /* all cpus have been used - no further use in running this test */ + } } gpr_mu_lock(&ct->mu); ct->r = r; /* make it look like we care about r's value... */ @@ -103,7 +109,7 @@ static void worker_thread(void *arg) { } static void cpu_test(void) { - gpr_uint32 i; + uint32_t i; int cores_seen = 0; struct cpu_test ct; gpr_thd_id thd; diff --git a/test/core/support/murmur_hash_test.c b/test/core/support/murmur_hash_test.c index 1762486776..562b9567e7 100644 --- a/test/core/support/murmur_hash_test.c +++ b/test/core/support/murmur_hash_test.c @@ -38,16 +38,16 @@ #include <string.h> -typedef gpr_uint32 (*hash_func)(const void *key, size_t len, gpr_uint32 seed); +typedef uint32_t (*hash_func)(const void *key, size_t len, uint32_t seed); /* From smhasher: This should hopefully be a thorough and uambiguous test of whether a hash is correctly implemented on a given platform */ -static void verification_test(hash_func hash, gpr_uint32 expected) { - gpr_uint8 key[256]; - gpr_uint32 hashes[256]; - gpr_uint32 final = 0; +static void verification_test(hash_func hash, uint32_t expected) { + uint8_t key[256]; + uint32_t hashes[256]; + uint32_t final = 0; size_t i; memset(key, 0, sizeof(key)); @@ -57,8 +57,8 @@ static void verification_test(hash_func hash, gpr_uint32 expected) { the seed */ for (i = 0; i < 256; i++) { - key[i] = (gpr_uint8)i; - hashes[i] = hash(key, i, (gpr_uint32)(256u - i)); + key[i] = (uint8_t)i; + hashes[i] = hash(key, i, (uint32_t)(256u - i)); } /* Then hash the result array */ diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c index 9e0e22c24b..2df38376a9 100644 --- a/test/core/support/slice_test.c +++ b/test/core/support/slice_test.c @@ -66,7 +66,7 @@ static void test_slice_malloc_returns_something_sensible(void) { } /* We must be able to write to every byte of the data */ for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* And finally we must succeed in destroying the slice */ gpr_slice_unref(slice); @@ -76,7 +76,7 @@ static void test_slice_malloc_returns_something_sensible(void) { static void do_nothing(void *ignored) {} static void test_slice_new_returns_something_sensible(void) { - gpr_uint8 x; + uint8_t x; gpr_slice slice = gpr_slice_new(&x, 1, do_nothing); GPR_ASSERT(slice.refcount); @@ -93,7 +93,7 @@ static void do_nothing_with_len_1(void *ignored, size_t len) { } static void test_slice_new_with_len_returns_something_sensible(void) { - gpr_uint8 x; + uint8_t x; int num_refs = 5; /* To test adding/removing an arbitrary number of refs */ int i; @@ -131,7 +131,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] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -141,7 +141,7 @@ static void test_slice_sub_works(unsigned length) { sub = gpr_slice_sub(slice, i, j); GPR_ASSERT(GPR_SLICE_LENGTH(sub) == j - i); for (k = 0; k < j - i; k++) { - GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (gpr_uint8)(i + k)); + GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k)); } gpr_slice_unref(sub); } @@ -170,7 +170,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] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -198,7 +198,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] = (gpr_uint8)i; + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c index c97d3176c5..c1d0f12250 100644 --- a/test/core/support/string_test.c +++ b/test/core/support/string_test.c @@ -59,7 +59,7 @@ static void test_strdup(void) { GPR_ASSERT(NULL == gpr_strdup(NULL)); } -static void expect_dump(const char *buf, size_t len, gpr_uint32 flags, +static void expect_dump(const char *buf, size_t len, uint32_t flags, const char *result) { char *got = gpr_dump(buf, len, flags); GPR_ASSERT(0 == strcmp(got, result)); @@ -76,7 +76,7 @@ static void test_dump(void) { expect_dump("ab", 2, GPR_DUMP_HEX | GPR_DUMP_ASCII, "61 62 'ab'"); } -static void expect_slice_dump(gpr_slice slice, gpr_uint32 flags, +static void expect_slice_dump(gpr_slice slice, uint32_t flags, const char *result) { char *got = gpr_dump_slice(slice, flags); GPR_ASSERT(0 == strcmp(got, result)); @@ -105,12 +105,12 @@ static void test_dump_slice(void) { } static void test_pu32_fail(const char *s) { - gpr_uint32 out; + uint32_t out; GPR_ASSERT(!gpr_parse_bytes_to_uint32(s, strlen(s), &out)); } -static void test_pu32_succeed(const char *s, gpr_uint32 want) { - gpr_uint32 out; +static void test_pu32_succeed(const char *s, uint32_t want) { + uint32_t out; GPR_ASSERT(gpr_parse_bytes_to_uint32(s, strlen(s), &out)); GPR_ASSERT(out == want); } @@ -318,19 +318,19 @@ static void test_int64toa() { LOG_TEST_NAME("test_int64toa"); /* zero */ - GPR_ASSERT(1 == gpr_int64toa(0, buf)); + GPR_ASSERT(1 == int64_ttoa(0, buf)); GPR_ASSERT(0 == strcmp("0", buf)); /* positive */ - GPR_ASSERT(3 == gpr_int64toa(123, buf)); + GPR_ASSERT(3 == int64_ttoa(123, buf)); GPR_ASSERT(0 == strcmp("123", buf)); /* large positive */ - GPR_ASSERT(19 == gpr_int64toa(9223372036854775807LL, buf)); + GPR_ASSERT(19 == int64_ttoa(9223372036854775807LL, buf)); GPR_ASSERT(0 == strcmp("9223372036854775807", buf)); /* large negative */ - GPR_ASSERT(20 == gpr_int64toa(-9223372036854775807LL - 1, buf)); + GPR_ASSERT(20 == int64_ttoa(-9223372036854775807LL - 1, buf)); GPR_ASSERT(0 == strcmp("-9223372036854775808", buf)); } diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c index 73f68e4dbd..0149bc3afd 100644 --- a/test/core/support/sync_test.c +++ b/test/core/support/sync_test.c @@ -149,8 +149,8 @@ int queue_remove(queue *q, int *head, gpr_timespec abs_deadline) { struct test { int threads; /* number of threads */ - gpr_int64 iterations; /* number of iterations per thread */ - gpr_int64 counter; + int64_t iterations; /* number of iterations per thread */ + int64_t counter; int thread_count; /* used to allocate thread ids */ int done; /* threads not yet completed */ int incr_step; /* how much to increment/decrement refcount each time */ @@ -171,7 +171,7 @@ struct test { }; /* Return pointer to a new struct test. */ -static struct test *test_new(int threads, gpr_int64 iterations, int incr_step) { +static struct test *test_new(int threads, int64_t iterations, int incr_step) { struct test *m = gpr_malloc(sizeof(*m)); m->threads = threads; m->iterations = iterations; @@ -246,7 +246,7 @@ static void mark_thread_done(struct test *m) { */ static void test(const char *name, void (*body)(void *m), void (*extra)(void *m), int timeout_s, int incr_step) { - gpr_int64 iterations = 1024; + int64_t iterations = 1024; struct test *m; gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; @@ -279,7 +279,7 @@ static void test(const char *name, void (*body)(void *m), /* Increment m->counter on each iteration; then mark thread as done. */ static void inc(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_mu_lock(&m->mu); m->counter++; @@ -292,7 +292,7 @@ static void inc(void *v /*=m*/) { then mark thread as done. */ static void inctry(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations;) { if (gpr_mu_trylock(&m->mu)) { m->counter++; @@ -307,7 +307,7 @@ static void inctry(void *v /*=m*/) { thread as done. */ static void inc_by_turns(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; int id = thread_id(m); for (i = 0; i != m->iterations; i++) { gpr_mu_lock(&m->mu); @@ -325,7 +325,7 @@ static void inc_by_turns(void *v /*=m*/) { then mark thread as done. */ static void inc_with_1ms_delay(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_timespec deadline; gpr_mu_lock(&m->mu); @@ -343,7 +343,7 @@ static void inc_with_1ms_delay(void *v /*=m*/) { for timing; then mark thread as done. */ static void inc_with_1ms_delay_event(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_timespec deadline; deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), @@ -361,7 +361,7 @@ static void inc_with_1ms_delay_event(void *v /*=m*/) { until it succeeds. */ static void many_producers(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; int x = thread_id(m); if ((x & 1) == 0) { for (i = 0; i != m->iterations; i++) { @@ -381,8 +381,8 @@ static void many_producers(void *v /*=m*/) { then mark thread as done. */ static void consumer(void *v /*=m*/) { struct test *m = v; - gpr_int64 n = m->iterations * m->threads; - gpr_int64 i; + int64_t n = m->iterations * m->threads; + int64_t i; int value; for (i = 0; i != n; i++) { queue_remove(&m->q, &value, gpr_inf_future(GPR_CLOCK_REALTIME)); @@ -401,7 +401,7 @@ static void consumer(void *v /*=m*/) { m->counter, then mark thread as done. */ static void statsinc(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { gpr_stats_inc(&m->stats_counter, 1); } @@ -416,7 +416,7 @@ static void statsinc(void *v /*=m*/) { then mark thread as done. */ static void refinc(void *v /*=m*/) { struct test *m = v; - gpr_int64 i; + int64_t i; for (i = 0; i != m->iterations; i++) { if (m->incr_step == 1) { gpr_ref(&m->refcount); @@ -435,8 +435,8 @@ static void refinc(void *v /*=m*/) { decrement caused the counter to reach zero, then mark thread as done. */ static void refcheck(void *v /*=m*/) { struct test *m = v; - gpr_int64 n = m->iterations * m->threads * m->incr_step; - gpr_int64 i; + int64_t n = m->iterations * m->threads * m->incr_step; + int64_t i; GPR_ASSERT(gpr_event_wait(&m->event, gpr_inf_future(GPR_CLOCK_REALTIME)) == (void *)1); GPR_ASSERT(gpr_event_get(&m->event) == (void *)1); diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c index b921052e7b..fc26f94d29 100644 --- a/test/core/support/time_test.c +++ b/test/core/support/time_test.c @@ -49,7 +49,7 @@ static void to_fp(void *arg, const char *buf, size_t len) { /* Convert gpr_uintmax x to ascii base b (2..16), and write with (*writer)(arg, ...), zero padding to "chars" digits). */ -static void u_to_s(gpr_uintmax x, unsigned base, int chars, +static void u_to_s(uintmax_t x, unsigned base, int chars, void (*writer)(void *arg, const char *buf, size_t len), void *arg) { char buf[64]; @@ -64,14 +64,14 @@ static void u_to_s(gpr_uintmax x, unsigned base, int chars, /* Convert gpr_intmax x to ascii base b (2..16), and write with (*writer)(arg, ...), zero padding to "chars" digits). */ -static void i_to_s(gpr_intmax x, unsigned base, int chars, +static void i_to_s(intmax_t x, unsigned base, int chars, void (*writer)(void *arg, const char *buf, size_t len), void *arg) { if (x < 0) { (*writer)(arg, "-", 1); - u_to_s((gpr_uintmax)-x, base, chars - 1, writer, arg); + u_to_s((uintmax_t)-x, base, chars - 1, writer, arg); } else { - u_to_s((gpr_uintmax)x, base, chars, writer, arg); + u_to_s((uintmax_t)x, base, chars, writer, arg); } } diff --git a/test/core/support/tls_test.c b/test/core/support/tls_test.c index 0a3c28417f..c6fb1a4a26 100644 --- a/test/core/support/tls_test.c +++ b/test/core/support/tls_test.c @@ -46,7 +46,7 @@ GPR_TLS_DECL(test_var); static void thd_body(void *arg) { - gpr_intptr i; + intptr_t i; GPR_ASSERT(gpr_tls_get(&test_var) == 0); diff --git a/test/core/support/useful_test.c b/test/core/support/useful_test.c index cbf4f02e26..3665bbf972 100644 --- a/test/core/support/useful_test.c +++ b/test/core/support/useful_test.c @@ -39,7 +39,7 @@ int main(int argc, char **argv) { int four[4]; int five[5]; - gpr_uint32 bitset = 0; + uint32_t bitset = 0; grpc_test_init(argc, argv); GPR_ASSERT(GPR_MIN(1, 2) == 1); @@ -51,8 +51,8 @@ int main(int argc, char **argv) { GPR_ASSERT(GPR_CLAMP(2, 0, 2) == 2); GPR_ASSERT(GPR_CLAMP(-1, 0, 2) == 0); GPR_ASSERT(GPR_CLAMP(3, 0, 2) == 2); - GPR_ASSERT(GPR_ROTL((gpr_uint32)0x80000001, 1) == 3); - GPR_ASSERT(GPR_ROTR((gpr_uint32)0x80000001, 1) == 0xc0000000); + GPR_ASSERT(GPR_ROTL((uint32_t)0x80000001, 1) == 3); + GPR_ASSERT(GPR_ROTR((uint32_t)0x80000001, 1) == 0xc0000000); GPR_ASSERT(GPR_ARRAY_SIZE(four) == 4); GPR_ASSERT(GPR_ARRAY_SIZE(five) == 5); diff --git a/test/core/surface/alarm_test.c b/test/core/surface/alarm_test.c index 52fe4ea084..054c328389 100644 --- a/test/core/surface/alarm_test.c +++ b/test/core/surface/alarm_test.c @@ -41,7 +41,7 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) static void *create_test_tag(void) { - static gpr_intptr i = 0; + static intptr_t i = 0; return (void *)(++i); } diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c index 252fe80621..ec49840ba8 100644 --- a/test/core/surface/completion_queue_test.c +++ b/test/core/surface/completion_queue_test.c @@ -44,7 +44,7 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) static void *create_test_tag(void) { - static gpr_intptr i = 0; + static intptr_t i = 0; return (void *)(++i); } @@ -226,7 +226,7 @@ static void test_too_many_plucks(void) { } /* wait until all other threads are plucking */ - gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100)); + gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(1000)); ev = grpc_completion_queue_pluck(cc, create_test_tag(), gpr_inf_future(GPR_CLOCK_REALTIME), NULL); @@ -274,29 +274,28 @@ static void producer_thread(void *arg) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_log(GPR_INFO, "producer %d started", opt->id); - gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_started, (void *)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); gpr_log(GPR_INFO, "producer %d phase 1", opt->id); for (i = 0; i < TEST_THREAD_EVENTS; i++) { - grpc_cq_begin_op(opt->cc, (void *)(gpr_intptr)1); + grpc_cq_begin_op(opt->cc, (void *)(intptr_t)1); } gpr_log(GPR_INFO, "producer %d phase 1 done", opt->id); - gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); gpr_log(GPR_INFO, "producer %d phase 2", opt->id); for (i = 0; i < TEST_THREAD_EVENTS; i++) { - grpc_cq_end_op(&exec_ctx, opt->cc, (void *)(gpr_intptr)1, 1, - free_completion, NULL, - gpr_malloc(sizeof(grpc_cq_completion))); + grpc_cq_end_op(&exec_ctx, opt->cc, (void *)(intptr_t)1, 1, free_completion, + NULL, gpr_malloc(sizeof(grpc_cq_completion))); opt->events_triggered++; grpc_exec_ctx_finish(&exec_ctx); } gpr_log(GPR_INFO, "producer %d phase 2 done", opt->id); - gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_finished, (void *)(intptr_t)1); grpc_exec_ctx_finish(&exec_ctx); } @@ -305,13 +304,13 @@ static void consumer_thread(void *arg) { grpc_event ev; gpr_log(GPR_INFO, "consumer %d started", opt->id); - gpr_event_set(&opt->on_started, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_started, (void *)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase1, ten_seconds_time())); gpr_log(GPR_INFO, "consumer %d phase 1", opt->id); gpr_log(GPR_INFO, "consumer %d phase 1 done", opt->id); - gpr_event_set(&opt->on_phase1_done, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_phase1_done, (void *)(intptr_t)1); GPR_ASSERT(gpr_event_wait(opt->phase2, ten_seconds_time())); gpr_log(GPR_INFO, "consumer %d phase 2", opt->id); @@ -324,7 +323,7 @@ static void consumer_thread(void *arg) { break; case GRPC_QUEUE_SHUTDOWN: gpr_log(GPR_INFO, "consumer %d phase 2 done", opt->id); - gpr_event_set(&opt->on_finished, (void *)(gpr_intptr)1); + gpr_event_set(&opt->on_finished, (void *)(intptr_t)1); return; case GRPC_QUEUE_TIMEOUT: gpr_log(GPR_ERROR, "Invalid timeout received"); @@ -366,7 +365,7 @@ static void test_threading(size_t producers, size_t consumers) { /* start phase1: producers will pre-declare all operations they will complete */ gpr_log(GPR_INFO, "start phase 1"); - gpr_event_set(&phase1, (void *)(gpr_intptr)1); + gpr_event_set(&phase1, (void *)(intptr_t)1); gpr_log(GPR_INFO, "wait phase 1"); for (i = 0; i < producers + consumers; i++) { @@ -376,7 +375,7 @@ static void test_threading(size_t producers, size_t consumers) { /* start phase2: operations will complete, and consumers will consume them */ gpr_log(GPR_INFO, "start phase 2"); - gpr_event_set(&phase2, (void *)(gpr_intptr)1); + gpr_event_set(&phase2, (void *)(intptr_t)1); /* in parallel, we shutdown the completion channel - all events should still be consumed */ diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 35b0212fcf..e03cce1322 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -45,7 +45,7 @@ grpc_closure transport_op_cb; -static void *tag(gpr_intptr x) { return (void *)x; } +static void *tag(intptr_t x) { return (void *)x; } void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg, int success) { grpc_transport_op *op = arg; diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c new file mode 100644 index 0000000000..1e1524d098 --- /dev/null +++ b/test/core/surface/public_headers_must_be_c89.c @@ -0,0 +1,61 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <grpc/byte_buffer.h> +#include <grpc/byte_buffer_reader.h> +#include <grpc/census.h> +#include <grpc/compression.h> +#include <grpc/grpc.h> +#include <grpc/grpc_security.h> +#include <grpc/status.h> +#include <grpc/support/alloc.h> +#include <grpc/support/atm.h> +#include <grpc/support/avl.h> +#include <grpc/support/cmdline.h> +#include <grpc/support/cpu.h> +#include <grpc/support/histogram.h> +#include <grpc/support/host_port.h> +#include <grpc/support/log.h> +#include <grpc/support/port_platform.h> +#include <grpc/support/slice.h> +#include <grpc/support/slice_buffer.h> +#include <grpc/support/string_util.h> +#include <grpc/support/subprocess.h> +#include <grpc/support/sync.h> +#include <grpc/support/sync_generic.h> +#include <grpc/support/thd.h> +#include <grpc/support/time.h> +#include <grpc/support/tls.h> +#include <grpc/support/useful.h> + +int main(int argc, char **argv) { return 0; } diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c index fde352433b..39f4174eec 100644 --- a/test/core/transport/chttp2/hpack_table_test.c +++ b/test/core/transport/chttp2/hpack_table_test.c @@ -51,7 +51,7 @@ static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_mdstr *mdstr, GPR_ASSERT(gpr_slice_str_cmp(mdstr->slice, str) == 0); } -static void assert_index(const grpc_chttp2_hptbl *tbl, gpr_uint32 idx, +static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx, const char *key, const char *value) { grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx); assert_str(tbl, md->key, key); @@ -172,7 +172,7 @@ static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl, static void test_find(void) { grpc_chttp2_hptbl tbl; - gpr_uint32 i; + uint32_t i; char buffer[32]; grpc_mdelem *elem; grpc_chttp2_hptbl_find_result r; @@ -255,7 +255,7 @@ static void test_find(void) { GPR_ASSERT(r.has_value == 1); for (i = 0; i < tbl.num_ents; i++) { - gpr_uint32 expect = 9999 - i; + uint32_t expect = 9999 - i; gpr_ltoa(expect, buffer); r = find_simple(&tbl, "test", buffer); diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c index 81fb80f84f..527d2fe0ae 100644 --- a/test/core/transport/chttp2/stream_map_test.c +++ b/test/core/transport/chttp2/stream_map_test.c @@ -82,9 +82,9 @@ static void test_double_deletion(void) { } /* test add & lookup */ -static void test_basic_add_find(gpr_uint32 n) { +static void test_basic_add_find(uint32_t n) { grpc_chttp2_stream_map map; - gpr_uint32 i; + uint32_t i; size_t got; LOG_TEST("test_basic_add_find"); @@ -93,36 +93,36 @@ static void test_basic_add_find(gpr_uint32 n) { grpc_chttp2_stream_map_init(&map, 8); GPR_ASSERT(0 == grpc_chttp2_stream_map_size(&map)); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); } GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, n + 1)); for (i = 1; i <= n; i++) { - got = (gpr_uintptr)grpc_chttp2_stream_map_find(&map, i); + got = (uintptr_t)grpc_chttp2_stream_map_find(&map, i); GPR_ASSERT(i == got); } grpc_chttp2_stream_map_destroy(&map); } /* verify that for_each gets the right values during test_delete_evens_XXX */ -static void verify_for_each(void *user_data, gpr_uint32 stream_id, void *ptr) { - gpr_uint32 *for_each_check = user_data; +static void verify_for_each(void *user_data, uint32_t stream_id, void *ptr) { + uint32_t *for_each_check = user_data; GPR_ASSERT(ptr); GPR_ASSERT(*for_each_check == stream_id); *for_each_check += 2; } -static void check_delete_evens(grpc_chttp2_stream_map *map, gpr_uint32 n) { - gpr_uint32 for_each_check = 1; - gpr_uint32 i; +static void check_delete_evens(grpc_chttp2_stream_map *map, uint32_t n) { + uint32_t for_each_check = 1; + uint32_t i; size_t got; GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(map, 0)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(map, n + 1)); for (i = 1; i <= n; i++) { if (i & 1) { - got = (gpr_uintptr)grpc_chttp2_stream_map_find(map, i); + got = (uintptr_t)grpc_chttp2_stream_map_find(map, i); GPR_ASSERT(i == got); } else { GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(map, i)); @@ -139,20 +139,20 @@ static void check_delete_evens(grpc_chttp2_stream_map *map, gpr_uint32 n) { /* add a bunch of keys, delete the even ones, and make sure the map is consistent */ -static void test_delete_evens_sweep(gpr_uint32 n) { +static void test_delete_evens_sweep(uint32_t n) { grpc_chttp2_stream_map map; - gpr_uint32 i; + uint32_t i; LOG_TEST("test_delete_evens_sweep"); gpr_log(GPR_INFO, "n = %d", n); grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); } for (i = 1; i <= n; i++) { if ((i & 1) == 0) { - GPR_ASSERT((void *)(gpr_uintptr)i == + GPR_ASSERT((void *)(uintptr_t)i == grpc_chttp2_stream_map_delete(&map, i)); } } @@ -162,16 +162,16 @@ static void test_delete_evens_sweep(gpr_uint32 n) { /* add a bunch of keys, delete the even ones immediately, and make sure the map is consistent */ -static void test_delete_evens_incremental(gpr_uint32 n) { +static void test_delete_evens_incremental(uint32_t n) { grpc_chttp2_stream_map map; - gpr_uint32 i; + uint32_t i; LOG_TEST("test_delete_evens_incremental"); gpr_log(GPR_INFO, "n = %d", n); grpc_chttp2_stream_map_init(&map, 8); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); if ((i & 1) == 0) { grpc_chttp2_stream_map_delete(&map, i); } @@ -182,10 +182,10 @@ static void test_delete_evens_incremental(gpr_uint32 n) { /* add a bunch of keys, delete old ones after some time, ensure the backing array does not grow */ -static void test_periodic_compaction(gpr_uint32 n) { +static void test_periodic_compaction(uint32_t n) { grpc_chttp2_stream_map map; - gpr_uint32 i; - gpr_uint32 del; + uint32_t i; + uint32_t del; LOG_TEST("test_periodic_compaction"); gpr_log(GPR_INFO, "n = %d", n); @@ -193,10 +193,10 @@ static void test_periodic_compaction(gpr_uint32 n) { grpc_chttp2_stream_map_init(&map, 16); GPR_ASSERT(map.capacity == 16); for (i = 1; i <= n; i++) { - grpc_chttp2_stream_map_add(&map, i, (void *)(gpr_uintptr)i); + grpc_chttp2_stream_map_add(&map, i, (void *)(uintptr_t)i); if (i > 8) { del = i - 8; - GPR_ASSERT((void *)(gpr_uintptr)del == + GPR_ASSERT((void *)(uintptr_t)del == grpc_chttp2_stream_map_delete(&map, del)); } } @@ -205,9 +205,9 @@ static void test_periodic_compaction(gpr_uint32 n) { } int main(int argc, char **argv) { - gpr_uint32 n = 1; - gpr_uint32 prev = 1; - gpr_uint32 tmp; + uint32_t n = 1; + uint32_t prev = 1; + uint32_t tmp; grpc_test_init(argc, argv); diff --git a/test/core/transport/chttp2/varint_test.c b/test/core/transport/chttp2/varint_test.c index 31fcb7e182..f06116a731 100644 --- a/test/core/transport/chttp2/varint_test.c +++ b/test/core/transport/chttp2/varint_test.c @@ -38,10 +38,9 @@ #include "test/core/util/test_config.h" -static void test_varint(gpr_uint32 value, gpr_uint32 prefix_bits, - gpr_uint8 prefix_or, const char *expect_bytes, - size_t expect_length) { - gpr_uint32 nbytes = GRPC_CHTTP2_VARINT_LENGTH(value, prefix_bits); +static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, + const char *expect_bytes, size_t expect_length) { + uint32_t nbytes = GRPC_CHTTP2_VARINT_LENGTH(value, prefix_bits); gpr_slice expect = gpr_slice_from_copied_buffer(expect_bytes, expect_length); gpr_slice slice; gpr_log(GPR_DEBUG, "Test: 0x%08x", value); diff --git a/test/core/transport/connectivity_state_test.c b/test/core/transport/connectivity_state_test.c index 1f23221812..34ab45d260 100644 --- a/test/core/transport/connectivity_state_test.c +++ b/test/core/transport/connectivity_state_test.c @@ -39,7 +39,7 @@ #include "test/core/util/test_config.h" -#define THE_ARG ((void *)0xcafebabe) +#define THE_ARG ((void *)(size_t)0xcafebabe) int g_counter; diff --git a/test/core/util/parse_hexstring.c b/test/core/util/parse_hexstring.c index eced3173d1..3ad7ce5828 100644 --- a/test/core/util/parse_hexstring.c +++ b/test/core/util/parse_hexstring.c @@ -37,8 +37,8 @@ gpr_slice parse_hexstring(const char *hexstring) { size_t nibbles = 0; const char *p = 0; - gpr_uint8 *out; - gpr_uint8 temp; + uint8_t *out; + uint8_t temp; gpr_slice slice; for (p = hexstring; *p; p++) { @@ -54,10 +54,10 @@ gpr_slice parse_hexstring(const char *hexstring) { temp = 0; for (p = hexstring; *p; p++) { if (*p >= '0' && *p <= '9') { - temp = (gpr_uint8)(temp << 4) | (gpr_uint8)(*p - '0'); + temp = (uint8_t)(temp << 4) | (uint8_t)(*p - '0'); nibbles++; } else if (*p >= 'a' && *p <= 'f') { - temp = (gpr_uint8)(temp << 4) | (gpr_uint8)(*p - 'a' + 10); + temp = (uint8_t)(temp << 4) | (uint8_t)(*p - 'a' + 10); nibbles++; } if (nibbles == 2) { diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 0a50660586..732a51c5cb 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -174,7 +174,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((gpr_uint16)*port); + addr.sin_port = htons((uint16_t)*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/slice_splitter.c b/test/core/util/slice_splitter.c index 0f05072e50..95b55a6505 100644 --- a/test/core/util/slice_splitter.c +++ b/test/core/util/slice_splitter.c @@ -119,7 +119,7 @@ void grpc_split_slice_buffer(grpc_slice_split_mode mode, gpr_slice_buffer *src, } gpr_slice grpc_slice_merge(gpr_slice *slices, size_t nslices) { - gpr_uint8 *out = NULL; + uint8_t *out = NULL; size_t length = 0; size_t capacity = 0; size_t i; diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index c700d3637f..53b574d285 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -63,7 +63,7 @@ void test_tcp_server_start(test_tcp_server *server, int port) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; addr.sin_family = AF_INET; - addr.sin_port = htons((gpr_uint16)port); + addr.sin_port = htons((uint16_t)port); memset(&addr.sin_addr, 0, sizeof(addr.sin_addr)); server->tcp_server = grpc_tcp_server_create(); diff --git a/test/cpp/common/alarm_test.cc b/test/cpp/common/alarm_test.cc index 18083cd8bd..d41a25a63c 100644 --- a/test/cpp/common/alarm_test.cc +++ b/test/cpp/common/alarm_test.cc @@ -43,12 +43,12 @@ namespace { class TestTag : public CompletionQueueTag { public: TestTag() : tag_(0) {} - TestTag(gpr_intptr tag) : tag_(tag) {} + TestTag(intptr_t tag) : tag_(tag) {} bool FinalizeResult(void** tag, bool* status) { return true; } - gpr_intptr tag() { return tag_; } + intptr_t tag() { return tag_; } private: - gpr_intptr tag_; + intptr_t tag_; }; TEST(AlarmTest, RegularExpiry) { diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 279423a8cb..af0b7fdb57 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -63,7 +63,7 @@ namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr)i; } +void* tag(int i) { return (void*)(intptr_t)i; } #ifdef GPR_POSIX_SOCKET static int assert_non_blocking_poll(struct pollfd* pfds, nfds_t nfds, diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index dd02c4ac16..bbeac7a30b 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -543,6 +543,7 @@ TEST_P(End2endTest, BidiStream) { stream->WritesDone(); EXPECT_FALSE(stream->Read(&response)); + EXPECT_FALSE(stream->Read(&response)); Status s = stream->Finish(); EXPECT_TRUE(s.ok()); diff --git a/test/cpp/end2end/generic_end2end_test.cc b/test/cpp/end2end/generic_end2end_test.cc index 6ecf7eb2fe..350e67b523 100644 --- a/test/cpp/end2end/generic_end2end_test.cc +++ b/test/cpp/end2end/generic_end2end_test.cc @@ -60,7 +60,7 @@ namespace grpc { namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr)i; } +void* tag(int i) { return (void*)(intptr_t)i; } void verify_ok(CompletionQueue* cq, int i, bool expect_ok) { bool ok; diff --git a/test/cpp/end2end/zookeeper_test.cc b/test/cpp/end2end/zookeeper_test.cc index e88c0f9c68..41482717d2 100644 --- a/test/cpp/end2end/zookeeper_test.cc +++ b/test/cpp/end2end/zookeeper_test.cc @@ -158,7 +158,7 @@ class ZookeeperTest : public ::testing::Test { void ResetStub() { string target = "zookeeper://" + zookeeper_address_ + "/test"; channel_ = CreateChannel(target, InsecureChannelCredentials()); - stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel_)); + stub_ = grpc::cpp::test::util::TestService::NewStub(channel_); } string to_string(const int number) { diff --git a/test/cpp/interop/client_helper.h b/test/cpp/interop/client_helper.h index ace193042e..0f77474139 100644 --- a/test/cpp/interop/client_helper.h +++ b/test/cpp/interop/client_helper.h @@ -60,7 +60,7 @@ class InteropClientContextInspector { return grpc_call_test_only_get_compression_algorithm(context_.call_); } - gpr_uint32 GetMessageFlags() const { + uint32_t GetMessageFlags() const { return grpc_call_test_only_get_message_flags(context_.call_); } diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index 6340007fa4..a758e73def 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -38,19 +38,19 @@ #include <fstream> #include <memory> +#include <grpc++/channel.h> +#include <grpc++/client_context.h> +#include <grpc++/security/credentials.h> #include <grpc/grpc.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> #include <grpc/support/useful.h> -#include <grpc++/channel.h> -#include <grpc++/client_context.h> -#include <grpc++/security/credentials.h> #include "src/core/transport/byte_stream.h" #include "test/cpp/interop/client_helper.h" -#include "test/proto/test.grpc.pb.h" #include "test/proto/empty.grpc.pb.h" #include "test/proto/messages.grpc.pb.h" +#include "test/proto/test.grpc.pb.h" namespace grpc { namespace testing { @@ -80,6 +80,24 @@ CompressionType GetInteropCompressionTypeFromCompressionAlgorithm( GPR_ASSERT(false); } } + +void NoopChecks(const InteropClientContextInspector& inspector, + const SimpleRequest* request, const SimpleResponse* response) {} + +void CompressionChecks(const InteropClientContextInspector& inspector, + const SimpleRequest* request, + const SimpleResponse* response) { + GPR_ASSERT(request->response_compression() == + GetInteropCompressionTypeFromCompressionAlgorithm( + inspector.GetCallCompressionAlgorithm())); + if (request->response_compression() == NONE) { + GPR_ASSERT(!(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS)); + } else if (request->response_type() == PayloadType::COMPRESSABLE) { + // requested compression and compressable response => results should always + // be compressed. + GPR_ASSERT(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS); + } +} } // namespace InteropClient::ServiceStub::ServiceStub(std::shared_ptr<Channel> channel, @@ -127,13 +145,13 @@ void InteropClient::AssertOkOrPrintErrorStatus(const Status& s) { if (s.ok()) { return; } - gpr_log(GPR_INFO, "Error status code: %d, message: %s", s.error_code(), + gpr_log(GPR_ERROR, "Error status code: %d, message: %s", s.error_code(), s.error_message().c_str()); GPR_ASSERT(0); } void InteropClient::DoEmpty() { - gpr_log(GPR_INFO, "Sending an empty rpc..."); + gpr_log(GPR_DEBUG, "Sending an empty rpc..."); Empty request = Empty::default_instance(); Empty response = Empty::default_instance(); @@ -142,12 +160,17 @@ void InteropClient::DoEmpty() { Status s = serviceStub_.Get()->EmptyCall(&context, request, &response); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "Empty rpc done."); + gpr_log(GPR_DEBUG, "Empty rpc done."); } -// Shared code to set large payload, make rpc and check response payload. void InteropClient::PerformLargeUnary(SimpleRequest* request, SimpleResponse* response) { + PerformLargeUnary(request, response, NoopChecks); +} + +void InteropClient::PerformLargeUnary(SimpleRequest* request, + SimpleResponse* response, + CheckerFn custom_checks_fn) { ClientContext context; InteropClientContextInspector inspector(context); // If the request doesn't already specify the response type, default to @@ -157,21 +180,10 @@ void InteropClient::PerformLargeUnary(SimpleRequest* request, request->mutable_payload()->set_body(payload.c_str(), kLargeRequestSize); Status s = serviceStub_.Get()->UnaryCall(&context, *request, response); - - // Compression related checks. - GPR_ASSERT(request->response_compression() == - GetInteropCompressionTypeFromCompressionAlgorithm( - inspector.GetCallCompressionAlgorithm())); - if (request->response_compression() == NONE) { - GPR_ASSERT(!(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS)); - } else if (request->response_type() == PayloadType::COMPRESSABLE) { - // requested compression and compressable response => results should always - // be compressed. - GPR_ASSERT(inspector.GetMessageFlags() & GRPC_WRITE_INTERNAL_COMPRESS); - } - AssertOkOrPrintErrorStatus(s); + custom_checks_fn(inspector, request, response); + // Payload related checks. if (request->response_type() != PayloadType::RANDOM) { GPR_ASSERT(response->payload().type() == request->response_type()); @@ -196,7 +208,7 @@ void InteropClient::PerformLargeUnary(SimpleRequest* request, void InteropClient::DoComputeEngineCreds( const grpc::string& default_service_account, const grpc::string& oauth_scope) { - gpr_log(GPR_INFO, + gpr_log(GPR_DEBUG, "Sending a large unary rpc with compute engine credentials ..."); SimpleRequest request; SimpleResponse response; @@ -204,19 +216,19 @@ void InteropClient::DoComputeEngineCreds( request.set_fill_oauth_scope(true); request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); - gpr_log(GPR_INFO, "Got username %s", response.username().c_str()); - gpr_log(GPR_INFO, "Got oauth_scope %s", response.oauth_scope().c_str()); + gpr_log(GPR_DEBUG, "Got username %s", response.username().c_str()); + gpr_log(GPR_DEBUG, "Got oauth_scope %s", response.oauth_scope().c_str()); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(response.username().c_str() == default_service_account); GPR_ASSERT(!response.oauth_scope().empty()); const char* oauth_scope_str = response.oauth_scope().c_str(); GPR_ASSERT(oauth_scope.find(oauth_scope_str) != grpc::string::npos); - gpr_log(GPR_INFO, "Large unary with compute engine creds done."); + gpr_log(GPR_DEBUG, "Large unary with compute engine creds done."); } void InteropClient::DoOauth2AuthToken(const grpc::string& username, const grpc::string& oauth_scope) { - gpr_log(GPR_INFO, + gpr_log(GPR_DEBUG, "Sending a unary rpc with raw oauth2 access token credentials ..."); SimpleRequest request; SimpleResponse response; @@ -233,11 +245,11 @@ void InteropClient::DoOauth2AuthToken(const grpc::string& username, GPR_ASSERT(username == response.username()); const char* oauth_scope_str = response.oauth_scope().c_str(); GPR_ASSERT(oauth_scope.find(oauth_scope_str) != grpc::string::npos); - gpr_log(GPR_INFO, "Unary with oauth2 access token credentials done."); + gpr_log(GPR_DEBUG, "Unary with oauth2 access token credentials done."); } void InteropClient::DoPerRpcCreds(const grpc::string& json_key) { - gpr_log(GPR_INFO, "Sending a unary rpc with per-rpc JWT access token ..."); + gpr_log(GPR_DEBUG, "Sending a unary rpc with per-rpc JWT access token ..."); SimpleRequest request; SimpleResponse response; request.set_fill_username(true); @@ -254,11 +266,12 @@ void InteropClient::DoPerRpcCreds(const grpc::string& json_key) { AssertOkOrPrintErrorStatus(s); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(json_key.find(response.username()) != grpc::string::npos); - gpr_log(GPR_INFO, "Unary with per-rpc JWT access token done."); + gpr_log(GPR_DEBUG, "Unary with per-rpc JWT access token done."); } void InteropClient::DoJwtTokenCreds(const grpc::string& username) { - gpr_log(GPR_INFO, "Sending a large unary rpc with JWT token credentials ..."); + gpr_log(GPR_DEBUG, + "Sending a large unary rpc with JWT token credentials ..."); SimpleRequest request; SimpleResponse response; request.set_fill_username(true); @@ -266,16 +279,16 @@ void InteropClient::DoJwtTokenCreds(const grpc::string& username) { PerformLargeUnary(&request, &response); GPR_ASSERT(!response.username().empty()); GPR_ASSERT(username.find(response.username()) != grpc::string::npos); - gpr_log(GPR_INFO, "Large unary with JWT token creds done."); + gpr_log(GPR_DEBUG, "Large unary with JWT token creds done."); } void InteropClient::DoLargeUnary() { - gpr_log(GPR_INFO, "Sending a large unary rpc..."); + gpr_log(GPR_DEBUG, "Sending a large unary rpc..."); SimpleRequest request; SimpleResponse response; request.set_response_type(PayloadType::COMPRESSABLE); PerformLargeUnary(&request, &response); - gpr_log(GPR_INFO, "Large unary done."); + gpr_log(GPR_DEBUG, "Large unary done."); } void InteropClient::DoLargeCompressedUnary() { @@ -288,20 +301,21 @@ void InteropClient::DoLargeCompressedUnary() { CompressionType_Name(compression_types[j]).c_str(), PayloadType_Name(payload_types[i]).c_str()); - gpr_log(GPR_INFO, "Sending a large compressed unary rpc %s.", log_suffix); + gpr_log(GPR_DEBUG, "Sending a large compressed unary rpc %s.", + log_suffix); SimpleRequest request; SimpleResponse response; request.set_response_type(payload_types[i]); request.set_response_compression(compression_types[j]); - PerformLargeUnary(&request, &response); - gpr_log(GPR_INFO, "Large compressed unary done %s.", log_suffix); + PerformLargeUnary(&request, &response, CompressionChecks); + gpr_log(GPR_DEBUG, "Large compressed unary done %s.", log_suffix); gpr_free(log_suffix); } } } void InteropClient::DoRequestStreaming() { - gpr_log(GPR_INFO, "Sending request steaming rpc ..."); + gpr_log(GPR_DEBUG, "Sending request steaming rpc ..."); ClientContext context; StreamingInputCallRequest request; @@ -322,11 +336,11 @@ void InteropClient::DoRequestStreaming() { GPR_ASSERT(response.aggregated_payload_size() == aggregated_payload_size); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "Request streaming done."); + gpr_log(GPR_DEBUG, "Request streaming done."); } void InteropClient::DoResponseStreaming() { - gpr_log(GPR_INFO, "Receiving response steaming rpc ..."); + gpr_log(GPR_DEBUG, "Receiving response steaming rpc ..."); ClientContext context; StreamingOutputCallRequest request; @@ -347,7 +361,7 @@ void InteropClient::DoResponseStreaming() { GPR_ASSERT(response_stream_sizes.size() == i); Status s = stream->Finish(); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "Response streaming done."); + gpr_log(GPR_DEBUG, "Response streaming done."); } void InteropClient::DoResponseCompressedStreaming() { @@ -364,7 +378,7 @@ void InteropClient::DoResponseCompressedStreaming() { CompressionType_Name(compression_types[j]).c_str(), PayloadType_Name(payload_types[i]).c_str()); - gpr_log(GPR_INFO, "Receiving response steaming rpc %s.", log_suffix); + gpr_log(GPR_DEBUG, "Receiving response steaming rpc %s.", log_suffix); request.set_response_type(payload_types[i]); request.set_response_compression(compression_types[j]); @@ -422,14 +436,14 @@ void InteropClient::DoResponseCompressedStreaming() { Status s = stream->Finish(); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "Response streaming done %s.", log_suffix); + gpr_log(GPR_DEBUG, "Response streaming done %s.", log_suffix); gpr_free(log_suffix); } } } void InteropClient::DoResponseStreamingWithSlowConsumer() { - gpr_log(GPR_INFO, "Receiving response steaming rpc with slow consumer ..."); + gpr_log(GPR_DEBUG, "Receiving response steaming rpc with slow consumer ..."); ClientContext context; StreamingOutputCallRequest request; @@ -446,7 +460,7 @@ void InteropClient::DoResponseStreamingWithSlowConsumer() { while (stream->Read(&response)) { GPR_ASSERT(response.payload().body() == grpc::string(kResponseMessageSize, '\0')); - gpr_log(GPR_INFO, "received message %d", i); + gpr_log(GPR_DEBUG, "received message %d", i); usleep(kReceiveDelayMilliSeconds * 1000); ++i; } @@ -454,11 +468,11 @@ void InteropClient::DoResponseStreamingWithSlowConsumer() { Status s = stream->Finish(); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "Response streaming done."); + gpr_log(GPR_DEBUG, "Response streaming done."); } void InteropClient::DoHalfDuplex() { - gpr_log(GPR_INFO, "Sending half-duplex streaming rpc ..."); + gpr_log(GPR_DEBUG, "Sending half-duplex streaming rpc ..."); ClientContext context; std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest, @@ -483,11 +497,11 @@ void InteropClient::DoHalfDuplex() { GPR_ASSERT(response_stream_sizes.size() == i); Status s = stream->Finish(); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "Half-duplex streaming rpc done."); + gpr_log(GPR_DEBUG, "Half-duplex streaming rpc done."); } void InteropClient::DoPingPong() { - gpr_log(GPR_INFO, "Sending Ping Pong streaming rpc ..."); + gpr_log(GPR_DEBUG, "Sending Ping Pong streaming rpc ..."); ClientContext context; std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest, @@ -512,11 +526,11 @@ void InteropClient::DoPingPong() { GPR_ASSERT(!stream->Read(&response)); Status s = stream->Finish(); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "Ping pong streaming done."); + gpr_log(GPR_DEBUG, "Ping pong streaming done."); } void InteropClient::DoCancelAfterBegin() { - gpr_log(GPR_INFO, "Sending request steaming rpc ..."); + gpr_log(GPR_DEBUG, "Sending request steaming rpc ..."); ClientContext context; StreamingInputCallRequest request; @@ -525,15 +539,15 @@ void InteropClient::DoCancelAfterBegin() { std::unique_ptr<ClientWriter<StreamingInputCallRequest>> stream( serviceStub_.Get()->StreamingInputCall(&context, &response)); - gpr_log(GPR_INFO, "Trying to cancel..."); + gpr_log(GPR_DEBUG, "Trying to cancel..."); context.TryCancel(); Status s = stream->Finish(); GPR_ASSERT(s.error_code() == StatusCode::CANCELLED); - gpr_log(GPR_INFO, "Canceling streaming done."); + gpr_log(GPR_DEBUG, "Canceling streaming done."); } void InteropClient::DoCancelAfterFirstResponse() { - gpr_log(GPR_INFO, "Sending Ping Pong streaming rpc ..."); + gpr_log(GPR_DEBUG, "Sending Ping Pong streaming rpc ..."); ClientContext context; std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest, @@ -549,15 +563,16 @@ void InteropClient::DoCancelAfterFirstResponse() { GPR_ASSERT(stream->Write(request)); GPR_ASSERT(stream->Read(&response)); GPR_ASSERT(response.payload().body() == grpc::string(31415, '\0')); - gpr_log(GPR_INFO, "Trying to cancel..."); + gpr_log(GPR_DEBUG, "Trying to cancel..."); context.TryCancel(); Status s = stream->Finish(); - gpr_log(GPR_INFO, "Canceling pingpong streaming done."); + gpr_log(GPR_DEBUG, "Canceling pingpong streaming done."); } void InteropClient::DoTimeoutOnSleepingServer() { - gpr_log(GPR_INFO, "Sending Ping Pong streaming rpc with a short deadline..."); + gpr_log(GPR_DEBUG, + "Sending Ping Pong streaming rpc with a short deadline..."); ClientContext context; std::chrono::system_clock::time_point deadline = @@ -573,11 +588,11 @@ void InteropClient::DoTimeoutOnSleepingServer() { Status s = stream->Finish(); GPR_ASSERT(s.error_code() == StatusCode::DEADLINE_EXCEEDED); - gpr_log(GPR_INFO, "Pingpong streaming timeout done."); + gpr_log(GPR_DEBUG, "Pingpong streaming timeout done."); } void InteropClient::DoEmptyStream() { - gpr_log(GPR_INFO, "Starting empty_stream."); + gpr_log(GPR_DEBUG, "Starting empty_stream."); ClientContext context; std::unique_ptr<ClientReaderWriter<StreamingOutputCallRequest, @@ -588,11 +603,12 @@ void InteropClient::DoEmptyStream() { GPR_ASSERT(stream->Read(&response) == false); Status s = stream->Finish(); AssertOkOrPrintErrorStatus(s); - gpr_log(GPR_INFO, "empty_stream done."); + gpr_log(GPR_DEBUG, "empty_stream done."); } void InteropClient::DoStatusWithMessage() { - gpr_log(GPR_INFO, "Sending RPC with a request for status code 2 and message"); + gpr_log(GPR_DEBUG, + "Sending RPC with a request for status code 2 and message"); ClientContext context; SimpleRequest request; @@ -606,7 +622,7 @@ void InteropClient::DoStatusWithMessage() { GPR_ASSERT(s.error_code() == grpc::StatusCode::UNKNOWN); GPR_ASSERT(s.error_message() == test_msg); - gpr_log(GPR_INFO, "Done testing Status and Message"); + gpr_log(GPR_DEBUG, "Done testing Status and Message"); } } // namespace testing diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h index 1bfb49d514..97a6fd77cf 100644 --- a/test/cpp/interop/interop_client.h +++ b/test/cpp/interop/interop_client.h @@ -44,6 +44,11 @@ namespace grpc { namespace testing { +// Function pointer for custom checks. +using CheckerFn = + std::function<void(const InteropClientContextInspector&, + const SimpleRequest*, const SimpleResponse*)>; + class InteropClient { public: explicit InteropClient(std::shared_ptr<Channel> channel); @@ -100,6 +105,10 @@ class InteropClient { }; void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response); + + /// Run \a custom_check_fn as an additional check. + void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response, + CheckerFn custom_checks_fn); void AssertOkOrPrintErrorStatus(const Status& s); ServiceStub serviceStub_; }; diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc index 92b5bf4dfa..d08385a74c 100644 --- a/test/cpp/interop/reconnect_interop_server.cc +++ b/test/cpp/interop/reconnect_interop_server.cc @@ -143,7 +143,7 @@ class ReconnectServiceImpl : public ReconnectService::Service { backoff > max_backoff + kTransmissionDelay) { passed = false; } - response->add_backoff_ms(static_cast<gpr_int32>(backoff)); + response->add_backoff_ms(static_cast<int32_t>(backoff)); expected_backoff *= kBackoffMultiplier; expected_backoff = expected_backoff > kMaxBackoffMs ? kMaxBackoffMs : expected_backoff; diff --git a/test/cpp/interop/server_helper.cc b/test/cpp/interop/server_helper.cc index 5138a38170..9a284094f0 100644 --- a/test/cpp/interop/server_helper.cc +++ b/test/cpp/interop/server_helper.cc @@ -68,7 +68,7 @@ InteropServerContextInspector::GetCallCompressionAlgorithm() const { return grpc_call_test_only_get_compression_algorithm(context_.call_); } -gpr_uint32 InteropServerContextInspector::GetEncodingsAcceptedByClient() const { +uint32_t InteropServerContextInspector::GetEncodingsAcceptedByClient() const { return grpc_call_test_only_get_encodings_accepted_by_peer(context_.call_); } diff --git a/test/cpp/interop/server_helper.h b/test/cpp/interop/server_helper.h index dc0ae1dccd..57337e5239 100644 --- a/test/cpp/interop/server_helper.h +++ b/test/cpp/interop/server_helper.h @@ -53,7 +53,7 @@ class InteropServerContextInspector { std::shared_ptr<const AuthContext> GetAuthContext() const; bool IsCancelled() const; grpc_compression_algorithm GetCallCompressionAlgorithm() const; - gpr_uint32 GetEncodingsAcceptedByClient() const; + uint32_t GetEncodingsAcceptedByClient() const; private: const ::grpc::ServerContext& context_; diff --git a/test/cpp/interop/stress_interop_client.cc b/test/cpp/interop/stress_interop_client.cc index 5d2951e3ed..04671fb935 100644 --- a/test/cpp/interop/stress_interop_client.cc +++ b/test/cpp/interop/stress_interop_client.cc @@ -112,7 +112,7 @@ void StressTestInteropClient::MainLoop(std::shared_ptr<Gauge> qps_gauge) { gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), test_end_time) < 0) { // Select the test case to execute based on the weights and execute it TestCaseType test_case = test_selector_.GetNextTest(); - gpr_log(GPR_INFO, "%d - Executing the test case %d", test_id_, test_case); + gpr_log(GPR_DEBUG, "%d - Executing the test case %d", test_id_, test_case); RunTest(test_case); num_calls_per_interval++; diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 934f4f5722..22ef5a5491 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -50,6 +50,10 @@ #include "test/proto/metrics.grpc.pb.h" #include "test/proto/metrics.pb.h" +extern "C" { +extern void gpr_default_log(gpr_log_func_args* args); +} + DEFINE_int32(metrics_port, 8081, "The metrics server port."); DEFINE_int32(metrics_collection_interval_secs, 5, @@ -94,6 +98,12 @@ DEFINE_string(test_cases, "", " 'large_unary', 10% of the time and 'empty_stream' the remaining" " 70% of the time"); +DEFINE_int32(log_level, GPR_LOG_SEVERITY_DEBUG, + "Severity level of messages that should be logged. Any messages " + "greater than or equal to the level set here will be logged. " + "The choices are: 0 (GPR_LOG_SEVERITY_DEBUG), 1 " + "(GPR_LOG_SEVERITY_INFO) and 2 (GPR_LOG_SEVERITY_ERROR."); + using grpc::testing::kTestCaseList; using grpc::testing::MetricsService; using grpc::testing::MetricsServiceImpl; @@ -102,6 +112,16 @@ using grpc::testing::TestCaseType; using grpc::testing::UNKNOWN_TEST; using grpc::testing::WeightedRandomTestSelector; +static int log_level = GPR_LOG_SEVERITY_DEBUG; + +// A simple wrapper to grp_default_log() function. This only logs messages at or +// above the current log level (set in 'log_level' variable) +void TestLogFunction(gpr_log_func_args* args) { + if (args->severity >= log_level) { + gpr_default_log(args); + } +} + TestCaseType GetTestTypeFromName(const grpc::string& test_name) { TestCaseType test_case = UNKNOWN_TEST; @@ -190,6 +210,18 @@ void LogParameterInfo(const std::vector<grpc::string>& addresses, int main(int argc, char** argv) { grpc::testing::InitTest(&argc, &argv, true); + if (FLAGS_log_level > GPR_LOG_SEVERITY_ERROR || + FLAGS_log_level < GPR_LOG_SEVERITY_DEBUG) { + gpr_log(GPR_ERROR, "log_level should be an integer between %d and %d", + GPR_LOG_SEVERITY_DEBUG, GPR_LOG_SEVERITY_ERROR); + return 1; + } + + // Change the default log function to TestLogFunction which respects the + // log_level setting. + log_level = FLAGS_log_level; + gpr_set_log_function(TestLogFunction); + srand(time(NULL)); // Parse the server addresses @@ -198,7 +230,7 @@ int main(int argc, char** argv) { // Parse test cases and weights if (FLAGS_test_cases.length() == 0) { - gpr_log(GPR_INFO, "Not running tests. The 'test_cases' string is empty"); + gpr_log(GPR_ERROR, "Not running tests. The 'test_cases' string is empty"); return 1; } @@ -270,6 +302,5 @@ int main(int argc, char** argv) { it->join(); } - metrics_server->Wait(); return 0; } diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index 9a769848a4..0de388d3ca 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -46,7 +46,7 @@ namespace grpc { namespace testing { namespace { -void* tag(int i) { return (void*)(gpr_intptr)i; } +void* tag(int i) { return (void*)(intptr_t)i; } } // namespace Status CliCall::Call(std::shared_ptr<grpc::Channel> channel, diff --git a/test/cpp/util/string_ref_test.cc b/test/cpp/util/string_ref_test.cc index 44a298d892..d94aa5962b 100644 --- a/test/cpp/util/string_ref_test.cc +++ b/test/cpp/util/string_ref_test.cc @@ -102,7 +102,8 @@ TEST_F(StringRefTest, Iterator) { string_ref s(kTestString); size_t i = 0; for (auto it = s.cbegin(); it != s.cend(); ++it) { - EXPECT_EQ(kTestString[i++], *it); + auto val = kTestString[i++]; + EXPECT_EQ(val, *it); } EXPECT_EQ(strlen(kTestString), i); } @@ -111,7 +112,8 @@ TEST_F(StringRefTest, ReverseIterator) { string_ref s(kTestString); size_t i = strlen(kTestString); for (auto rit = s.crbegin(); rit != s.crend(); ++rit) { - EXPECT_EQ(kTestString[--i], *rit); + auto val = kTestString[--i]; + EXPECT_EQ(val, *rit); } EXPECT_EQ(0U, i); } |