Re: [libvirt PATCH 5/5] tests: Allow expansion of mocked stat symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 07, 2022 at 10:01:40AM +0000, Daniel P. Berrangé wrote:
On Mon, Mar 07, 2022 at 10:04:06AM +0100, Martin Kletzander wrote:
When libc uses a define to rewrite stat64 to stat our mocks do not work if they
are chained because the symbol that we are looking up is being stringified and
therefore preventing the stat64->stat expansion per C-preprocessor rules.  One
stringification macro is just enough to make it work.

This doesn't sound right to me.

If we're implementing a mock for 'stat64', we should not be looking
up 'stat'.  We should  be implmenting a mock for 'stat' instead.

It sounds more like we got MOCK_STAT and MOCK_STAT64 incorrectly
defined surely.


I spent three days trying to figure this out.  But with this fix we are
actually doing what you are suggesting.  All the (l)stat64 are being
replaced by (l)stat, so even:

int lstat64(const char *path, struct stat64 *statbuf)

is actually rewritten to

int lstat(const char *path, struct stat *statbuf)

because the define applies to the struct name as well.  The only
difference is that internally it will use the real_lstat64 function
pointer, but the function declaration is correct.  And if you enable
debugging it will say that lstat64 is being redirected, but that's a
pretty minor issue, if it is one at all.

What we could do is rewrite the macros so that all of the above is
properly expanded/substituted, but I do not think that is the way we
want to do things as it looked a bit messy (I probably still have that
commit somewhere.

Regards,
Daniel
--
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux