From f6f5e28f3382d3828228089765040413682db85a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 20 Dec 2013 16:53:32 +0100 Subject: torture: Add torture_server_port(). --- tests/torture.c | 15 +++++++++++++++ tests/torture.h | 1 + 2 files changed, 16 insertions(+) diff --git a/tests/torture.c b/tests/torture.c index 2097ae5..3aeaa57 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -80,6 +80,21 @@ const char *torture_server_address(int family) return NULL; } +int torture_server_port(void) +{ + char *env = getenv("TORTURE_SERVER_PORT"); + + if (env != NULL && env[0] != '\0' && strlen(env) < 6) { + int port = atoi(env); + + if (port > 0 && port < 65536) { + return port; + } + } + + return TORTURE_ECHO_SRV_PORT; +} + void torture_setup_socket_dir(void **state) { struct torture_state *s; diff --git a/tests/torture.h b/tests/torture.h index be100f7..62382d6 100644 --- a/tests/torture.h +++ b/tests/torture.h @@ -59,6 +59,7 @@ struct torture_state { #endif const char *torture_server_address(int domain); +int torture_server_port(void); void torture_setup_socket_dir(void **state); void torture_setup_echo_srv_udp_ipv4(void **state); -- cgit