Merge "Split up the stack space tests into their own noinline functions."

This commit is contained in:
Josh Gao 2017-03-16 06:44:58 +00:00 committed by Gerrit Code Review
commit b2882dd429

View file

@ -1886,25 +1886,34 @@ extern _Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx, void* arg);
static volatile bool signal_handler_on_altstack_done;
static void SignalHandlerOnAltStack(int signo, siginfo_t*, void*) {
ASSERT_EQ(SIGUSR1, signo);
{
__attribute__((__noinline__))
static void signal_handler_backtrace() {
// Check if we have enough stack space for unwinding.
int count = 0;
_Unwind_Backtrace(FrameCounter, &count);
ASSERT_GT(count, 0);
}
{
}
__attribute__((__noinline__))
static void signal_handler_logging() {
// Check if we have enough stack space for logging.
std::string s(2048, '*');
GTEST_LOG_(INFO) << s;
signal_handler_on_altstack_done = true;
}
{
}
__attribute__((__noinline__))
static void signal_handler_snprintf() {
// Check if we have enough stack space for snprintf to a PATH_MAX buffer, plus some extra.
char buf[PATH_MAX + 2048];
ASSERT_GT(snprintf(buf, sizeof(buf), "/proc/%d/status", getpid()), 0);
}
}
static void SignalHandlerOnAltStack(int signo, siginfo_t*, void*) {
ASSERT_EQ(SIGUSR1, signo);
signal_handler_backtrace();
signal_handler_logging();
signal_handler_snprintf();
}
TEST(pthread, big_enough_signal_stack) {