Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 02 Apr 2026 02:42:16 +0000
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 72252591ac01 - main - rtld: add test for dlopen("#dirfd/path")
Message-ID:  <69cdd788.36fca.5f4d52bb@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=72252591ac01037fa53501adb88f00d5d3cc09ed

commit 72252591ac01037fa53501adb88f00d5d3cc09ed
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-03-30 00:42:00 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-04-02 02:41:56 +0000

    rtld: add test for dlopen("#dirfd/path")
    
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:   https://reviews.freebsd.org/D56152
---
 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();
+}


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69cdd788.36fca.5f4d52bb>