diff options
author | Elliott Hughes <enh@google.com> | 2014-09-12 22:52:38 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-09-12 22:52:38 +0000 |
commit | a40a16eab13b770c3ce80f4e4241dfcd9518022f (patch) | |
tree | 40b074daa7dd81badacb728e905a3b70530f1253 | |
parent | 69c2d7dc6434c7e7e9bd22797deb7f727199ab0c (diff) | |
parent | 8fb639ca9118a6522723d0bc09db59b432a803a9 (diff) | |
download | bionic-a40a16eab13b770c3ce80f4e4241dfcd9518022f.zip bionic-a40a16eab13b770c3ce80f4e4241dfcd9518022f.tar.gz bionic-a40a16eab13b770c3ce80f4e4241dfcd9518022f.tar.bz2 |
Merge "Add a test for pthread_gettid_np."
-rw-r--r-- | tests/pthread_test.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index 3a5c3dc..43587f4 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -909,3 +909,29 @@ TEST(pthread, pthread_attr_getstack__main_thread) { EXPECT_EQ(stack_size, stack_size2); ASSERT_EQ(6666U, stack_size); } + +#if defined(__BIONIC__) +static void* pthread_gettid_np_helper(void* arg) { + *reinterpret_cast<pid_t*>(arg) = gettid(); + return NULL; +} +#endif + +TEST(pthread, pthread_gettid_np) { +#if defined(__BIONIC__) + ASSERT_EQ(gettid(), pthread_gettid_np(pthread_self())); + + pid_t t_gettid_result; + pthread_t t; + pthread_create(&t, NULL, pthread_gettid_np_helper, &t_gettid_result); + + pid_t t_pthread_gettid_np_result = pthread_gettid_np(t); + + void* join_result; + pthread_join(t, &join_result); + + ASSERT_EQ(t_gettid_result, t_pthread_gettid_np_result); +#else + GTEST_LOG_(INFO) << "This test does nothing.\n"; +#endif +} |