git: 20318719dfd8 - stable/15 - rtld: add test for dlopen("#dirfd/path")
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 09 Apr 2026 08:25:48 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=20318719dfd8077c47ed3c37e8e29b17c365ae18
commit 20318719dfd8077c47ed3c37e8e29b17c365ae18
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-03-30 00:42:00 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-04-08 18:22:39 +0000
rtld: add test for dlopen("#dirfd/path")
(cherry picked from commit 72252591ac01037fa53501adb88f00d5d3cc09ed)
---
libexec/rtld-elf/tests/Makefile | 1 +
libexec/rtld-elf/tests/dlopen_hash_test.c | 45 +++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+)
diff --git a/libexec/rtld-elf/tests/Makefile b/libexec/rtld-elf/tests/Makefile
index 3c05b52b83bb..4fbc32d87615 100644
--- a/libexec/rtld-elf/tests/Makefile
+++ b/libexec/rtld-elf/tests/Makefile
@@ -14,6 +14,7 @@ SRCS.$t= $t.c common.c
.endfor
ATF_TESTS_C+= dlopen_test
+ATF_TESTS_C+= dlopen_hash_test
WARNS?= 3
diff --git a/libexec/rtld-elf/tests/dlopen_hash_test.c b/libexec/rtld-elf/tests/dlopen_hash_test.c
new file mode 100644
index 000000000000..a95ebdb34381
--- /dev/null
+++ b/libexec/rtld-elf/tests/dlopen_hash_test.c
@@ -0,0 +1,45 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Alex S <iwtcex@gmail.com>
+ * Copyright 2026 The FreeBSD Foundation
+ *
+ * Portions of this software were developed by
+ * Konstantin Belousov <kib@FreeBSD.org> under sponsorship from
+ * the FreeBSD Foundation.
+ */
+
+#include <atf-c.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <link.h>
+#include <stdio.h>
+
+ATF_TC_WITHOUT_HEAD(dlopen_hash);
+ATF_TC_BODY(dlopen_hash, tc)
+{
+ void *handle;
+ char *pathfds;
+ char *name;
+ 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);
+
+ ATF_REQUIRE(asprintf(&name, "#%d/libpythagoras.so.0", testdir) > 0);
+ handle = dlopen(name, RTLD_LAZY);
+ ATF_REQUIRE(handle != NULL);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, dlopen_hash);
+ return atf_no_error();
+}