From: Jason Edgecombe Date: Sat, 22 Sep 2012 03:14:37 +0000 (-0400) Subject: TESTS: Add a library to check for the default loopback network X-Git-Tag: openafs-stable-1_8_0pre1~1969 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=70c4369e893d6770f0f7b243c3e840c32b5a2a2b;hp=58c089e642198a210462b3bf508056b56667f879 TESTS: Add a library to check for the default loopback network Change-Id: Id7bb92345e97309363fa5ddbff9147edf30ccd96 Reviewed-on: http://gerrit.openafs.org/8145 Reviewed-by: Marc Dionne Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/tests/common/Makefile.in b/tests/common/Makefile.in index 11708e1..2909f61 100644 --- a/tests/common/Makefile.in +++ b/tests/common/Makefile.in @@ -4,9 +4,10 @@ abs_top_builddir=@abs_top_builddir@ include @TOP_OBJDIR@/src/config/Makefile.config include @TOP_OBJDIR@/src/config/Makefile.pthread -MODULE_CFLAGS=-I$(srcdir)/.. +MODULE_CFLAGS=-I$(srcdir)/.. -I$(srcdir)/../.. +CFLAGS_network.o = -Wno-strict-prototypes -all check test tests: config.o servers.o ubik.o rxkad.o +all check test tests: config.o servers.o ubik.o rxkad.o network.o clean: rm -f *.o diff --git a/tests/common/common.h b/tests/common/common.h index 9782a98..cf19692 100644 --- a/tests/common/common.h +++ b/tests/common/common.h @@ -50,3 +50,7 @@ extern int afstest_GetUbikClient(struct afsconf_dir *dir, char *service, struct rx_securityClass *secClass, int secIndex, struct ubik_client **ubikClient); + +/* network.c */ +extern int afstest_IsLoopbackNetworkDefault(void); +extern int afstest_SkipTestsIfLoopbackNetIsDefault(void); diff --git a/tests/common/network.c b/tests/common/network.c new file mode 100644 index 0000000..e605b28 --- /dev/null +++ b/tests/common/network.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include "common.h" + +extern int h_errno; + +/*! Check if the current machine's hostname resolves to the loopback + * network. + */ +int +afstest_IsLoopbackNetworkDefault(void) { + char hostname[MAXHOSTCHARS]; + afs_uint32 addr; + struct hostent *host; + + gethostname(hostname, sizeof(hostname)); + host = gethostbyname(hostname); + memcpy(&addr, host->h_addr, sizeof(addr)); + + return(rx_IsLoopbackAddr(ntohl(addr))); +} + +/*! Skips all TAP tests if the current machine's hostname resolves to the + * loopback network. + */ +int +afstest_SkipTestsIfLoopbackNetIsDefault(void) { + int retval=0; + retval=afstest_IsLoopbackNetworkDefault(); + if(retval==1) { + skip_all("Default IP address is on the loopback network!\n"); + } + + return retval; +}