mirror of
https://git.openafs.org/openafs.git
synced 2025-01-18 15:00:12 +00:00
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 <marc.c.dionne@gmail.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
This commit is contained in:
parent
58c089e642
commit
70c4369e89
@ -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
|
||||
|
@ -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);
|
||||
|
44
tests/common/network.c
Normal file
44
tests/common/network.c
Normal file
@ -0,0 +1,44 @@
|
||||
#include <afsconfig.h>
|
||||
#include <afs/param.h>
|
||||
#include <afs/cellconfig.h>
|
||||
#include <rx/rx.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <tests/tap/basic.h>
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user