[libvirt] [PATCH v2 1/8] test: Introduce VIR_MOCK_REAL_INIT_VERSIONED()

Andrea Bolognani abologna at redhat.com
Mon Apr 30 16:52:56 UTC 2018


This will be used later on to choose the modern implementation
of the functions we need to mock instead of the default, and
broken, one.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 tests/virmock.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/tests/virmock.h b/tests/virmock.h
index 914d5141c9..d35b1176fc 100644
--- a/tests/virmock.h
+++ b/tests/virmock.h
@@ -302,4 +302,17 @@
         } \
     } while (0)
 
+# define VIR_MOCK_REAL_INIT_VERSIONED(name, version) \
+    do { \
+        if (real_##name == NULL && \
+            !(real_##name = dlvsym(RTLD_NEXT, \
+                                   #name, \
+                                   version))) { \
+            fprintf(stderr, "Missing symbol '%s@%s'\n", \
+                            #name, \
+                            version); \
+            abort(); \
+        } \
+    } while (0)
+
 #endif /* __VIR_MOCK_H__ */
-- 
2.14.3




More information about the libvir-list mailing list