提交 f2a519a5 编写于 作者: M Michal Privoznik

virtestmock: Track connect() too

The aim of this mock is to track if a test doesn't touch anything
in live system. Well, connect() which definitely falls into that
category isn't tracked yet.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 cfdc0c77
......@@ -27,6 +27,10 @@
#include <execinfo.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/socket.h>
#ifdef HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#include "internal.h"
#include "configmake.h"
......@@ -61,6 +65,7 @@ static int (*real_lstat)(const char *path, struct stat *sb);
static int (*real_lstat64)(const char *path, void *sb);
static int (*real___lxstat)(int ver, const char *path, struct stat *sb);
static int (*real___lxstat64)(int ver, const char *path, void *sb);
static int (*real_connect)(int fd, const struct sockaddr *addr, socklen_t addrlen);
static const char *progname;
const char *output;
......@@ -79,6 +84,7 @@ static void init_syms(void)
VIR_MOCK_REAL_INIT_ALT(stat64, __xstat64);
VIR_MOCK_REAL_INIT_ALT(lstat, __lxstat);
VIR_MOCK_REAL_INIT_ALT(lstat64, __lxstat64);
VIR_MOCK_REAL_INIT(connect);
}
static void
......@@ -321,3 +327,19 @@ __lxstat64(int ver, const char *path, struct stat64 *sb)
return real___lxstat64(ver, path, sb);
}
#endif
int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen)
{
init_syms();
#ifdef HAVE_SYS_UN_H
if (addrlen == sizeof(struct sockaddr_un)) {
struct sockaddr_un *tmp = (struct sockaddr_un *) addr;
if (tmp->sun_family == AF_UNIX)
checkPath(tmp->sun_path);
}
#endif
return real_connect(sockfd, addr, addrlen);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册