computing-offload/generic_vdpa/libvirt/tests-Allow-expansion-of-mocked-stat-symbols.patch
jiangdongxu 79c4324644 add generic_vdpa basecode
Change-Id: I2d302dda68298877c65c99147f5bf22186a59aac
2024-09-19 17:19:46 +08:00

42 lines
1.7 KiB
Diff

From 9f6e5e5fe12e9cb4bb42918f597ba0268e57064b Mon Sep 17 00:00:00 2001
From: xuyinghao <xuyinghao2@huawei.com>
Date: Tue, 16 Aug 2022 19:08:45 +0800
Subject: [PATCH 08/13] tests: Allow expansion of mocked stat symbols
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 | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/virmock.h b/tests/virmock.h
index 95feeb0d92..188f0cf55b 100644
--- a/tests/virmock.h
+++ b/tests/virmock.h
@@ -57,6 +57,7 @@
#define VIR_MOCK_GET_ARG20(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t) z(a, b), z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, p), z(q, r), z(s, t)
#define VIR_MOCK_GET_ARG21(z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u) z(a, b), z(c, d), z(e, f), z(g, h), z(i, j), z(k, l), z(m, n), z(o, p), z(q, r), z(s, t)
+#define VIR_MOCK_STRINGIFY_SYMBOL(name) #name
#define VIR_MOCK_ARGNAMES_EXPAND(a, b, ...) VIR_MOCK_ARG_PASTE(a, b, __VA_ARGS__)
#define VIR_MOCK_ARGNAMES(...) \
@@ -283,7 +284,7 @@
do { \
if (real_##name == NULL && \
!(real_##name = dlsym(RTLD_NEXT, \
- #name))) { \
+ VIR_MOCK_STRINGIFY_SYMBOL(name)))) { \
fprintf(stderr, "Missing symbol '" #name "'\n"); \
abort(); \
} \
--
2.33.0