diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/engine.c | 9 | ||||
-rw-r--r-- | tests/meson.build | 4 | ||||
-rw-r--r-- | tests/shm.c | 10 |
3 files changed, 8 insertions, 15 deletions
diff --git a/tests/engine.c b/tests/engine.c index 7f2a748..fd2a348 100644 --- a/tests/engine.c +++ b/tests/engine.c @@ -2,6 +2,7 @@ #include "../engine/dconf-engine.h" #include "../engine/dconf-engine-profile.h" +#include "../engine/dconf-engine-mockable.h" #include "../common/dconf-enums.h" #include "dconf-mock.h" @@ -17,13 +18,9 @@ static const gchar *filename_to_replace; static const gchar *filename_to_replace_it_with; FILE * -fopen (const char *filename, +dconf_engine_fopen (const char *filename, const char *mode) { - static FILE * (*real_fopen) (const char *, const char *); - - if (!real_fopen) - real_fopen = dlsym (RTLD_NEXT, "fopen"); if (filename_to_replace && g_str_equal (filename, filename_to_replace)) { @@ -32,7 +29,7 @@ fopen (const char *filename, filename = filename_to_replace_it_with; } - return (* real_fopen) (filename, mode); + return fopen (filename, mode); } static void assert_no_messages (void); diff --git a/tests/meson.build b/tests/meson.build index 247ad76..8aa5837 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -24,11 +24,11 @@ unit_tests = [ # [name, sources, c_args, dependencies, link_with] ['paths', 'paths.c', [], libdconf_common_dep, []], ['changeset', 'changeset.c', [], libdconf_common_dep, []], - ['shm', ['shm.c', 'tmpdir.c'], [], [dl_dep, libdconf_common_dep, libdconf_shm_dep], []], + ['shm', ['shm.c', 'tmpdir.c'], [], [dl_dep, libdconf_common_dep, libdconf_shm_test_dep], []], ['gvdb', 'gvdb.c', '-DSRCDIR="@0@"'.format(test_dir), libgvdb_dep, []], ['gdbus-thread', 'dbus.c', '-DDBUS_BACKEND="/gdbus/thread"', libdconf_gdbus_thread_dep, []], ['gdbus-filter', 'dbus.c', '-DDBUS_BACKEND="/gdbus/filter"', libdconf_gdbus_filter_dep, []], - ['engine', 'engine.c', '-DSRCDIR="@0@"'.format(test_dir), [dl_dep, libdconf_engine_dep, m_dep], libdconf_mock], + ['engine', 'engine.c', '-DSRCDIR="@0@"'.format(test_dir), [dl_dep, libdconf_engine_test_dep, m_dep], libdconf_mock], ['client', 'client.c', '-DSRCDIR="@0@"'.format(test_dir), [libdconf_client_dep, libdconf_engine_dep], libdconf_mock], ['writer', 'writer.c', '-DSRCDIR="@0@"'.format(test_dir), [glib_dep, dl_dep, m_dep, libdconf_service_dep], [libdconf_mock]], ] diff --git a/tests/shm.c b/tests/shm.c index a0cf67e..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 @@ -90,20 +91,15 @@ test_flag_nonexistent (void) 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"); - if (should_fail_pwrite) { errno = ENOSPC; return -1; } - return (* real_pwrite) (fd, buf, count, offset); + return pwrite (fd, buf, count, offset); } static void |