From e441ef5517c57bdc0bacec2601c7358e723906b1 Mon Sep 17 00:00:00 2001 From: riastradh Date: Fri, 24 Nov 2023 17:40:09 +0000 Subject: [PATCH] rtld tests: Don't use RZ for dlinfo. Use ATF_REQUIRE_EQ_MSG(dlinfo(...), 0, "dlinfo: %s", dlerror()) instead, in order to accurately report the error on failure. RZ is only for functions like pthread_create(3) that return zero on success and errno(3) code on failure, but dlinfo returns -1 on failure and sets dlerror() to report the nature of the error. --- tests/libexec/ld.elf_so/t_dlinfo.c | 5 +++-- tests/libexec/ld.elf_so/t_rtld_r_debug.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/libexec/ld.elf_so/t_dlinfo.c b/tests/libexec/ld.elf_so/t_dlinfo.c index e7db9712963e..f66155ca1745 100644 --- a/tests/libexec/ld.elf_so/t_dlinfo.c +++ b/tests/libexec/ld.elf_so/t_dlinfo.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_dlinfo.c,v 1.6 2019/07/09 16:24:01 maya Exp $ */ +/* $NetBSD: t_dlinfo.c,v 1.7 2023/11/24 17:40:09 riastradh Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,8 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen_iter, tc) handle = dlopen("libutil.so", RTLD_LAZY); ATF_CHECK(handle); - RZ(dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map)); + ATF_REQUIRE_EQ_MSG(dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map), 0, + "dlinfo: %s", dlerror()); for (; map->l_next; map = map->l_next) continue; diff --git a/tests/libexec/ld.elf_so/t_rtld_r_debug.c b/tests/libexec/ld.elf_so/t_rtld_r_debug.c index 6a2ff8716b24..79f36d08cfd4 100644 --- a/tests/libexec/ld.elf_so/t_rtld_r_debug.c +++ b/tests/libexec/ld.elf_so/t_rtld_r_debug.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_rtld_r_debug.c,v 1.3 2020/09/29 16:35:42 roy Exp $ */ +/* $NetBSD: t_rtld_r_debug.c,v 1.4 2023/11/24 17:40:09 riastradh Exp $ */ /* * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -150,7 +150,8 @@ ATF_TC_BODY(dlopen, tc) check_r_debug_return_link_map("libutil.so", &r_map); - RZ(dlinfo(handle, RTLD_DI_LINKMAP, &map)); + ATF_REQUIRE_EQ_MSG(dlinfo(handle, RTLD_DI_LINKMAP, &map), 0, + "dlinfo: %s", dlerror()); ATF_CHECK(map == r_map); dlclose(handle);