summaryrefslogtreecommitdiff
path: root/tests/stack_unwinding_test.cpp
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-06-14 10:00:57 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-06-14 10:00:57 +0000
commita3f1238f32ff3d564ef148eed68353bd09ed5800 (patch)
treedb4e9e91a34b6db2be83b4bfb8495e805aa8ac9f /tests/stack_unwinding_test.cpp
parent4f100d71fe8a69611098b0f66142275544c1dfd1 (diff)
parent4c90af54ee40fd5850f3a201fba9f706f9c2619f (diff)
Snap for 7454474 from 4c90af54ee40fd5850f3a201fba9f706f9c2619f to s-keystone-qcom-release
Change-Id: Ia8b046c32157cb0f325da998d754e67cdae09764
Diffstat (limited to 'tests/stack_unwinding_test.cpp')
-rw-r--r--tests/stack_unwinding_test.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/tests/stack_unwinding_test.cpp b/tests/stack_unwinding_test.cpp
index 0ff6f30a6..2f891a6e1 100644
--- a/tests/stack_unwinding_test.cpp
+++ b/tests/stack_unwinding_test.cpp
@@ -66,13 +66,28 @@ static int noinline unwind_one_frame_deeper() {
return count;
}
-TEST(stack_unwinding, easy) {
+static void UnwindTest() {
int count = 0;
_Unwind_Backtrace(FrameCounter, &count);
int deeper_count = unwind_one_frame_deeper();
ASSERT_EQ(count + 1, deeper_count);
}
+TEST(stack_unwinding, easy) {
+ UnwindTest();
+}
+
+TEST(stack_unwinding, thread) {
+ pthread_t thread;
+ ASSERT_EQ(0, pthread_create(&thread, nullptr, [](void*) -> void* {
+ UnwindTest();
+ return nullptr;
+ }, nullptr));
+ void *retval;
+ ASSERT_EQ(0, pthread_join(thread, &retval));
+ EXPECT_EQ(nullptr, retval);
+}
+
struct UnwindData {
volatile bool signal_handler_complete = false;
int expected_frame_count = 0;
@@ -98,7 +113,7 @@ static void verify_unwind_data(const UnwindData& unwind_data) {
EXPECT_EQ(unwind_data.handler_frame_count + 1, unwind_data.handler_one_deeper_frame_count);
}
-static void noinline UnwindTest() {
+static void noinline SignalUnwindTest() {
g_unwind_data = {};
_Unwind_Backtrace(FrameCounter, &g_unwind_data.expected_frame_count);
@@ -114,12 +129,12 @@ static void noinline UnwindTest() {
TEST(stack_unwinding, unwind_through_signal_frame) {
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler);
- UnwindTest();
+ SignalUnwindTest();
}
// On LP32, the SA_SIGINFO flag gets you __restore_rt instead of __restore.
TEST(stack_unwinding, unwind_through_signal_frame_SA_SIGINFO) {
ScopedSignalHandler ssh(SIGUSR1, UnwindSignalHandler, SA_SIGINFO);
- UnwindTest();
+ SignalUnwindTest();
}