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

tests: Drop VIR_MOCK_CALL_STAT

It wasn't as great idea as I thought. Thing around stat() are
more complicated than that. Therefore we need to revert
86d1705a plus drop use of the macro as introduced in
later patches.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 a1344f70
...@@ -558,7 +558,7 @@ int __lxstat(int ver, const char *path, struct stat *sb) ...@@ -558,7 +558,7 @@ int __lxstat(int ver, const char *path, struct stat *sb)
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
ret = VIR_MOCK_CALL_LSTAT(ver, newpath, sb); ret = real___lxstat(ver, newpath, sb);
free(newpath); free(newpath);
} else if (STRPREFIX(path, fakedevicedir0)) { } else if (STRPREFIX(path, fakedevicedir0)) {
sb->st_mode = S_IFBLK; sb->st_mode = S_IFBLK;
...@@ -569,7 +569,7 @@ int __lxstat(int ver, const char *path, struct stat *sb) ...@@ -569,7 +569,7 @@ int __lxstat(int ver, const char *path, struct stat *sb)
sb->st_rdev = makedev(9, 0); sb->st_rdev = makedev(9, 0);
return 0; return 0;
} else { } else {
ret = VIR_MOCK_CALL_LSTAT(ver, path, sb); ret = real___lxstat(ver, path, sb);
} }
return ret; return ret;
} }
...@@ -589,7 +589,7 @@ int lstat(const char *path, struct stat *sb) ...@@ -589,7 +589,7 @@ int lstat(const char *path, struct stat *sb)
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
ret = VIR_MOCK_CALL_LSTAT(_STAT_VER, newpath, sb); ret = real_lstat(newpath, sb);
free(newpath); free(newpath);
} else if (STRPREFIX(path, fakedevicedir0)) { } else if (STRPREFIX(path, fakedevicedir0)) {
sb->st_mode = S_IFBLK; sb->st_mode = S_IFBLK;
...@@ -600,7 +600,7 @@ int lstat(const char *path, struct stat *sb) ...@@ -600,7 +600,7 @@ int lstat(const char *path, struct stat *sb)
sb->st_rdev = makedev(9, 0); sb->st_rdev = makedev(9, 0);
return 0; return 0;
} else { } else {
ret = VIR_MOCK_CALL_LSTAT(_STAT_VER, path, sb); ret = real_lstat(path, sb);
} }
return ret; return ret;
} }
...@@ -620,7 +620,7 @@ int __xstat(int ver, const char *path, struct stat *sb) ...@@ -620,7 +620,7 @@ int __xstat(int ver, const char *path, struct stat *sb)
errno = ENOMEM; errno = ENOMEM;
return -1; return -1;
} }
ret = VIR_MOCK_CALL_STAT(ver, newpath, sb); ret = real___xstat(ver, newpath, sb);
free(newpath); free(newpath);
} else if (STRPREFIX(path, fakedevicedir0)) { } else if (STRPREFIX(path, fakedevicedir0)) {
sb->st_mode = S_IFBLK; sb->st_mode = S_IFBLK;
...@@ -631,7 +631,7 @@ int __xstat(int ver, const char *path, struct stat *sb) ...@@ -631,7 +631,7 @@ int __xstat(int ver, const char *path, struct stat *sb)
sb->st_rdev = makedev(9, 0); sb->st_rdev = makedev(9, 0);
return 0; return 0;
} else { } else {
ret = VIR_MOCK_CALL_STAT(ver, path, sb); ret = real___xstat(ver, path, sb);
} }
return ret; return ret;
} }
...@@ -671,7 +671,7 @@ int stat(const char *path, struct stat *sb) ...@@ -671,7 +671,7 @@ int stat(const char *path, struct stat *sb)
if (!(newpath = strdup(path))) if (!(newpath = strdup(path)))
return -1; return -1;
} }
ret = VIR_MOCK_CALL_STAT(_STAT_VER, newpath, sb); ret = real_stat(newpath, sb);
free(newpath); free(newpath);
return ret; return ret;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
# endif # endif
# include <stdlib.h> # include <stdlib.h>
# include <stdio.h> # include <stdio.h>
# include <sys/stat.h>
# include "internal.h" # include "internal.h"
...@@ -255,28 +254,6 @@ ...@@ -255,28 +254,6 @@
static void (*real_##name)(void); \ static void (*real_##name)(void); \
void name(void) void name(void)
static inline int
callStat(int (*realStat)(const char *, struct stat *),
int (*realXstat)(int, const char *, struct stat *),
int __ver, const char *__filename, struct stat *__stat_buf)
{
if (!realXstat) {
if (__ver == _STAT_VER) {
return realStat(__filename, __stat_buf);
} else {
fprintf(stderr, "Not handled __xstat(ver=%d)", __ver);
abort();
}
}
return realXstat(__ver, __filename, __stat_buf);
}
# define VIR_MOCK_CALL_STAT(__ver, __filename, __stat_buf) \
callStat(real_stat, real___xstat, __ver, __filename, __stat_buf)
# define VIR_MOCK_CALL_LSTAT(__ver, __filename, __stat_buf) \
callStat(real_lstat, real___lxstat, __ver, __filename, __stat_buf)
/* /*
* The VIR_MOCK_WRAP_NNN_MMM() macros are intended for use in the * The VIR_MOCK_WRAP_NNN_MMM() macros are intended for use in the
* individual test suites. The define a stub implementation of * individual test suites. The define a stub implementation of
......
...@@ -353,7 +353,8 @@ pci_device_new_from_stub(const struct pciDevice *data) ...@@ -353,7 +353,8 @@ pci_device_new_from_stub(const struct pciDevice *data)
/* If there is a config file for the device within virpcitestdata dir, /* If there is a config file for the device within virpcitestdata dir,
* symlink it. Otherwise create a dummy config file. */ * symlink it. Otherwise create a dummy config file. */
if (VIR_MOCK_CALL_STAT(_STAT_VER, configSrc, &sb) == 0) { if ((real_stat && real_stat(configSrc, &sb) == 0) ||
(real___xstat && real___xstat(_STAT_VER, configSrc, &sb) == 0)) {
/* On success, copy @configSrc into the destination (a copy, /* On success, copy @configSrc into the destination (a copy,
* rather than a symlink, is required since we write into the * rather than a symlink, is required since we write into the
* file, and parallel VPATH builds must not stomp on the * file, and parallel VPATH builds must not stomp on the
...@@ -868,10 +869,10 @@ __lxstat(int ver, const char *path, struct stat *sb) ...@@ -868,10 +869,10 @@ __lxstat(int ver, const char *path, struct stat *sb)
char *newpath; char *newpath;
if (getrealpath(&newpath, path) < 0) if (getrealpath(&newpath, path) < 0)
return -1; return -1;
ret = VIR_MOCK_CALL_LSTAT(ver, newpath, sb); ret = real___lxstat(ver, newpath, sb);
VIR_FREE(newpath); VIR_FREE(newpath);
} else { } else {
ret = VIR_MOCK_CALL_LSTAT(ver, path, sb); ret = real___lxstat(ver, path, sb);
} }
return ret; return ret;
} }
...@@ -887,10 +888,10 @@ lstat(const char *path, struct stat *sb) ...@@ -887,10 +888,10 @@ lstat(const char *path, struct stat *sb)
char *newpath; char *newpath;
if (getrealpath(&newpath, path) < 0) if (getrealpath(&newpath, path) < 0)
return -1; return -1;
ret = VIR_MOCK_CALL_LSTAT(_STAT_VER, newpath, sb); ret = real_lstat(newpath, sb);
VIR_FREE(newpath); VIR_FREE(newpath);
} else { } else {
ret = VIR_MOCK_CALL_LSTAT(_STAT_VER, path, sb); ret = real_lstat(path, sb);
} }
return ret; return ret;
} }
...@@ -906,10 +907,10 @@ __xstat(int ver, const char *path, struct stat *sb) ...@@ -906,10 +907,10 @@ __xstat(int ver, const char *path, struct stat *sb)
char *newpath; char *newpath;
if (getrealpath(&newpath, path) < 0) if (getrealpath(&newpath, path) < 0)
return -1; return -1;
ret = VIR_MOCK_CALL_STAT(ver, newpath, sb); ret = real___xstat(ver, newpath, sb);
VIR_FREE(newpath); VIR_FREE(newpath);
} else { } else {
ret = VIR_MOCK_CALL_STAT(ver, path, sb); ret = real___xstat(ver, path, sb);
} }
return ret; return ret;
} }
...@@ -925,10 +926,10 @@ stat(const char *path, struct stat *sb) ...@@ -925,10 +926,10 @@ stat(const char *path, struct stat *sb)
char *newpath; char *newpath;
if (getrealpath(&newpath, path) < 0) if (getrealpath(&newpath, path) < 0)
return -1; return -1;
ret = VIR_MOCK_CALL_STAT(_STAT_VER, newpath, sb); ret = real_stat(newpath, sb);
VIR_FREE(newpath); VIR_FREE(newpath);
} else { } else {
ret = VIR_MOCK_CALL_STAT(_STAT_VER, path, sb); ret = real_stat(path, sb);
} }
return ret; return ret;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <execinfo.h> #include <execinfo.h>
#include <sys/file.h> #include <sys/file.h>
#include <sys/stat.h>
#include "internal.h" #include "internal.h"
#include "configmake.h" #include "configmake.h"
...@@ -192,7 +193,7 @@ int stat(const char *path, struct stat *sb) ...@@ -192,7 +193,7 @@ int stat(const char *path, struct stat *sb)
checkPath(path); checkPath(path);
return VIR_MOCK_CALL_STAT(_STAT_VER, path, sb); return real_stat(path, sb);
} }
int int
...@@ -202,7 +203,7 @@ __xstat(int ver, const char *path, struct stat *sb) ...@@ -202,7 +203,7 @@ __xstat(int ver, const char *path, struct stat *sb)
checkPath(path); checkPath(path);
return VIR_MOCK_CALL_STAT(ver, path, sb); return real___xstat(ver, path, sb);
} }
int int
...@@ -212,7 +213,7 @@ lstat(const char *path, struct stat *sb) ...@@ -212,7 +213,7 @@ lstat(const char *path, struct stat *sb)
checkPath(path); checkPath(path);
return VIR_MOCK_CALL_LSTAT(_STAT_VER, path, sb); return real_lstat(path, sb);
} }
int int
...@@ -222,5 +223,5 @@ __lxstat(int ver, const char *path, struct stat *sb) ...@@ -222,5 +223,5 @@ __lxstat(int ver, const char *path, struct stat *sb)
checkPath(path); checkPath(path);
return VIR_MOCK_CALL_LSTAT(ver, path, sb); return real___lxstat(ver, path, sb);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册