diff options
author | Elliott Hughes <enh@google.com> | 2013-10-15 11:23:57 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-10-15 11:23:57 -0700 |
commit | 19e62325c268a668692e2b65fde2284079f369aa (patch) | |
tree | 364b827a4b7504b5f00c18a2f1bafc5b7d1d83b8 /tests/pthread_test.cpp | |
parent | abeafbd6d5e11044dd305e48134bc3d84319a3da (diff) | |
download | android_bionic-19e62325c268a668692e2b65fde2284079f369aa.tar.gz android_bionic-19e62325c268a668692e2b65fde2284079f369aa.tar.bz2 android_bionic-19e62325c268a668692e2b65fde2284079f369aa.zip |
Clean up the sigprocmask/pthread_sigmask implementation.
Let's have both use rt_sigprocmask, like in glibc. The 64-bit ABIs
can share the same code as the 32-bit ABIs.
Also, let's test the return side of these calls, not just the
setting.
Bug: 11069919
Change-Id: I11da99f85b5b481870943c520d05ec929b15eddb
Diffstat (limited to 'tests/pthread_test.cpp')
-rw-r--r-- | tests/pthread_test.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index d82921b30..4a7c155c0 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -173,12 +173,28 @@ static void* SignalHandlerFn(void* arg) { } TEST(pthread, pthread_sigmask) { + // Check that SIGUSR1 isn't blocked. + sigset_t original_set; + sigemptyset(&original_set); + ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, NULL, &original_set)); + ASSERT_FALSE(sigismember(&original_set, SIGUSR1)); + // Block SIGUSR1. sigset_t set; sigemptyset(&set); sigaddset(&set, SIGUSR1); ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, &set, NULL)); + // Check that SIGUSR1 is blocked. + sigset_t final_set; + sigemptyset(&final_set); + ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, NULL, &final_set)); + ASSERT_TRUE(sigismember(&final_set, SIGUSR1)); + // ...and that sigprocmask agrees with pthread_sigmask. + sigemptyset(&final_set); + ASSERT_EQ(0, sigprocmask(SIG_BLOCK, NULL, &final_set)); + ASSERT_TRUE(sigismember(&final_set, SIGUSR1)); + // Spawn a thread that calls sigwait and tells us what it received. pthread_t signal_thread; int received_signal = -1; @@ -192,6 +208,9 @@ TEST(pthread, pthread_sigmask) { ASSERT_EQ(0, pthread_join(signal_thread, &join_result)); ASSERT_EQ(SIGUSR1, received_signal); ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(join_result)); + + // Restore the original signal mask. + ASSERT_EQ(0, pthread_sigmask(SIG_SETMASK, &original_set, NULL)); } #if __BIONIC__ |