Skip to content

Commit

Permalink
test: get libaio symbols via dlsym(RTLD_NEXT, ...)
Browse files Browse the repository at this point in the history
disable lazy-binding and reference a symbol not wrapped for that
  • Loading branch information
wenningerk committed Mar 20, 2024
1 parent bd93f1d commit e89c634
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tests/regressions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
: ${SBD_TRANSLATE_AIO:= "no"}

sbd() {
LD_PRELOAD=${SBD_PRELOAD} SBD_DEVICE="${SBD_DEVICE}" SBD_PRELOAD_LOG=${SBD_PRELOAD_LOG} SBD_WATCHDOG_DEV=/dev/watchdog setsid ${SBD_BINARY} -p ${SBD_PIDFILE} "$@"
LD_BIND_NOW=yes LD_PRELOAD=${SBD_PRELOAD} SBD_DEVICE="${SBD_DEVICE}" SBD_PRELOAD_LOG=${SBD_PRELOAD_LOG} SBD_WATCHDOG_DEV=/dev/watchdog setsid ${SBD_BINARY} -p ${SBD_PIDFILE} "$@"
}

sbd_sleep() {
Expand Down
24 changes: 12 additions & 12 deletions tests/sbd-testbed.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ typedef int (*orig_io_getevents_f_type)(io_context_t ctx_id, long min_nr, long n
struct io_event *events, struct timespec *timeout);
typedef int (*orig_io_cancel_f_type)(io_context_t ctx_id, struct iocb *iocb,
struct io_event *result);
typedef int (*orig_io_pgetevents_f_type)(io_context_t ctx_id, long min_nr, long nr,
struct io_event *events, struct timespec *timeout,
sigset_t *sigmask);


static int is_init = 0;
static FILE *log_fp = NULL;
Expand Down Expand Up @@ -98,6 +102,7 @@ static orig_io_destroy_f_type orig_io_destroy = NULL;
static orig_io_submit_f_type orig_io_submit = NULL;
static orig_io_getevents_f_type orig_io_getevents = NULL;
static orig_io_cancel_f_type orig_io_cancel = NULL;
static orig_io_pgetevents_f_type orig_io_pgetevents = NULL;

/* fprintf is inlined as __fprintf_chk or
* we have vfprintf.
Expand Down Expand Up @@ -154,17 +159,12 @@ init (void)
orig_fopen = (orig_fopen_f_type)dlsym_fatal(RTLD_NEXT,"fopen");
orig_fclose = (orig_fclose_f_type)dlsym_fatal(RTLD_NEXT,"fclose");

handle = dlopen("libaio.so.1", RTLD_NOW);
if (!handle) {
fprintf(stderr, "Failed opening libaio.so.1\n");
exit(1);
}
orig_io_setup = (orig_io_setup_f_type)dlsym_fatal(handle,"io_setup");
orig_io_destroy = (orig_io_destroy_f_type)dlsym_fatal(handle,"io_destroy");
orig_io_submit = (orig_io_submit_f_type)dlsym_fatal(handle,"io_submit");
orig_io_getevents = (orig_io_getevents_f_type)dlsym_fatal(handle,"io_getevents");
orig_io_cancel = (orig_io_cancel_f_type)dlsym_fatal(handle,"io_cancel");
dlclose(handle);
orig_io_setup = (orig_io_setup_f_type)dlsym_fatal(RTLD_NEXT,"io_setup");
orig_io_destroy = (orig_io_destroy_f_type)dlsym_fatal(RTLD_NEXT,"io_destroy");
orig_io_submit = (orig_io_submit_f_type)dlsym_fatal(RTLD_NEXT,"io_submit");
orig_io_getevents = (orig_io_getevents_f_type)dlsym_fatal(RTLD_NEXT,"io_getevents");
orig_io_cancel = (orig_io_cancel_f_type)dlsym_fatal(RTLD_NEXT,"io_cancel");
orig_io_pgetevents= io_pgetevents; /* reference something we don't wrap */

value = getenv("SBD_PRELOAD_LOG");
if (value) {
Expand Down Expand Up @@ -203,7 +203,7 @@ init (void)
}
}

// ***** end - handling of watchdog & block-devices ****
// ***** handling of watchdog & block-devices ****

static gboolean
watchdog_timeout_notify(gpointer data)
Expand Down

0 comments on commit e89c634

Please sign in to comment.