From 28ea229bb29f3ee82991ca8b5ac5f7a9b7b89fdc Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 4 Sep 2014 13:54:42 -0700 Subject: Don't mask out SA_RESTORER from sa_flags. glibc doesn't do this, and we probably shouldn't either. Bug: 16703540 Bug: 17436734 (cherry picked from commit afe58ad9892de27a7acb0aaded6312ee0f958314) Change-Id: Iada5d0ae814f438cb276f056b2b5e3675f0e3666 --- tests/signal_test.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp index 89b8088..e53fd3a 100644 --- a/tests/signal_test.cpp +++ b/tests/signal_test.cpp @@ -14,10 +14,10 @@ * limitations under the License. */ -#include +#include #include -#include +#include #include "ScopedSignalHandler.h" @@ -198,13 +198,19 @@ static void EmptySignalHandler(int) {} static void EmptySignalAction(int, siginfo_t*, void*) {} TEST(signal, sigaction) { + // Both bionic and glibc set SA_RESTORER when talking to the kernel on arm, + // arm64, x86, and x86-64. The version of glibc we're using also doesn't + // define SA_RESTORER, but luckily it's the same value everywhere, and mips + // doesn't use the bit for anything. + static const int sa_restorer = 0x4000000; + // See what's currently set for SIGALRM. struct sigaction original_sa; memset(&original_sa, 0, sizeof(original_sa)); ASSERT_EQ(0, sigaction(SIGALRM, NULL, &original_sa)); ASSERT_TRUE(original_sa.sa_handler == NULL); ASSERT_TRUE(original_sa.sa_sigaction == NULL); - ASSERT_TRUE(original_sa.sa_flags == 0); + ASSERT_EQ(0, original_sa.sa_flags & ~sa_restorer); // Set a traditional sa_handler signal handler. struct sigaction sa; @@ -219,7 +225,7 @@ TEST(signal, sigaction) { ASSERT_EQ(0, sigaction(SIGALRM, NULL, &sa)); ASSERT_TRUE(sa.sa_handler == EmptySignalHandler); ASSERT_TRUE((void*) sa.sa_sigaction == (void*) sa.sa_handler); - ASSERT_TRUE(sa.sa_flags == SA_ONSTACK); + ASSERT_EQ(SA_ONSTACK, sa.sa_flags & ~sa_restorer); // Set a new-style sa_sigaction signal handler. memset(&sa, 0, sizeof(sa)); @@ -233,7 +239,7 @@ TEST(signal, sigaction) { ASSERT_EQ(0, sigaction(SIGALRM, NULL, &sa)); ASSERT_TRUE(sa.sa_sigaction == EmptySignalAction); ASSERT_TRUE((void*) sa.sa_sigaction == (void*) sa.sa_handler); - ASSERT_TRUE(sa.sa_flags == (SA_ONSTACK | SA_SIGINFO)); + ASSERT_EQ((SA_ONSTACK | SA_SIGINFO), sa.sa_flags & ~sa_restorer); // Put everything back how it was. ASSERT_EQ(0, sigaction(SIGALRM, &original_sa, NULL)); -- cgit v1.1