am 46d0b81a: Merge "restore sigprocmask in setjmp/longjmp test."
* commit '46d0b81a9465bf74fe44a881365c332dc6173f2f': restore sigprocmask in setjmp/longjmp test.
This commit is contained in:
commit
b2ec9cb264
@ -74,7 +74,8 @@ TEST(setjmp, _setjmp_signal_mask) {
|
||||
// _setjmp/_longjmp do not save/restore the signal mask.
|
||||
sigset_t ss1(SigSetOf(SIGUSR1));
|
||||
sigset_t ss2(SigSetOf(SIGUSR2));
|
||||
sigprocmask(SIG_SETMASK, &ss1, NULL);
|
||||
sigset_t original_set;
|
||||
sigprocmask(SIG_SETMASK, &ss1, &original_set);
|
||||
jmp_buf jb;
|
||||
if (_setjmp(jb) == 0) {
|
||||
sigprocmask(SIG_SETMASK, &ss2, NULL);
|
||||
@ -85,6 +86,7 @@ TEST(setjmp, _setjmp_signal_mask) {
|
||||
sigprocmask(SIG_SETMASK, NULL, &ss);
|
||||
EXPECT_TRUE(sigismember(&ss, SIGUSR2));
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &original_set, NULL);
|
||||
}
|
||||
|
||||
TEST(setjmp, setjmp_signal_mask) {
|
||||
@ -93,7 +95,8 @@ TEST(setjmp, setjmp_signal_mask) {
|
||||
// behavior unspecified, so any code that cares needs to use sigsetjmp.
|
||||
sigset_t ss1(SigSetOf(SIGUSR1));
|
||||
sigset_t ss2(SigSetOf(SIGUSR2));
|
||||
sigprocmask(SIG_SETMASK, &ss1, NULL);
|
||||
sigset_t original_set;
|
||||
sigprocmask(SIG_SETMASK, &ss1, &original_set);
|
||||
jmp_buf jb;
|
||||
if (setjmp(jb) == 0) {
|
||||
sigprocmask(SIG_SETMASK, &ss2, NULL);
|
||||
@ -110,13 +113,15 @@ TEST(setjmp, setjmp_signal_mask) {
|
||||
EXPECT_TRUE(sigismember(&ss, SIGUSR2));
|
||||
#endif
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &original_set, NULL);
|
||||
}
|
||||
|
||||
TEST(setjmp, sigsetjmp_0_signal_mask) {
|
||||
// sigsetjmp(0)/siglongjmp do not save/restore the signal mask.
|
||||
sigset_t ss1(SigSetOf(SIGUSR1));
|
||||
sigset_t ss2(SigSetOf(SIGUSR2));
|
||||
sigprocmask(SIG_SETMASK, &ss1, NULL);
|
||||
sigset_t original_set;
|
||||
sigprocmask(SIG_SETMASK, &ss1, &original_set);
|
||||
sigjmp_buf sjb;
|
||||
if (sigsetjmp(sjb, 0) == 0) {
|
||||
sigprocmask(SIG_SETMASK, &ss2, NULL);
|
||||
@ -127,13 +132,15 @@ TEST(setjmp, sigsetjmp_0_signal_mask) {
|
||||
sigprocmask(SIG_SETMASK, NULL, &ss);
|
||||
EXPECT_TRUE(sigismember(&ss, SIGUSR2));
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &original_set, NULL);
|
||||
}
|
||||
|
||||
TEST(setjmp, sigsetjmp_1_signal_mask) {
|
||||
// sigsetjmp(1)/siglongjmp does save/restore the signal mask.
|
||||
sigset_t ss1(SigSetOf(SIGUSR1));
|
||||
sigset_t ss2(SigSetOf(SIGUSR2));
|
||||
sigprocmask(SIG_SETMASK, &ss1, NULL);
|
||||
sigset_t original_set;
|
||||
sigprocmask(SIG_SETMASK, &ss1, &original_set);
|
||||
sigjmp_buf sjb;
|
||||
if (sigsetjmp(sjb, 1) == 0) {
|
||||
sigprocmask(SIG_SETMASK, &ss2, NULL);
|
||||
@ -144,4 +151,5 @@ TEST(setjmp, sigsetjmp_1_signal_mask) {
|
||||
sigprocmask(SIG_SETMASK, NULL, &ss);
|
||||
EXPECT_TRUE(sigismember(&ss, SIGUSR1));
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, &original_set, NULL);
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ TEST(stack_unwinding, easy) {
|
||||
ASSERT_EQ(count + 1, deeper_count);
|
||||
}
|
||||
|
||||
static volatile bool signal_handler_run = false;
|
||||
static int killer_count = 0;
|
||||
static int handler_count = 0;
|
||||
static int handler_one_deeper_count = 0;
|
||||
@ -83,6 +84,7 @@ static void noinline UnwindSignalHandler(int) {
|
||||
|
||||
handler_one_deeper_count = unwind_one_frame_deeper();
|
||||
ASSERT_EQ(handler_count + 1, handler_one_deeper_count);
|
||||
signal_handler_run = true;
|
||||
}
|
||||
|
||||
TEST(stack_unwinding, unwind_through_signal_frame) {
|
||||
@ -90,8 +92,9 @@ TEST(stack_unwinding, unwind_through_signal_frame) {
|
||||
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler);
|
||||
|
||||
_Unwind_Backtrace(FrameCounter, &killer_count);
|
||||
|
||||
signal_handler_run = false;
|
||||
ASSERT_EQ(0, kill(getpid(), SIGUSR1));
|
||||
while (!signal_handler_run) {}
|
||||
}
|
||||
|
||||
// On LP32, the SA_SIGINFO flag gets you __restore_rt instead of __restore.
|
||||
@ -100,6 +103,7 @@ TEST(stack_unwinding, unwind_through_signal_frame_SA_SIGINFO) {
|
||||
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler, SA_SIGINFO);
|
||||
|
||||
_Unwind_Backtrace(FrameCounter, &killer_count);
|
||||
|
||||
signal_handler_run = false;
|
||||
ASSERT_EQ(0, kill(getpid(), SIGUSR1));
|
||||
while (!signal_handler_run) {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user