<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 17, 2020 at 6:47 PM Andrea Bolognani <<a href="mailto:abologna@redhat.com">abologna@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, 2020-01-16 at 09:28 +0100, Christian Ehrhardt wrote:<br>
> +VIR_MOCK_IMPL_RET_ARGS(virFileMakePath, int,<br>
> +                       const char *, path)<br>
> +{<br>
> +    const char *home;<br>
> +<br>
> +    VIR_MOCK_REAL_INIT(virFileMakePath);<br>
> +<br>
> +    /* ignore non-existing homes (e.g. in build environments) */<br>
> +    home = getenv("HOME");<br>
> +    if (strstr(path, home)) {<br>
> +        if (!g_file_test (home, G_FILE_TEST_EXISTS))<br>
> +            return 0;<br>
> +    }<br>
> +    return real_virFileMakePath(path);<br>
> +}<br>
<br>
This doesn't look like the correct fix: what will happen is that,<br>
instead of creating the directory the library code expects, we will<br>
not create it and lie to the caller about this fact.<br></blockquote><div> </div><div>Not creating and lying was exactly what I had in mind for this particular case as it was the least invasive change to achieve what was needed for the test.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
What we should do instead is create the directory, but make sure it<br>
is prefixed with LIBVIRT_FAKE_ROOT_DIR, in a similar way to what's<br>
done in virpcimock. Of course file access will need to be mocked in<br>
the same way for the tests to work...<br></blockquote><div> </div>I was initially adding all sorts of virFileWrapperAddPrefix but it failed me.</div><div class="gmail_quote">Trying again in the style of virpcimock seems like a good idea, but I have to be honest due to a business trip and some other tasks I won't get to it soon.</div><div class="gmail_quote">If that build error with non-existing $HOME bothers anyone else feel free to beat me to it with a v3 of this.<div><span style="color:rgb(0,0,0);font-family:monospace"><br></span></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
-- <br>
Andrea Bolognani / Red Hat / Virtualization<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Christian Ehrhardt<br>Staff Engineer, Ubuntu Server<br>Canonical Ltd</div></div>