>From d37171c459734b0430fe4b55eb39b2606aba45f0 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 2 May 2013 16:19:22 +0200 Subject: [PATCH 2/3] tests: enable network tests based on environment variable Currently the tests that require a network connection can be enabled by selecting the -n command line parameter for the test. But in some cases, like the buildsystems, it might be better to actually enable network tests globally for all tests. This patch enables the network tests if the environment variable SSS_TESTS_USE_NETWORK is set. --- src/tests/fail_over-tests.c | 17 ++++++++++++++++- src/tests/resolv-tests.c | 12 +++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c index ea5eb8b0b7db46be74f46ab70e32e9539484d0c6..9e5523c835055b21d4a0512e3f7664db73c3ed4d 100644 --- a/src/tests/fail_over-tests.c +++ b/src/tests/fail_over-tests.c @@ -288,7 +288,11 @@ main(int argc, const char *argv[]) struct poptOption long_options[] = { POPT_AUTOHELP { "debug-level", 'd', POPT_ARG_INT, &debug_level, 0, "Set debug level", NULL }, - { "use-net-test", 'n', POPT_ARG_NONE, 0, 'n', "Run tests that need an active internet connection", NULL }, + { "use-net-test", 'n', POPT_ARG_NONE, 0, 'n', + "Run tests that need an active internet connection. " \ + "These tests can also be enabled by setting the " \ + "environment variable SSS_TESTS_USE_NETWORK", + NULL }, POPT_TABLEEND }; @@ -315,6 +319,17 @@ main(int argc, const char *argv[]) tests_set_cwd(); + if (getenv("SSS_TESTS_USE_NETWORK") != NULL) { + DEBUG(SSSDBG_CONF_SETTINGS, + ("Enabling unit tests that require network access\n")); + use_net_test = 1; + } + + if (!use_net_test) { + printf("Network tests disabled. Rerun with the \"-n\" " + "option to run the full suite of tests\n"); + } + suite = create_suite(); sr = srunner_create(suite); /* If CK_VERBOSITY is set, use that, otherwise it defaults to CK_NORMAL */ diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c index dd212c055f6c25c9add3c49a701df19c2e802faf..99d8e3ad5073b212712aeac3539c69014652a323 100644 --- a/src/tests/resolv-tests.c +++ b/src/tests/resolv-tests.c @@ -826,7 +826,11 @@ int main(int argc, const char *argv[]) struct poptOption long_options[] = { POPT_AUTOHELP { "debug-level", 'd', POPT_ARG_INT, &debug, 0, "Set debug level", NULL }, - { "use-net-test", 'n', POPT_ARG_NONE, 0, 'n', "Run tests that need an active internet connection", NULL }, + { "use-net-test", 'n', POPT_ARG_NONE, 0, 'n', + "Run tests that need an active internet connection. " \ + "These tests can also be enabled by setting the " \ + "environment variable SSS_TESTS_USE_NETWORK", + NULL }, { "txt-host", 't', POPT_ARG_STRING, 0, 't', "Specify the host used for TXT record testing", NULL }, { "srv-host", 's', POPT_ARG_STRING, 0, 's', "Specify the host used for SRV record testing", NULL }, POPT_TABLEEND @@ -858,6 +862,12 @@ int main(int argc, const char *argv[]) DEBUG_INIT(debug); + if (getenv("SSS_TESTS_USE_NETWORK") != NULL) { + DEBUG(SSSDBG_CONF_SETTINGS, + ("Enabling unit tests that require network access\n")); + use_net_test = 1; + } + if (!use_net_test) { printf("Network tests disabled. Rerun with the \"-n\" " "option to run the full suite of tests\n"); -- 1.8.2.1