[msan] Fix sigaction interceptor.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@178868 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/msan/tests/msan_test.cc b/lib/msan/tests/msan_test.cc
index e6612ba..9c27bf0 100644
--- a/lib/msan/tests/msan_test.cc
+++ b/lib/msan/tests/msan_test.cc
@@ -981,6 +981,7 @@
TEST(MemorySanitizer, sigaction) {
struct sigaction act = {};
+ struct sigaction oldact = {};
act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = &SigactionHandler;
sigaction(SIGPROF, &act, 0);
@@ -993,17 +994,23 @@
act.sa_flags &= ~SA_SIGINFO;
act.sa_handler = SIG_IGN;
- sigaction(SIGPROF, &act, 0);
+ sigaction(SIGPROF, &act, &oldact);
+ EXPECT_FALSE(oldact.sa_flags & SA_SIGINFO);
+ EXPECT_EQ(SIG_DFL, oldact.sa_handler);
kill(getpid(), SIGPROF);
act.sa_flags |= SA_SIGINFO;
act.sa_sigaction = &SigactionHandler;
- sigaction(SIGPROF, &act, 0);
+ sigaction(SIGPROF, &act, &oldact);
+ EXPECT_FALSE(oldact.sa_flags & SA_SIGINFO);
+ EXPECT_EQ(SIG_IGN, oldact.sa_handler);
kill(getpid(), SIGPROF);
act.sa_flags &= ~SA_SIGINFO;
act.sa_handler = SIG_DFL;
- sigaction(SIGPROF, &act, 0);
+ sigaction(SIGPROF, &act, &oldact);
+ EXPECT_TRUE(oldact.sa_flags & SA_SIGINFO);
+ EXPECT_EQ(&SigactionHandler, oldact.sa_sigaction);
EXPECT_EQ(2, cnt);
}