[libvirt] [PATCH 2/3] virtestmock: Initialize symbols from stat() and its friends

Michal Privoznik mprivozn at redhat.com
Mon May 6 14:34:07 UTC 2019


Introduced by ff376c6283c97.

Previously, init_syms() was called from stat() mock and its
friends. This is crucial because checkPath() might call
printFile() which in turn calls real_fopen(). But if stat() or
one of its friends is the first function called then because of
lacking init_syms() call no real_* is initialized.

The other thing is that we really want the recorded action to be
"stat" instead of __FUNCTION__ because there's no good in
recording that it was __xstat64 who touched some file.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 tests/virtestmock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/virtestmock.c b/tests/virtestmock.c
index bc62312444..ad6958ac87 100644
--- a/tests/virtestmock.c
+++ b/tests/virtestmock.c
@@ -190,7 +190,9 @@ int access(const char *path, int mode)
 }
 
 
-#define VIR_MOCK_STAT_HOOK CHECK_PATH(path)
+#define VIR_MOCK_STAT_HOOK \
+    init_syms(); \
+    checkPath(path, "stat")
 
 #include "virmockstathelpers.c"
 
-- 
2.21.0




More information about the libvir-list mailing list