Tests: remove bug prone usage of dlsym and RTDL_NEXT
As seen in !36 (closed), there is a problem with the way the tests wrap the pwrite
function, using dlsym
with RTDL_NEXT
to call the original. Usually glibc would wrap pwrite
and handle making the correct system call on different systems (either pwrite
or pwrite64
), but dlsym
skips glibc's wrapper... for reasons that are difficult to understand.
Instead of duplicating the logic from glibc, I've removed direct calls to both of the functions that were mocked out in this way (pwrite
and fopen
) and replaced them with explicit wrappers (dconf_engine_fopen
and dconf_shm_pwrite
). The wrappers are implemented differently for production and test environments. The production modules (dconf-engine-mockable.c
, dconf-shm-mockable.c
) simply proxy the original functions and are linked with the relevant binaries, whereas the test modules (tests/engine.c
, tests/shm.c
) are not linked with them, and instead define their own mock versions.