mirror of
https://github.com/libvirt/libvirt.git
synced 2026-10-02 12:20:06 -05:00
tests: mock: Accept spaces in build path
If path to the build directory contains spaces (e.g. meson setup 'a b') then our mocks don't work. The problem is in glibc where not just a colon but also a space character is a delimiter for LD_PRELOAD [1]. Hence, a test using mock tries to preload something like libvirt.git/a b/libsomethingmock.so which is interpreted by glibc as two separate strings: "libvirt.git/a", "b/libsomethingmock.so". One trick to get around this is to set LD_PRELOAD to just the shared object file (without path) and let glibc find the mock in paths specified in LD_LIBRARY_PATH (where only a colon or a semicolon are valid separators [1]). This can be seen in action by running say: LD_DEBUG=libs ./virpcitest 1: https://man7.org/linux/man-pages/man8/ld.so.8.html Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
1 parent
ece476ec2e
commit
eac646ea49
5 files changed
+18
-6
No files matched your search
+4
-2
@@ -837,8 +837,10 @@ int virTestMain(int argc,
|
||||
|
||||
va_start(ap, func);
|
||||
while ((lib = va_arg(ap, const char *))) {
|
||||
if (!virFileIsExecutable(lib)) {
|
||||
perror(lib);
|
||||
g_autofree char *abs_lib_path = g_strdup_printf("%s/%s", abs_builddir, lib);
|
||||
|
||||
if (!virFileIsExecutable(abs_lib_path)) {
|
||||
perror(abs_lib_path);
|
||||
va_end(ap);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user