]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blobdiff - tests/stack_unwinding_test.cpp
restore sigprocmask in setjmp/longjmp test.
[android-sdk/platform-bionic.git] / tests / stack_unwinding_test.cpp
index 017a5f2e84e828c85afc1f2e6ef24dbca0708585..3d3f22df50718a3f73c357400995b5cc529d3e33 100644 (file)
@@ -31,7 +31,8 @@
 
 #include "ScopedSignalHandler.h"
 
-#define noinline __attribute__((noinline))
+#define noinline __attribute__((__noinline__))
+#define __unused __attribute__((__unused__))
 
 static _Unwind_Reason_Code FrameCounter(_Unwind_Context* ctx __unused, void* arg) {
   int* count_ptr = reinterpret_cast<int*>(arg);
@@ -72,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;
@@ -82,21 +84,26 @@ 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) {
+  killer_count = handler_count = handler_one_deeper_count = 0;
   ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler);
 
   _Unwind_Backtrace(FrameCounter, &killer_count);
-
+  signal_handler_run = false;
   ASSERT_EQ(0, kill(getpid(), SIGUSR1));
+  while (!signal_handler_run) {}
 }
 
-extern "C" void unwind_through_frame_with_cleanup_function();
+// On LP32, the SA_SIGINFO flag gets you __restore_rt instead of __restore.
+TEST(stack_unwinding, unwind_through_signal_frame_SA_SIGINFO) {
+  killer_count = handler_count = handler_one_deeper_count = 0;
+  ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler, SA_SIGINFO);
 
-// We have to say "DeathTest" here so gtest knows to run this test (which exits)
-// in its own process.
-TEST(stack_unwinding_DeathTest, unwind_through_frame_with_cleanup_function) {
-  ::testing::FLAGS_gtest_death_test_style = "threadsafe";
-  ASSERT_EXIT(unwind_through_frame_with_cleanup_function(), ::testing::ExitedWithCode(42), "");
+  _Unwind_Backtrace(FrameCounter, &killer_count);
+  signal_handler_run = false;
+  ASSERT_EQ(0, kill(getpid(), SIGUSR1));
+  while (!signal_handler_run) {}
 }