From: Erik van der Kouwe Date: Thu, 2 Jul 2015 17:01:58 +0000 (+0200) Subject: test48: Introduce USENETWORK variable. X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=95b9ecf9958becff4c5bad2dfb59a37cb9bb6f05;p=minix.git test48: Introduce USENETWORK variable. This patch introduces USENETWORK environment variable to determine whether to use the network or not, instead of the unreliable ping test; set to 'yes' to enable network usage. Change-Id: I9e26fa95b5b990fd94f5978db8de0dd73496d314 --- diff --git a/minix/tests/run b/minix/tests/run index d46a3c3c5..7bc938aa2 100755 --- a/minix/tests/run +++ b/minix/tests/run @@ -16,6 +16,7 @@ failed=`expr 0` # count number of tests that failed skipped=`expr 0` # count number of tests that were skipped total=`expr 0` # total number of tests tried badones= # list of tests that failed +export USENETWORK # set to "yes" for test48 to use the network # In the lists below, shell scripts should be listed without ".sh" suffix diff --git a/minix/tests/test48.c b/minix/tests/test48.c index 7f994898c..697bd9459 100644 --- a/minix/tests/test48.c +++ b/minix/tests/test48.c @@ -577,17 +577,18 @@ static void test_getnameinfo_all(void) static int can_use_network(void) { - int status; + const char *usenet; - /* try to ping minix3.org */ - status = system("ping -w 5 www.minix3.org > /dev/null 2>&1"); - if (status == 127) - { - printf("cannot execute ping\n"); - err(); - } + /* set $USENETWORK to "yes" or "no" to indicate whether + * an internet connection is to be expected; defaults to "no" + */ + usenet = getenv("USENETWORK"); + if (!usenet || !*usenet) return 0; /* default: disable network */ + if (strcmp(usenet, "yes") == 0) return 1; /* network enabled */ + if (strcmp(usenet, "no") == 0) return 0; /* network disabled */ - return status == 0; + fprintf(stderr, "warning: invalid $USENETWORK value: %s\n", usenet); + return 0; } int main(void) @@ -597,8 +598,6 @@ int main(void) start(48); use_network = can_use_network(); - if (!use_network) - printf("Warning: no network\n"); test_getaddrinfo_all(use_network); test_getnameinfo_all();