Assume glibc >= 2.15.
This catches one trivial difference between us and glibc --- the error
returned by pthread_setname_np for an invalid pthread_t.
Change-Id: If4c21e22107c6488333d11184f8005f8669096c2
diff --git a/libc/bionic/pthread_setname_np.cpp b/libc/bionic/pthread_setname_np.cpp
index 7b2fa6b..93d4b2f 100644
--- a/libc/bionic/pthread_setname_np.cpp
+++ b/libc/bionic/pthread_setname_np.cpp
@@ -61,7 +61,7 @@
{
pthread_accessor thread(t);
if (thread.get() == NULL) {
- return ESRCH;
+ return ENOENT;
}
tid = thread->tid;
}
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 379e495..b5e12a5 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -359,50 +359,26 @@
ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, NULL));
}
-#if defined(__BIONIC__)
-#define HAVE_PTHREAD_SETNAME_NP
-#elif defined(__GLIBC__)
-#if __GLIBC_PREREQ(2, 12)
-#define HAVE_PTHREAD_SETNAME_NP
-#endif
-#endif
-
TEST(pthread, pthread_setname_np__too_long) {
-#if defined(HAVE_PTHREAD_SETNAME_NP)
ASSERT_EQ(ERANGE, pthread_setname_np(pthread_self(), "this name is far too long for linux"));
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
}
TEST(pthread, pthread_setname_np__self) {
-#if defined(HAVE_PTHREAD_SETNAME_NP)
ASSERT_EQ(0, pthread_setname_np(pthread_self(), "short 1"));
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
}
TEST(pthread, pthread_setname_np__other) {
-#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_t t1;
ASSERT_EQ(0, pthread_create(&t1, NULL, SleepFn, reinterpret_cast<void*>(5)));
ASSERT_EQ(0, pthread_setname_np(t1, "short 2"));
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
}
TEST(pthread, pthread_setname_np__no_such_thread) {
-#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_t dead_thread;
MakeDeadThread(dead_thread);
// Call pthread_setname_np after thread has already exited.
- ASSERT_EQ(ESRCH, pthread_setname_np(dead_thread, "short 3"));
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
+ ASSERT_EQ(ENOENT, pthread_setname_np(dead_thread, "short 3"));
}
TEST(pthread, pthread_kill__0) {
diff --git a/tests/sys_socket_test.cpp b/tests/sys_socket_test.cpp
index 38ef68a..eb8c33e 100644
--- a/tests/sys_socket_test.cpp
+++ b/tests/sys_socket_test.cpp
@@ -22,18 +22,6 @@
#include <sys/un.h>
#include <fcntl.h>
-#if defined(__BIONIC__)
- #define RECVMMSG_SUPPORTED 1
- #define SENDMMSG_SUPPORTED 1
-#elif defined(__GLIBC_PREREQ)
- #if __GLIBC_PREREQ(2, 12)
- #define RECVMMSG_SUPPORTED 1
- #endif
- #if __GLIBC_PREREQ(2, 14)
- #define SENDMMSG_SUPPORTED 1
- #endif
-#endif
-
#define SOCK_PATH "test"
static void* ConnectFn(void* data) {
@@ -120,7 +108,6 @@
RunTest(TestAccept4, NULL);
}
-#if defined(RECVMMSG_SUPPORTED)
const char* g_RecvMsgs[] = {
"RECVMMSG_ONE",
"RECVMMSG_TWO",
@@ -171,26 +158,16 @@
close(fd_acc);
}
-#endif
TEST(sys_socket, recvmmsg_smoke) {
-#if defined(RECVMMSG_SUPPORTED)
RunTest(TestRecvMMsg, SendMultiple);
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
}
TEST(sys_socket, recvmmsg_error) {
-#if defined(RECVMMSG_SUPPORTED)
ASSERT_EQ(-1, recvmmsg(-1, NULL, 0, 0, NULL));
ASSERT_EQ(EBADF, errno);
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
}
-#if defined(SENDMMSG_SUPPORTED)
const char* g_SendMsgs[] = {
"MSG_ONE",
"MSG_TWO",
@@ -239,21 +216,12 @@
close(fd_acc);
}
-#endif
TEST(sys_socket, sendmmsg_smoke) {
-#if defined(SENDMMSG_SUPPORTED)
RunTest(TestSendMMsg, SendMMsg);
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
}
TEST(sys_socket, sendmmsg_error) {
-#if defined(SENDMMSG_SUPPORTED)
ASSERT_EQ(-1, sendmmsg(-1, NULL, 0, 0));
ASSERT_EQ(EBADF, errno);
-#else
- GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif
}