]> xenbits.xensource.com Git - libvirt.git/commit
tests: mock: Accept spaces in build path
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 22 Mar 2024 15:57:44 +0000 (16:57 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Apr 2024 07:24:16 +0000 (09:24 +0200)
commiteac646ea490e66500609585047f0d800e3645d6b
treedf1cd15a666f344ca772aa607d83c221bd114d8d
parentece476ec2e0ff85ce342fb1b0b691f37e88553b7
tests: mock: Accept spaces in build path

If path to the build directory contains spaces (e.g. meson setup
'a b') then our mocks don't work. The problem is in glibc where
not just a colon but also a space character is a delimiter for
LD_PRELOAD [1]. Hence, a test using mock tries to preload
something like libvirt.git/a b/libsomethingmock.so which is
interpreted by glibc as two separate strings: "libvirt.git/a",
"b/libsomethingmock.so".

One trick to get around this is to set LD_PRELOAD to just the
shared object file (without path) and let glibc find the mock in
paths specified in LD_LIBRARY_PATH (where only a colon or a
semicolon are valid separators [1]). This can be seen in action
by running say:

  LD_DEBUG=libs ./virpcitest

1: https://man7.org/linux/man-pages/man8/ld.so.8.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tests/securityselinuxlabeltest.c
tests/securityselinuxtest.c
tests/testutils.c
tests/testutils.h
tests/viridentitytest.c