diff options
author | 2015-04-01 13:54:44 -0700 | |
---|---|---|
committer | 2015-04-01 13:54:44 -0700 | |
commit | 5a5032dd4ce43aed1330ad31430f8c9b3e833a72 (patch) | |
tree | 979261faf0a538c8943724e2deb74f54c8b5411f /test | |
parent | 1bd4736527ca691217b56e8287e4121a9d4fc684 (diff) |
Add a macro to enable replacing the default with a custom port picker
Diffstat (limited to 'test')
-rw-r--r-- | test/core/util/port_posix.c | 7 | ||||
-rw-r--r-- | test/core/util/test_config.h | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/test/core/util/port_posix.c b/test/core/util/port_posix.c index 36f13e1b51..7467c2f9ea 100644 --- a/test/core/util/port_posix.c +++ b/test/core/util/port_posix.c @@ -32,7 +32,8 @@ */ #include <grpc/support/port_platform.h> -#ifdef GPR_POSIX_SOCKET +#include "test/core/util/test_config.h" +#if defined(GPR_POSIX_SOCKET) && defined(GRPC_TEST_PICK_PORT) #include "test/core/util/port.h" @@ -125,7 +126,7 @@ int grpc_pick_unused_port(void) { } else { port = 0; } - + if (!is_port_available(&port, is_tcp)) { continue; } @@ -155,4 +156,4 @@ int grpc_pick_unused_port_or_die(void) { return port; } -#endif /* GPR_POSIX_SOCKET */ +#endif /* GPR_POSIX_SOCKET && GRPC_TEST_PICK_PORT */ diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 668a069f26..0b3c54373d 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -59,6 +59,10 @@ extern "C" { gpr_time_add(gpr_now(), \ gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x))) +#ifndef GRPC_TEST_CUSTOM_PICK_PORT +#define GRPC_TEST_PICK_PORT +#endif + void grpc_test_init(int argc, char **argv); #ifdef __cplusplus |