diff options
author | Elliott Hughes <enh@google.com> | 2013-01-10 14:42:14 -0800 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2013-01-10 14:42:14 -0800 |
commit | c5d028fc913de84a781bd61084bf7ae2182fd48e (patch) | |
tree | 9086acc9c039dad30feca8a8d80ca7af04b061e1 /tests/signal_test.cpp | |
parent | 2bbb8fac61e482dd96386620cc6f7f193e9c6840 (diff) | |
download | android_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/signal_test.cpp')
-rw-r--r-- | tests/signal_test.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp index 129256890..b100372c9 100644 --- a/tests/signal_test.cpp +++ b/tests/signal_test.cpp @@ -101,3 +101,27 @@ TEST(signal, raise_invalid) { ASSERT_EQ(-1, raise(-1)); ASSERT_EQ(EINVAL, errno); } + +static void HandleSIGALRM(int signal_number) { + ASSERT_EQ(SIGALRM, signal_number); +} + +TEST(signal, sigwait) { + struct sigaction action; + sigemptyset(&action.sa_mask); + action.sa_flags = 0; + action.sa_handler = HandleSIGALRM; + sigaction(SIGALRM, &action, NULL); + + sigset_t wait_set; + sigemptyset(&wait_set); + sigaddset(&wait_set, SIGALRM); + + alarm(1); + + int received_signal; + errno = 0; + ASSERT_EQ(0, sigwait(&wait_set, &received_signal)); + ASSERT_EQ(0, errno); + ASSERT_EQ(SIGALRM, received_signal); +} |