]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Use flat namespace on macOS
authorRoman Bolshakov <r.bolshakov@yadro.com>
Wed, 21 Aug 2019 16:13:21 +0000 (19:13 +0300)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 23 Aug 2019 10:26:26 +0000 (11:26 +0100)
Test executables and mocks have assumption that any symbol can be
replaced with LD_PRELOAD. That's not a case for macOS unless flat
namespace is used, because every external symbol reference records the
library to be looked up. And the symbols cannot be replaced unless dyld
interposing is used.

Setting DYLD_FORCE_FLAT_NAMESPACE changes symbol lookup behaviour to be
similar to Linux dynamic linker. It's more lightweight solution than
explicitly decorating all mock symbols as interpositions and building
libvirt as interposable dynamic library.

This fixes vircryptotest and allows to proceed other tests that rely on
mocks a little bit further.

Signed-off-by: Roman Bolshakov <r.bolshakov@yadro.com>
tests/testutils.h

index 766010199109d07a576de3751f0213f838529a74..b46bc86d84286ae5ff081a0e85e490a682ac2735 100644 (file)
@@ -119,9 +119,12 @@ int virTestMain(int argc,
 
 #ifdef __APPLE__
 # define PRELOAD_VAR "DYLD_INSERT_LIBRARIES"
+# define FORCE_FLAT_NAMESPACE \
+            setenv("DYLD_FORCE_FLAT_NAMESPACE", "1", 1);
 # define MOCK_EXT ".dylib"
 #else
 # define PRELOAD_VAR "LD_PRELOAD"
+# define FORCE_FLAT_NAMESPACE
 # define MOCK_EXT ".so"
 #endif
 
@@ -141,6 +144,7 @@ int virTestMain(int argc,
                 return EXIT_FAILURE; \
             } \
             setenv(PRELOAD_VAR, newenv, 1); \
+            FORCE_FLAT_NAMESPACE \
             execv(argv[0], argv); \
         } \
     } while (0)