mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tests: Mock virFileCanonicalizePath()
We're going to need this later on. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
026606caf2
commit
9190c37268
@ -43,6 +43,7 @@ static char *(*real_canonicalize_file_name)(const char *path);
|
|||||||
static int (*real_open)(const char *path, int flags, ...);
|
static int (*real_open)(const char *path, int flags, ...);
|
||||||
static int (*real_close)(int fd);
|
static int (*real_close)(int fd);
|
||||||
static DIR * (*real_opendir)(const char *name);
|
static DIR * (*real_opendir)(const char *name);
|
||||||
|
static char *(*real_virFileCanonicalizePath)(const char *path);
|
||||||
|
|
||||||
/* Don't make static, since it causes problems with clang
|
/* Don't make static, since it causes problems with clang
|
||||||
* when passed as an arg to virAsprintf()
|
* when passed as an arg to virAsprintf()
|
||||||
@ -814,6 +815,7 @@ init_syms(void)
|
|||||||
VIR_MOCK_REAL_INIT(open);
|
VIR_MOCK_REAL_INIT(open);
|
||||||
VIR_MOCK_REAL_INIT(close);
|
VIR_MOCK_REAL_INIT(close);
|
||||||
VIR_MOCK_REAL_INIT(opendir);
|
VIR_MOCK_REAL_INIT(opendir);
|
||||||
|
VIR_MOCK_REAL_INIT(virFileCanonicalizePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1046,6 +1048,28 @@ close(int fd)
|
|||||||
return -1;
|
return -1;
|
||||||
return real_close(fd);
|
return real_close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
virFileCanonicalizePath(const char *path)
|
||||||
|
{
|
||||||
|
char *ret;
|
||||||
|
|
||||||
|
init_syms();
|
||||||
|
|
||||||
|
if (STRPREFIX(path, SYSFS_PCI_PREFIX)) {
|
||||||
|
char *newpath;
|
||||||
|
|
||||||
|
if (getrealpath(&newpath, path) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ret = real_virFileCanonicalizePath(newpath);
|
||||||
|
VIR_FREE(newpath);
|
||||||
|
} else {
|
||||||
|
ret = real_virFileCanonicalizePath(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* Nothing to override on non-__linux__ platforms */
|
/* Nothing to override on non-__linux__ platforms */
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user