]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virtestmock: Initialize symbols from stat() and its friends
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 6 May 2019 14:11:57 +0000 (16:11 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 7 May 2019 09:01:14 +0000 (11:01 +0200)
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@redhat.com>
tests/virtestmock.c

index bc62312444dfa148278758a0546f5f0b42bade65..df8cac64411a1910b60a727b295db631b641d8ae 100644 (file)
@@ -190,7 +190,11 @@ int access(const char *path, int mode)
 }
 
 
-#define VIR_MOCK_STAT_HOOK CHECK_PATH(path)
+#define VIR_MOCK_STAT_HOOK \
+    do { \
+        init_syms(); \
+        checkPath(path, "stat"); \
+    } while (0)
 
 #include "virmockstathelpers.c"