On Wed, Mar 11, 2026 at 12:28:32 +0100, Michal Privoznik wrote:
> From: Michal Privoznik <[email protected]>
> 
> 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 <[email protected]>
> ---
>  tests/testutils.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/testutils.c b/tests/testutils.c
> index c984f66d0e..14e5c56fcf 100644
> --- a/tests/testutils.c
> +++ b/tests/testutils.c
> @@ -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();
> -- 
> 2.52.0
> 

Reviewed-by: Jiri Denemark <[email protected]>

Reply via email to