aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/util
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-02-25 08:36:40 -0800
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-02-25 08:36:40 -0800
commit8ad8a41a84bf7e17c6e9a5fd8d975370a222c0fe (patch)
tree257d00e77bda0bc5e53b770ba9fa7cc300c449bb /test/core/util
parent517aa0c5358f860582e6143a29522699f61fba15 (diff)
Introduce slowdown factor for unit test deadlines
Dramatically lowers (eliminates maybe?) false negatives from ?SAN runs.
Diffstat (limited to 'test/core/util')
-rw-r--r--test/core/util/port_posix.c7
-rw-r--r--test/core/util/test_config.h14
2 files changed, 18 insertions, 3 deletions
diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c
index f0fe1a0e7c..0b6e7918ac 100644
--- a/test/core/util/port_posix.c
+++ b/test/core/util/port_posix.c
@@ -113,11 +113,12 @@ int grpc_pick_unused_port(void) {
/* Type of port to first pick in next iteration */
int is_tcp = 1;
- int try = 0;
+ int try
+ = 0;
for (;;) {
- int port =
- try < NUM_RANDOM_PORTS_TO_PICK ? rand() % (65536 - 30000) + 30000 : 0;
+ int port = try
+ < NUM_RANDOM_PORTS_TO_PICK ? rand() % (65536 - 30000) + 30000 : 0;
if (!is_port_available(&port, is_tcp)) {
continue;
}
diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h
index b97fbfa613..74c2a3cf1b 100644
--- a/test/core/util/test_config.h
+++ b/test/core/util/test_config.h
@@ -34,10 +34,24 @@
#ifndef __GRPC_TEST_UTIL_TEST_CONFIG_H__
#define __GRPC_TEST_UTIL_TEST_CONFIG_H__
+#include <grpc/support/time.h>
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
+#ifndef GRPC_TEST_SLOWDOWN_FACTOR
+#define GRPC_TEST_SLOWDOWN_FACTOR 1.0
+#endif
+
+#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
+ gpr_time_add(gpr_now(), \
+ gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e6 * (x)))
+
+#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
+ gpr_time_add(gpr_now(), \
+ gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x)))
+
void grpc_test_init(int argc, char **argv);
#ifdef __cplusplus