[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/6] tests: Decouple preload code from main()



The new VIRT_TEST_PRELOAD macro does not force the caller to create a
special main function which would need to be called through
virtTestMain().

Signed-off-by: Jiri Denemark <jdenemar redhat com>
---
 tests/testutils.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tests/testutils.h b/tests/testutils.h
index 0417a0b..123a4fb 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -110,8 +110,8 @@ int virtTestMain(int argc,
         return virtTestMain(argc, argv, func);  \
     }
 
-# define VIRT_TEST_MAIN_PRELOAD(func, lib)                              \
-    int main(int argc, char **argv) {                                   \
+# define VIRT_TEST_PRELOAD(lib)                                         \
+    do {                                                                \
         const char *preload = getenv("LD_PRELOAD");                     \
         if (preload == NULL || strstr(preload, lib) == NULL) {          \
             char *newenv;                                               \
@@ -128,6 +128,11 @@ int virtTestMain(int argc,
             setenv("LD_PRELOAD", newenv, 1);                            \
             execv(argv[0], argv);                                       \
         }                                                               \
+    } while (0)
+
+# define VIRT_TEST_MAIN_PRELOAD(func, lib)                              \
+    int main(int argc, char **argv) {                                   \
+        VIRT_TEST_PRELOAD(lib);                                         \
         return virtTestMain(argc, argv, func);                          \
     }
 
-- 
2.8.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]