Re: [libvirt] [PATCH 03/11] tests: Preload mocks with DYLD_INSERT_LIBRARIES on macOS

2019-08-21 Thread Daniel P . Berrangé
On Wed, Aug 21, 2019 at 07:13:15PM +0300, Roman Bolshakov wrote:
> LD_PRELOAD has no effect on macOS. Instead, dyld(1) provides a way for
> symbol hooking via DYLD_INSERT_LIBRARIES. The variable should contain
> colon-separated paths to the dylibs to be inserted.
> 
> Signed-off-by: Roman Bolshakov 
> ---
>  tests/testutils.h | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrangé 


Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH 03/11] tests: Preload mocks with DYLD_INSERT_LIBRARIES on macOS

2019-08-21 Thread Roman Bolshakov
LD_PRELOAD has no effect on macOS. Instead, dyld(1) provides a way for
symbol hooking via DYLD_INSERT_LIBRARIES. The variable should contain
colon-separated paths to the dylibs to be inserted.

Signed-off-by: Roman Bolshakov 
---
 tests/testutils.h | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tests/testutils.h b/tests/testutils.h
index 8c12fd7c12..07dda6e355 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -117,9 +117,15 @@ int virTestMain(int argc,
 return virTestMain(argc, argv, func, NULL); \
 }
 
+#ifdef __APPLE__
+# define PRELOAD_VAR "DYLD_INSERT_LIBRARIES"
+#else
+# define PRELOAD_VAR "LD_PRELOAD"
+#endif
+
 #define VIR_TEST_PRELOAD(lib) \
 do { \
-const char *preload = getenv("LD_PRELOAD"); \
+const char *preload = getenv(PRELOAD_VAR); \
 if (preload == NULL || strstr(preload, lib) == NULL) { \
 char *newenv; \
 if (!virFileIsExecutable(lib)) { \
@@ -132,7 +138,7 @@ int virTestMain(int argc,
 perror("virAsprintf"); \
 return EXIT_FAILURE; \
 } \
-setenv("LD_PRELOAD", newenv, 1); \
+setenv(PRELOAD_VAR, newenv, 1); \
 execv(argv[0], argv); \
 } \
 } while (0)
-- 
2.22.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list