git: a91b30766883 - stable/15 - rtld: add a test for rtld_set_var (with LIBRARY_PATH_FDS)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 02 Apr 2026 02:17:08 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=a91b3076688311397630d37b4c093f5f18680cec
commit a91b3076688311397630d37b4c093f5f18680cec
Author: Alex S <iwtcex@gmail.com>
AuthorDate: 2026-03-25 00:56:01 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-04-02 02:13:50 +0000
rtld: add a test for rtld_set_var (with LIBRARY_PATH_FDS)
PR: 294054
(cherry picked from commit 9f16078b5f8c44d5718ecc940ab0b4ed5a1877a5)
---
libexec/rtld-elf/tests/Makefile | 1 +
libexec/rtld-elf/tests/set_var_test.c | 38 +++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/libexec/rtld-elf/tests/Makefile b/libexec/rtld-elf/tests/Makefile
index c4b3baab4cb8..3c05b52b83bb 100644
--- a/libexec/rtld-elf/tests/Makefile
+++ b/libexec/rtld-elf/tests/Makefile
@@ -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
diff --git a/libexec/rtld-elf/tests/set_var_test.c b/libexec/rtld-elf/tests/set_var_test.c
new file mode 100644
index 000000000000..6279bd5ecb44
--- /dev/null
+++ b/libexec/rtld-elf/tests/set_var_test.c
@@ -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();
+}