rtld: add a test for rtld_set_var (with LIBRARY_PATH_FDS)

PR:	294054
Reviewed by:	kib
MFC after:	1 week
This commit is contained in:
Alex S
2026-03-25 03:56:01 +03:00
committed by Konstantin Belousov
parent f7b368d25f
commit 9f16078b5f
2 changed files with 39 additions and 0 deletions
+1
View File
@@ -7,6 +7,7 @@ SUBDIR_DEPEND_target= libpythagoras
ATF_TESTS_C= ld_library_pathfds
ATF_TESTS_C+= ld_preload_fds
ATF_TESTS_C+= set_var_test
.for t in ${ATF_TESTS_C}
SRCS.$t= $t.c common.c
+38
View File
@@ -0,0 +1,38 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright (c) 2026 Alex S <iwtcex@gmail.com>
*/
#include <atf-c.h>
#include <dlfcn.h>
#include <fcntl.h>
#include <link.h>
#include <stdio.h>
ATF_TC_WITHOUT_HEAD(set_var_library_path_fds);
ATF_TC_BODY(set_var_library_path_fds, tc)
{
void *handle;
char *pathfds;
int testdir;
handle = dlopen("libpythagoras.so.0", RTLD_LAZY);
ATF_REQUIRE(handle == NULL);
testdir = open(atf_tc_get_config_var(tc, "srcdir"),
O_RDONLY | O_DIRECTORY);
ATF_REQUIRE(testdir >= 0);
ATF_REQUIRE(asprintf(&pathfds, "%d", testdir) > 0);
ATF_REQUIRE(rtld_set_var("LIBRARY_PATH_FDS", pathfds) == 0);
handle = dlopen("libpythagoras.so.0", RTLD_LAZY);
ATF_REQUIRE(handle != NULL);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, set_var_library_path_fds);
return atf_no_error();
}