t_dlinfo, t_rtld_r_debug: Audit ATF_REQUIRE/CHECK, sprinkle messages.
Make sure to use ATF_REQUIRE when the subsequent code doesn't work if the check fails.
This commit is contained in:
parent
e441ef5517
commit
c73729f0bb
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: t_dlinfo.c,v 1.7 2023/11/24 17:40:09 riastradh Exp $ */
|
/* $NetBSD: t_dlinfo.c,v 1.8 2023/11/24 17:40:20 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
* Copyright (c) 2009 The NetBSD Foundation, Inc.
|
||||||
|
@ -46,7 +46,7 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_self, tc)
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
rv = dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map);
|
rv = dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map);
|
||||||
ATF_CHECK_EQ(rv, 0);
|
ATF_REQUIRE_EQ_MSG(rv, 0, "dlinfo: %s", dlerror());
|
||||||
ATF_CHECK((strstr(map->l_name, "t_dlinfo") != NULL));
|
ATF_CHECK((strstr(map->l_name, "t_dlinfo") != NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_inval, tc)
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
rv = dlinfo(NULL, RTLD_DI_LINKMAP, &v);
|
rv = dlinfo(NULL, RTLD_DI_LINKMAP, &v);
|
||||||
ATF_CHECK_EQ(rv, -1);
|
ATF_CHECK_EQ_MSG(rv, -1, "rv=%d", rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
ATF_TC(rtld_dlinfo_linkmap_dlopen);
|
ATF_TC(rtld_dlinfo_linkmap_dlopen);
|
||||||
|
@ -76,12 +76,12 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen, tc)
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
handle = dlopen("libutil.so", RTLD_LAZY);
|
handle = dlopen("libutil.so", RTLD_LAZY);
|
||||||
ATF_CHECK(handle);
|
ATF_REQUIRE_MSG(handle, "dlopen: %s", dlerror());
|
||||||
|
|
||||||
rv = dlinfo(handle, RTLD_DI_LINKMAP, &map);
|
rv = dlinfo(handle, RTLD_DI_LINKMAP, &map);
|
||||||
ATF_CHECK_EQ(rv, 0);
|
ATF_REQUIRE_EQ_MSG(rv, 0, "dlinfo: %s", dlerror());
|
||||||
ATF_CHECK((strstr(map->l_name, "libutil.so") != NULL));
|
ATF_CHECK((strstr(map->l_name, "libutil.so") != NULL));
|
||||||
dlclose(handle);
|
ATF_CHECK_EQ_MSG(dlclose(handle), 0, "dlclose: %s", dlerror());
|
||||||
}
|
}
|
||||||
|
|
||||||
ATF_TC(rtld_dlinfo_linkmap_dlopen_iter);
|
ATF_TC(rtld_dlinfo_linkmap_dlopen_iter);
|
||||||
|
@ -95,7 +95,7 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen_iter, tc)
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
handle = dlopen("libutil.so", RTLD_LAZY);
|
handle = dlopen("libutil.so", RTLD_LAZY);
|
||||||
ATF_CHECK(handle);
|
ATF_REQUIRE_MSG(handle, "dlopen: %s", dlerror());
|
||||||
|
|
||||||
ATF_REQUIRE_EQ_MSG(dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map), 0,
|
ATF_REQUIRE_EQ_MSG(dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &map), 0,
|
||||||
"dlinfo: %s", dlerror());
|
"dlinfo: %s", dlerror());
|
||||||
|
@ -108,7 +108,7 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen_iter, tc)
|
||||||
|
|
||||||
ATF_REQUIRE_MSG(map, "dlopen()d object not found from linkmap");
|
ATF_REQUIRE_MSG(map, "dlopen()d object not found from linkmap");
|
||||||
ATF_REQUIRE_MSG(dlopen(map->l_name, RTLD_LAZY) != NULL,
|
ATF_REQUIRE_MSG(dlopen(map->l_name, RTLD_LAZY) != NULL,
|
||||||
"could not dlopen() name in linkmap");
|
"could not dlopen() name in linkmap: %s", dlerror());
|
||||||
}
|
}
|
||||||
|
|
||||||
ATF_TP_ADD_TCS(tp)
|
ATF_TP_ADD_TCS(tp)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: t_rtld_r_debug.c,v 1.4 2023/11/24 17:40:09 riastradh Exp $ */
|
/* $NetBSD: t_rtld_r_debug.c,v 1.5 2023/11/24 17:40:20 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 The NetBSD Foundation, Inc.
|
* Copyright (c) 2020 The NetBSD Foundation, Inc.
|
||||||
|
@ -104,7 +104,9 @@ check_r_debug_return_link_map(const char *name, struct link_map **rmap)
|
||||||
loader = NULL;
|
loader = NULL;
|
||||||
debug = get_rtld_r_debug();
|
debug = get_rtld_r_debug();
|
||||||
ATF_CHECK(debug != NULL);
|
ATF_CHECK(debug != NULL);
|
||||||
ATF_CHECK(debug->r_version == R_DEBUG_VERSION);
|
ATF_CHECK_EQ_MSG(debug->r_version, R_DEBUG_VERSION,
|
||||||
|
"debug->r_version=%d R_DEBUG_VERSION=%d",
|
||||||
|
debug->r_version, R_DEBUG_VERSION);
|
||||||
map = debug->r_map;
|
map = debug->r_map;
|
||||||
ATF_CHECK(map != NULL);
|
ATF_CHECK(map != NULL);
|
||||||
|
|
||||||
|
@ -120,8 +122,12 @@ check_r_debug_return_link_map(const char *name, struct link_map **rmap)
|
||||||
ATF_CHECK(found);
|
ATF_CHECK(found);
|
||||||
ATF_CHECK(loader != NULL);
|
ATF_CHECK(loader != NULL);
|
||||||
ATF_CHECK(debug->r_brk != NULL);
|
ATF_CHECK(debug->r_brk != NULL);
|
||||||
ATF_CHECK(debug->r_state == RT_CONSISTENT);
|
ATF_CHECK_EQ_MSG(debug->r_state, RT_CONSISTENT,
|
||||||
ATF_CHECK(debug->r_ldbase == loader);
|
"debug->r_state=%d RT_CONSISTENT=%d",
|
||||||
|
debug->r_state, RT_CONSISTENT);
|
||||||
|
ATF_CHECK_EQ_MSG(debug->r_ldbase, loader,
|
||||||
|
"debug->r_ldbase=%p loader=%p",
|
||||||
|
debug->r_ldbase, loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
ATF_TC(self);
|
ATF_TC(self);
|
||||||
|
@ -146,15 +152,15 @@ ATF_TC_BODY(dlopen, tc)
|
||||||
struct link_map *map, *r_map;
|
struct link_map *map, *r_map;
|
||||||
|
|
||||||
handle = dlopen("libutil.so", RTLD_LAZY);
|
handle = dlopen("libutil.so", RTLD_LAZY);
|
||||||
ATF_CHECK(handle);
|
ATF_REQUIRE_MSG(handle, "dlopen: %s", dlerror());
|
||||||
|
|
||||||
check_r_debug_return_link_map("libutil.so", &r_map);
|
check_r_debug_return_link_map("libutil.so", &r_map);
|
||||||
|
|
||||||
ATF_REQUIRE_EQ_MSG(dlinfo(handle, RTLD_DI_LINKMAP, &map), 0,
|
ATF_REQUIRE_EQ_MSG(dlinfo(handle, RTLD_DI_LINKMAP, &map), 0,
|
||||||
"dlinfo: %s", dlerror());
|
"dlinfo: %s", dlerror());
|
||||||
|
|
||||||
ATF_CHECK(map == r_map);
|
ATF_CHECK_EQ_MSG(map, r_map, "map=%p r_map=%p", map, r_map);
|
||||||
dlclose(handle);
|
ATF_CHECK_EQ_MSG(dlclose(handle), 0, "dlclose: %s", dlerror());
|
||||||
}
|
}
|
||||||
|
|
||||||
ATF_TP_ADD_TCS(tp)
|
ATF_TP_ADD_TCS(tp)
|
||||||
|
|
Loading…
Reference in New Issue