On Thu, 2020-01-16 at 09:28 +0100, Christian Ehrhardt wrote:
+VIR_MOCK_IMPL_RET_ARGS(virFileMakePath, int,
+ const char *, path)
+{
+ const char *home;
+
+ VIR_MOCK_REAL_INIT(virFileMakePath);
+
+ /* ignore non-existing homes (e.g. in build environments) */
+ home = getenv("HOME");
+ if (strstr(path, home)) {
+ if (!g_file_test (home, G_FILE_TEST_EXISTS))
+ return 0;
+ }
+ return real_virFileMakePath(path);
+}
This doesn't look like the correct fix: what will happen is that,
instead of creating the directory the library code expects, we will
not create it and lie to the caller about this fact.
What we should do instead is create the directory, but make sure it
is prefixed with LIBVIRT_FAKE_ROOT_DIR, in a similar way to what's
done in virpcimock. Of course file access will need to be mocked in
the same way for the tests to work...
--
Andrea Bolognani / Red Hat / Virtualization