diff options
author | Daniel Playfair Cal <daniel.playfair.cal@gmail.com> | 2019-01-07 22:33:15 +1100 |
---|---|---|
committer | Daniel Playfair Cal <daniel.playfair.cal@gmail.com> | 2019-02-12 19:47:56 +1100 |
commit | 8cbaee1c341b97d81fc597a4571b459baaac5c11 (patch) | |
tree | 1a1d58e7110fb231f0ea04d9b8626ec283e4a3c2 /tests/shm.c | |
parent | 38e625da7f47e457d150efedc598437e2e867ef7 (diff) | |
download | dconf-8cbaee1c341b97d81fc597a4571b459baaac5c11.tar.gz |
Tests: replace usage of dlsym with separate modules containing functions that need to be mocked out
Diffstat (limited to 'tests/shm.c')
-rw-r--r-- | tests/shm.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/tests/shm.c b/tests/shm.c index 26c5160..69d683f 100644 --- a/tests/shm.c +++ b/tests/shm.c @@ -10,6 +10,7 @@ #include <dlfcn.h> #include "../shm/dconf-shm.h" +#include "../shm/dconf-shm-mockable.h" #include "tmpdir.h" static void @@ -87,29 +88,18 @@ test_flag_nonexistent (void) dconf_shm_flag ("does-not-exist"); } -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 -#define PWRITE_SYM "pwrite64" -#else -#define PWRITE_SYM "pwrite" -#endif - static gboolean should_fail_pwrite; /* interpose */ ssize_t -pwrite (int fd, const void *buf, size_t count, off_t offset) +dconf_shm_pwrite (int fd, const void *buf, size_t count, off_t offset) { - static ssize_t (* real_pwrite) (int, const void *, size_t, off_t); - - if (!real_pwrite) - real_pwrite = dlsym (RTLD_NEXT, PWRITE_SYM); - if (should_fail_pwrite) { errno = ENOSPC; return -1; } - return (* real_pwrite) (fd, buf, count, offset); + return pwrite (fd, buf, count, offset); } static void |