aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-10-27 20:01:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-10-27 20:01:36 +0000
commitec58e29b276b0f98eb624430fb70703dc32057bf (patch)
treed861bcbf17cdde6337d941fb8cb33531cdc2c08c
parent021b6412f7b7ce73b383480b25a8e5d69323f78c (diff)
parented29e858d09906bc28e79d919af1d09f0538a464 (diff)
downloadandroid_bionic-ec58e29b276b0f98eb624430fb70703dc32057bf.tar.gz
android_bionic-ec58e29b276b0f98eb624430fb70703dc32057bf.tar.bz2
android_bionic-ec58e29b276b0f98eb624430fb70703dc32057bf.zip
Merge "pthread_setname_np appears in glibc 2.12."
-rw-r--r--tests/pthread_test.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index c26ad17a8..61641e47f 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -355,53 +355,50 @@ TEST(pthread, pthread_sigmask) {
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(__BIONIC__) // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
+#if defined(HAVE_PTHREAD_SETNAME_NP)
ASSERT_EQ(ERANGE, pthread_setname_np(pthread_self(), "this name is far too long for linux"));
-#else // __BIONIC__
+#else
GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif // __BIONIC__
+#endif
}
TEST(pthread, pthread_setname_np__self) {
-#if defined(__BIONIC__) // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
+#if defined(HAVE_PTHREAD_SETNAME_NP)
ASSERT_EQ(0, pthread_setname_np(pthread_self(), "short 1"));
-#else // __BIONIC__
+#else
GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif // __BIONIC__
+#endif
}
TEST(pthread, pthread_setname_np__other) {
-#if defined(__BIONIC__) // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
- // Emulator kernels don't currently support setting the name of other threads.
- char* filename = NULL;
- asprintf(&filename, "/proc/self/task/%d/comm", gettid());
- struct stat sb;
- bool has_comm = (stat(filename, &sb) != -1);
- free(filename);
-
- if (has_comm) {
- 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 {
- fprintf(stderr, "skipping test: this kernel doesn't have /proc/self/task/tid/comm files!\n");
- }
-#else // __BIONIC__
+#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 // __BIONIC__
+#endif
}
TEST(pthread, pthread_setname_np__no_such_thread) {
-#if defined(__BIONIC__) // Not all build servers have a new enough glibc? TODO: remove when they're on gprecise.
+#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 // __BIONIC__
+#else
GTEST_LOG_(INFO) << "This test does nothing.\n";
-#endif // __BIONIC__
+#endif
}
TEST(pthread, pthread_kill__0) {