]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Create fake root dirs later
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 11 Mar 2026 11:21:17 +0000 (12:21 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 11 Mar 2026 13:06:04 +0000 (14:06 +0100)
In one of previous commits the virTestMain() function was changed
to actually create fake HOME, XDG_RUNTIME_DIR, ... directories
instead of setting spoofed values in the environment. But
alongside with this, the call to virTestFakeRootDirInit() was
moved (to location where environment was poisoned). And this
would not matter if it wasn't for mocking. Because what we ended
up with is virTestFakeRootDirInit() is called and then
(optionally) the process re-execs itself (with mocks loaded).
This means that previously created root dirs are never cleaned
up and just pollute builddir.

Therefore, restore original location from which the function was
called.

Fixes: 79d97d2b4f0b55ea80f8330144953e2b93927e25
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
tests/testutils.c

index c984f66d0e3a6822598b3e33489369ad70a8bbd0..14e5c56fcf7207060c7239190ccae33741b539b6 100644 (file)
@@ -859,9 +859,6 @@ int virTestMain(int argc,
         preloads[npreloads] = NULL;
     }
 
-    if (!(fakerootdir = virTestFakeRootDirInit()))
-        return EXIT_FAILURE;
-
     va_start(ap, func);
     while ((lib = va_arg(ap, const char *))) {
         g_autofree char *abs_lib_path = g_strdup_printf("%s/%s", abs_builddir, lib);
@@ -934,6 +931,9 @@ int virTestMain(int argc,
 
     failedTests = virBitmapNew(1);
 
+    if (!(fakerootdir = virTestFakeRootDirInit()))
+        return EXIT_FAILURE;
+
     ret = (func)();
 
     virResetLastError();