Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177748765
D61609.1795194391.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D61609.1795194391.diff
View Options
diff --git a/contrib/netbsd-tests/lib/libpthread/t_name.c b/contrib/netbsd-tests/lib/libpthread/t_name.c
--- a/contrib/netbsd-tests/lib/libpthread/t_name.c
+++ b/contrib/netbsd-tests/lib/libpthread/t_name.c
@@ -54,10 +54,24 @@
pthread_t self = pthread_self();
char retname[32];
+#ifdef __FreeBSD__
+ /* Check initial name is empty on the created thread */
+ (void) strcpy(retname, "foo");
+ PTHREAD_REQUIRE(pthread_getname_np(self, retname, sizeof(retname)));
+ ATF_REQUIRE_EQ(retname[0], '\0');
+
+ /* FreeBSD sets the name explicitly after the thread is created */
+ PTHREAD_REQUIRE(pthread_setname_np(self, NAME_JUST_RIGHT));
+#endif
+ /* NetBSD supplies the initial name through thread attributes */
PTHREAD_REQUIRE(pthread_getname_np(self, retname, sizeof(retname)));
ATF_REQUIRE_STREQ(retname, NAME_JUST_RIGHT);
+#ifdef __FreeBSD__
+ PTHREAD_REQUIRE(pthread_setname_np(self, non_const_name));
+#else
PTHREAD_REQUIRE(pthread_setname_np(self, non_const_name, NULL));
+#endif
(void) memset(non_const_name, 0, sizeof(non_const_name));
PTHREAD_REQUIRE(pthread_getname_np(self, retname, sizeof(retname)));
ATF_REQUIRE_STREQ(retname, CONST_NAME);
@@ -68,8 +82,13 @@
ATF_TC(name);
ATF_TC_HEAD(name, tc)
{
+#ifdef __FreeBSD__
+ atf_tc_set_md_var(tc, "descr",
+ "Checks pthread_{get,set}name_np() API");
+#else
atf_tc_set_md_var(tc, "descr",
"Checks pthread_{,attr}_{get,set}name_np() API");
+#endif
}
ATF_TC_BODY(name, tc)
{
@@ -78,12 +97,19 @@
char retname[32];
PTHREAD_REQUIRE(pthread_attr_init(&attr));
+#ifdef __NetBSD__
PTHREAD_REQUIRE(pthread_attr_getname_np(&attr, retname,
sizeof(retname), NULL));
ATF_REQUIRE_EQ(retname[0], '\0');
+ /*
+ * NetBSD rejects 32-character names in thread attributes.
+ * FreeBSD's pthread_setname_np() does not impose a fixed name length
+ * limit, so this length boundary check is specific to NetBSD.
+ */
ATF_REQUIRE_EQ(pthread_attr_setname_np(&attr, NAME_TOO_LONG, NULL), EINVAL);
PTHREAD_REQUIRE(pthread_attr_setname_np(&attr, "%s",
__UNCONST(NAME_JUST_RIGHT)));
+#endif
(void) strcpy(retname, "foo");
PTHREAD_REQUIRE(pthread_getname_np(self, retname, sizeof(retname)));
diff --git a/lib/libthr/tests/Makefile b/lib/libthr/tests/Makefile
--- a/lib/libthr/tests/Makefile
+++ b/lib/libthr/tests/Makefile
@@ -4,7 +4,6 @@
TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libpthread
-# TODO: t_name (missing pthread_getname_np support in FreeBSD)
NETBSD_ATF_TESTS_C= barrier_test
NETBSD_ATF_TESTS_C+= cond_test
NETBSD_ATF_TESTS_C+= condwait_test
@@ -15,6 +14,7 @@
NETBSD_ATF_TESTS_C+= join_test
NETBSD_ATF_TESTS_C+= kill_test
NETBSD_ATF_TESTS_C+= mutex_test
+NETBSD_ATF_TESTS_C+= name_test
NETBSD_ATF_TESTS_C+= once_test
NETBSD_ATF_TESTS_C+= preempt_test
NETBSD_ATF_TESTS_C+= rwlock_test
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 20, 5:06 PM (19 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41871991
Default Alt Text
D61609.1795194391.diff (2 KB)
Attached To
Mode
D61609: libthr: Enable the thread name test
Attached
Detach File
Event Timeline