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
This commit is contained in:
Erik van der Kouwe 2015-07-02 19:01:58 +02:00 committed by Lionel Sambuc
parent 4d5b0de1fb
commit 95b9ecf995
2 changed files with 11 additions and 11 deletions

View file

@ -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

View file

@ -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();