diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2015-02-25 08:36:40 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2015-02-25 08:36:40 -0800 |
commit | 8ad8a41a84bf7e17c6e9a5fd8d975370a222c0fe (patch) | |
tree | 257d00e77bda0bc5e53b770ba9fa7cc300c449bb /test/core/transport | |
parent | 517aa0c5358f860582e6143a29522699f61fba15 (diff) |
Introduce slowdown factor for unit test deadlines
Dramatically lowers (eliminates maybe?) false negatives from ?SAN runs.
Diffstat (limited to 'test/core/transport')
-rw-r--r-- | test/core/transport/chttp2/hpack_parser_test.c | 4 | ||||
-rw-r--r-- | test/core/transport/chttp2/stream_map_test.c | 6 | ||||
-rw-r--r-- | test/core/transport/chttp2_transport_end2end_test.c | 3 | ||||
-rw-r--r-- | test/core/transport/transport_end2end_tests.c | 24 |
4 files changed, 17 insertions, 20 deletions
diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c index 86c6bb1f56..1d6ad2a758 100644 --- a/test/core/transport/chttp2/hpack_parser_test.c +++ b/test/core/transport/chttp2/hpack_parser_test.c @@ -42,9 +42,7 @@ #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" -typedef struct { - va_list args; -} test_checker; +typedef struct { va_list args; } test_checker; static void onhdr(void *ud, grpc_mdelem *md) { const char *ekey, *evalue; diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c index 49d58114f8..6b91bdf14f 100644 --- a/test/core/transport/chttp2/stream_map_test.c +++ b/test/core/transport/chttp2/stream_map_test.c @@ -93,7 +93,7 @@ static void test_basic_add_find(size_t 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 *)(gpr_uintptr) i); } GPR_ASSERT(n == grpc_chttp2_stream_map_size(&map)); GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 0)); @@ -148,7 +148,7 @@ static void test_delete_evens_sweep(size_t 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 *)(gpr_uintptr) i); } for (i = 1; i <= n; i++) { if ((i & 1) == 0) { @@ -170,7 +170,7 @@ static void test_delete_evens_incremental(size_t 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 *)(gpr_uintptr) i); if ((i & 1) == 0) { grpc_chttp2_stream_map_delete(&map, i); } diff --git a/test/core/transport/chttp2_transport_end2end_test.c b/test/core/transport/chttp2_transport_end2end_test.c index a3c9f97ce4..b90fe22999 100644 --- a/test/core/transport/chttp2_transport_end2end_test.c +++ b/test/core/transport/chttp2_transport_end2end_test.c @@ -100,7 +100,8 @@ grpc_transport_test_config fixture_configs[] = { {"chttp2_on_socketpair/medium", create_http2_transport_for_test_medium_slices}, {"chttp2_on_socketpair/large", - create_http2_transport_for_test_large_slices}, }; + create_http2_transport_for_test_large_slices}, +}; /* Driver function: run the test suite for each test configuration */ int main(int argc, char **argv) { diff --git a/test/core/transport/transport_end2end_tests.c b/test/core/transport/transport_end2end_tests.c index 6d13bf1f8c..437a1c3ef5 100644 --- a/test/core/transport/transport_end2end_tests.c +++ b/test/core/transport/transport_end2end_tests.c @@ -43,8 +43,7 @@ #include <grpc/support/log.h> #include <grpc/support/thd.h> #include <grpc/support/useful.h> - -enum { REQUEST_DEADLINE = 200000 }; /* valgrind need a large value */ +#include "test/core/util/test_config.h" static grpc_mdctx *g_metadata_context; @@ -63,9 +62,7 @@ static int g_pending_ops; typedef struct test_fixture test_fixture; /* User data passed to the transport and handed to each callback */ -typedef struct test_user_data { - test_fixture *fixture; -} test_user_data; +typedef struct test_user_data { test_fixture *fixture; } test_user_data; /* A message we expect to receive (forms a singly linked list with next) */ typedef struct expected_message { @@ -131,8 +128,7 @@ static void expect_metadata(test_stream *s, int from_client, const char *key, /* Convert some number of seconds into a gpr_timespec that many seconds in the future */ static gpr_timespec deadline_from_seconds(double deadline_seconds) { - return gpr_time_add(gpr_now(), - gpr_time_from_micros((long)(deadline_seconds * 1e6))); + return GRPC_TIMEOUT_SECONDS_TO_DEADLINE(deadline_seconds); } /* Init a test_user_data instance */ @@ -576,7 +572,7 @@ static grpc_transport_setup_result setup_client_transport( name - the name of this test */ static void begin_test(test_fixture *f, grpc_transport_test_config *config, const char *name) { - gpr_timespec timeout = gpr_time_add(gpr_now(), gpr_time_from_seconds(100)); + gpr_timespec timeout = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(100); gpr_log(GPR_INFO, "BEGIN: %s/%s", name, config->name); @@ -591,9 +587,10 @@ static void begin_test(test_fixture *f, grpc_transport_test_config *config, f->client_transport = NULL; f->server_transport = NULL; - GPR_ASSERT(0 == config->create_transport(setup_client_transport, f, - setup_server_transport, f, - g_metadata_context)); + GPR_ASSERT(0 == + config->create_transport(setup_client_transport, f, + setup_server_transport, f, + g_metadata_context)); gpr_mu_lock(&f->mu); while (!f->client_transport || !f->server_transport) { @@ -909,8 +906,9 @@ static void test_ping(grpc_transport_test_config *config) { * Test driver */ -static const size_t interesting_message_lengths[] = {1, 100, 10000, - 100000, 1000000, }; +static const size_t interesting_message_lengths[] = { + 1, 100, 10000, 100000, 1000000, +}; void grpc_transport_end2end_tests(grpc_transport_test_config *config) { unsigned i; |