From 1f71e76fdaed68321246e84b19684effdd83ff75 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Sat, 24 May 2025 12:57:11 +0100 Subject: [PATCH] testsuite: fprintf() + abort() when dlsym() returns NULL Currently each of our three dlsym() instances behaves differently. From seg-faulting, to abort() to assert(). Just use abort throughout, since assert() is no-op when NDEBUG is defined. Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/355 Signed-off-by: Lucas De Marchi --- testsuite/path.c | 6 +++++- testsuite/uname.c | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/testsuite/path.c b/testsuite/path.c index 947a3915..06060b85 100644 --- a/testsuite/path.c +++ b/testsuite/path.c @@ -84,7 +84,11 @@ static void *get_libc_func(const char *f) void *fp; fp = dlsym(RTLD_NEXT, f); - assert(fp); + if (fp == NULL) { + fprintf(stderr, "FIXME FIXME FIXME: could not load %s symbol: %s\n", f, + dlerror()); + abort(); + } return fp; } diff --git a/testsuite/uname.c b/testsuite/uname.c index 0333f7a9..ffd274dc 100644 --- a/testsuite/uname.c +++ b/testsuite/uname.c @@ -20,8 +20,15 @@ TS_EXPORT int uname(struct utsname *u) int err; size_t sz; - if (nextlib_uname == NULL) + if (nextlib_uname == NULL) { nextlib_uname = dlsym(RTLD_NEXT, "uname"); + if (nextlib_uname == NULL) { + fprintf(stderr, + "FIXME FIXME FIXME: could not load uname symbol: %s\n", + dlerror()); + abort(); + } + } err = nextlib_uname(u); if (err < 0) -- 2.47.2