summaryrefslogtreecommitdiff
path: root/tests/lib/test_grpc.cpp
diff options
context:
space:
mode:
authorG. Paul Ziemba <p-fbsd-bugs@ziemba.us>2021-09-03 09:49:05 -0700
committerG. Paul Ziemba <p-fbsd-bugs@ziemba.us>2021-09-14 09:51:49 -0700
commit52fad8f6563080c64b5609f8b357ed47b1dfb78c (patch)
tree71f29fe8be8f7f7d68982c8e15abfdfbd08e3a18 /tests/lib/test_grpc.cpp
parent53b08a373db2aadff166bba08c40cdd72101768a (diff)
lib/module.c and callers of frrmod_load(): fix error messages
frrmod_load() attempts to dlopen() several possible paths (constructed from its basename argument) until one succeeds. Each dlopen() attempt may fail for a different reason, and the important one might not be the last one. Example: dlopen(a/foo): file not found dlopen(b/foo): symbol "bar" missing dlopen(c/foo): file not found Previous code reported only the most recent error. Now frrmod_load() describes each dlopen() failure. Signed-off-by: G. Paul Ziemba <paulz@labn.net>
Diffstat (limited to 'tests/lib/test_grpc.cpp')
-rw-r--r--tests/lib/test_grpc.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/tests/lib/test_grpc.cpp b/tests/lib/test_grpc.cpp
index 491796802a..0aa1bbb7e1 100644
--- a/tests/lib/test_grpc.cpp
+++ b/tests/lib/test_grpc.cpp
@@ -81,11 +81,16 @@ static const struct frr_yang_module_info *const staticd_yang_modules[] = {
static int grpc_thread_stop(struct thread *thread);
+static void _err_print(const void *cookie, const char *errstr)
+{
+ std::cout << "Failed to load grpc module:" << errstr << std::endl;
+}
+
static void static_startup(void)
{
// struct frrmod_runtime module;
// static struct option_chain *oc;
- char moderr[256] = {};
+
cmd_init(1);
zlog_aux_init("NONE: ", LOG_DEBUG);
@@ -94,17 +99,14 @@ static void static_startup(void)
/* Load the server side module -- check libtool path first */
std::string modpath = std::string(binpath) + std::string("../../../lib/.libs");
- grpc_module = frrmod_load("grpc:50051", modpath.c_str(), moderr, sizeof(moderr));
+ grpc_module = frrmod_load("grpc:50051", modpath.c_str(), 0, 0);
if (!grpc_module) {
modpath = std::string(binpath) + std::string("../../lib");
- grpc_module = frrmod_load("grpc:50051", modpath.c_str(), moderr,
- sizeof(moderr));
+ grpc_module = frrmod_load("grpc:50051", modpath.c_str(),
+ _err_print, 0);
}
- if (!grpc_module) {
- std::cout << "Failed to load grpc module:" << moderr
- << std::endl;
+ if (!grpc_module)
exit(1);
- }
static_debug_init();