]> git.ipfire.org Git - thirdparty/libvirt.git/commit
tests: Fix mocking of open()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 11 Jun 2025 14:17:33 +0000 (16:17 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 2 Jul 2025 11:54:04 +0000 (13:54 +0200)
commit300965f4f12261b141514354f12ca5d9995bf3ec
tree9a2cd89597ff4e8b6bd13e2e7cb6a0c4e836bc87
parent21e7bcc14fae7eca97cf738669ac73bed496ad2f
tests: Fix mocking of open()

In some cases (well, majority), open() is either rewritten to
open64(), either by plain '#define open open64') or at assembly
level (using __REDIRECT macro). See <fcntl.h> for more info.

This didn't really matter to us, because we do not chain load two
mocks that would need to reimplement open() at the same time. But
this is soon going to change.

The problem is, that VIR_MOCK_REAL_INIT(open) glances over
aforementioned rewrite and initializes real_open pointer to
open() from the standard C library. But it needs to point to
open() (well, open64()) from the next mock on the list.

Therefore, init real_open to open64().

But of course, this is all glibc specific and for example musl
does the oposite (#define open64 open).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/nssmock.c
tests/qemusecuritymock.c
tests/vircgroupmock.c
tests/virfilewrapper.c
tests/virpcimock.c
tests/virtestmock.c
tests/virusbmock.c