From 3c61c9bea60c1bc95efb131eaee414c457f0ab09 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Mon, 7 Mar 2022 09:21:26 +0100 Subject: [PATCH] tests: Allow expansion of mocked stat symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Michal Privoznik Reviewed-by: Ján Tomko --- tests/virmock.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/virmock.h b/tests/virmock.h index 5250e733a1..300ba17174 100644 --- a/tests/virmock.h +++ b/tests/virmock.h @@ -296,12 +296,14 @@ 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(); \ } \