]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: Allow expansion of mocked stat symbols
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 7 Mar 2022 08:21:26 +0000 (09:21 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Mon, 7 Mar 2022 09:31:24 +0000 (10:31 +0100)
When libc uses a define to rewrite stat64 to stat our mocks do not work if they
are chained because the symbol that we are looking up is being stringified and
therefore preventing the stat64->stat expansion per C-preprocessor rules.  One
stringification macro is just enough to make it work.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/virmock.h

index 5250e733a156fa50c85db4c1215b9c336876ce9d..300ba17174d4db279d204cd62680006ee3a366eb 100644 (file)
     do {} while (0)
 #endif
 
+#define VIR_MOCK_STRINGIFY_SYMBOL(name) #name
+
 #define VIR_MOCK_REAL_INIT(name) \
     do { \
         VIR_MOCK_REAL_INIT_MAIN(name, #name); \
         if (real_##name == NULL && \
             !(real_##name = dlsym(RTLD_NEXT, \
-                                  #name))) { \
+                                  VIR_MOCK_STRINGIFY_SYMBOL(name)))) { \
             fprintf(stderr, "Missing symbol '" #name "'\n"); \
             abort(); \
         } \