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:
parent
4d5b0de1fb
commit
95b9ecf995
2 changed files with 11 additions and 11 deletions
|
@ -16,6 +16,7 @@ failed=`expr 0` # count number of tests that failed
|
||||||
skipped=`expr 0` # count number of tests that were skipped
|
skipped=`expr 0` # count number of tests that were skipped
|
||||||
total=`expr 0` # total number of tests tried
|
total=`expr 0` # total number of tests tried
|
||||||
badones= # list of tests that failed
|
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
|
# In the lists below, shell scripts should be listed without ".sh" suffix
|
||||||
|
|
||||||
|
|
|
@ -577,17 +577,18 @@ static void test_getnameinfo_all(void)
|
||||||
|
|
||||||
static int can_use_network(void)
|
static int can_use_network(void)
|
||||||
{
|
{
|
||||||
int status;
|
const char *usenet;
|
||||||
|
|
||||||
/* try to ping minix3.org */
|
/* set $USENETWORK to "yes" or "no" to indicate whether
|
||||||
status = system("ping -w 5 www.minix3.org > /dev/null 2>&1");
|
* an internet connection is to be expected; defaults to "no"
|
||||||
if (status == 127)
|
*/
|
||||||
{
|
usenet = getenv("USENETWORK");
|
||||||
printf("cannot execute ping\n");
|
if (!usenet || !*usenet) return 0; /* default: disable network */
|
||||||
err();
|
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)
|
int main(void)
|
||||||
|
@ -597,8 +598,6 @@ int main(void)
|
||||||
start(48);
|
start(48);
|
||||||
|
|
||||||
use_network = can_use_network();
|
use_network = can_use_network();
|
||||||
if (!use_network)
|
|
||||||
printf("Warning: no network\n");
|
|
||||||
test_getaddrinfo_all(use_network);
|
test_getaddrinfo_all(use_network);
|
||||||
test_getnameinfo_all();
|
test_getnameinfo_all();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue