am ec58e29b: Merge "pthread_setname_np appears in glibc 2.12."
* commit 'ec58e29b276b0f98eb624430fb70703dc32057bf': pthread_setname_np appears in glibc 2.12.
This commit is contained in:
commit
382938d092
@ -355,53 +355,50 @@ TEST(pthread, pthread_sigmask) {
|
|||||||
ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, NULL));
|
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) {
|
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"));
|
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";
|
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||||
#endif // __BIONIC__
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(pthread, pthread_setname_np__self) {
|
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"));
|
ASSERT_EQ(0, pthread_setname_np(pthread_self(), "short 1"));
|
||||||
#else // __BIONIC__
|
#else
|
||||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||||
#endif // __BIONIC__
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(pthread, pthread_setname_np__other) {
|
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.
|
#if defined(HAVE_PTHREAD_SETNAME_NP)
|
||||||
// Emulator kernels don't currently support setting the name of other threads.
|
pthread_t t1;
|
||||||
char* filename = NULL;
|
ASSERT_EQ(0, pthread_create(&t1, NULL, SleepFn, reinterpret_cast<void*>(5)));
|
||||||
asprintf(&filename, "/proc/self/task/%d/comm", gettid());
|
ASSERT_EQ(0, pthread_setname_np(t1, "short 2"));
|
||||||
struct stat sb;
|
#else
|
||||||
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__
|
|
||||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||||
#endif // __BIONIC__
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(pthread, pthread_setname_np__no_such_thread) {
|
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;
|
pthread_t dead_thread;
|
||||||
MakeDeadThread(dead_thread);
|
MakeDeadThread(dead_thread);
|
||||||
|
|
||||||
// Call pthread_setname_np after thread has already exited.
|
// Call pthread_setname_np after thread has already exited.
|
||||||
ASSERT_EQ(ESRCH, pthread_setname_np(dead_thread, "short 3"));
|
ASSERT_EQ(ESRCH, pthread_setname_np(dead_thread, "short 3"));
|
||||||
#else // __BIONIC__
|
#else
|
||||||
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
GTEST_LOG_(INFO) << "This test does nothing.\n";
|
||||||
#endif // __BIONIC__
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(pthread, pthread_kill__0) {
|
TEST(pthread, pthread_kill__0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user