aboutsummaryrefslogtreecommitdiffstats
path: root/tests/pthread_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2013-01-10 14:42:14 -0800
committerElliott Hughes <enh@google.com>2013-01-10 14:42:14 -0800
commitc5d028fc913de84a781bd61084bf7ae2182fd48e (patch)
tree9086acc9c039dad30feca8a8d80ca7af04b061e1 /tests/pthread_test.cpp
parent2bbb8fac61e482dd96386620cc6f7f193e9c6840 (diff)
downloadandroid_bionic-c5d028fc913de84a781bd61084bf7ae2182fd48e.tar.gz
android_bionic-c5d028fc913de84a781bd61084bf7ae2182fd48e.tar.bz2
android_bionic-c5d028fc913de84a781bd61084bf7ae2182fd48e.zip
Only have one copy of the kernel_sigset_t hack, and add more tests.
Change-Id: I377522fcba6fb4b5fd2754ab15b091014bd7c16f
Diffstat (limited to 'tests/pthread_test.cpp')
-rw-r--r--tests/pthread_test.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index da945b4df..3e144dbaa 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -126,3 +126,31 @@ TEST(pthread_DeathTest, pthread_bug_37410) {
EXPECT_EXIT(TestBug37410(), ::testing::ExitedWithCode(0), "");
}
#endif
+
+static void* SignalHandlerFn(void* arg) {
+ sigset_t wait_set;
+ sigfillset(&wait_set);
+ return reinterpret_cast<void*>(sigwait(&wait_set, reinterpret_cast<int*>(arg)));
+}
+
+TEST(pthread, pthread_sigmask) {
+ // Block SIGUSR1.
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGUSR1);
+ ASSERT_EQ(0, pthread_sigmask(SIG_BLOCK, &set, NULL));
+
+ // Spawn a thread that calls sigwait and tells us what it received.
+ pthread_t signal_thread;
+ int received_signal = -1;
+ ASSERT_EQ(0, pthread_create(&signal_thread, NULL, SignalHandlerFn, &received_signal));
+
+ // Send that thread SIGUSR1.
+ pthread_kill(signal_thread, SIGUSR1);
+
+ // See what it got.
+ void* join_result;
+ ASSERT_EQ(0, pthread_join(signal_thread, &join_result));
+ ASSERT_EQ(SIGUSR1, received_signal);
+ ASSERT_EQ(0, reinterpret_cast<int>(join_result));
+}