
commit 70822d08bd80378cb2dbbdac1ac7af46d3bc6d2d Author: David Goulet <dgoulet@ev0ke.net> Date: Fri Aug 4 15:20:39 2017 -0400 test: Detect if tor is running in test_fd_passing Also, replace spaces for a tab. Signed-off-by: David Goulet <dgoulet@ev0ke.net> --- tests/Makefile.am | 2 +- tests/test_fd_passing.c | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index e703168..fe6d3ad 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -30,7 +30,7 @@ test_socket_LDADD = $(LIBTAP) $(LIBTORSOCKS) test_connect_SOURCES = test_connect.c test_connect_LDADD = $(LIBTAP) $(LIBTORSOCKS) -test_fd_passing_SOURCES = test_fd_passing.c +test_fd_passing_SOURCES = test_fd_passing.c $(HELPER_SOURCES) test_fd_passing_LDADD = $(LIBTAP) $(LIBTORSOCKS) -lpthread test_getpeername_SOURCES = test_getpeername.c $(HELPER_SOURCES) diff --git a/tests/test_fd_passing.c b/tests/test_fd_passing.c index 8d41496..59ca4a8 100644 --- a/tests/test_fd_passing.c +++ b/tests/test_fd_passing.c @@ -28,6 +28,7 @@ #include <lib/torsocks.h> #include <tap/tap.h> +#include "helpers.h" #define NUM_TESTS 5 @@ -514,10 +515,17 @@ error: int main(int argc, char **argv) { + /* Try to connect to SocksPort localhost:9050 and if we can't skip. This is + * to avoid to have failing test if no tor daemon is available. */ + if (!helper_is_default_tor_running()) { + goto end; + } + /* Libtap call for the number of tests planned. */ plan_tests(NUM_TESTS); test_inet_socket(); - return 0; +end: + return 0; }