summaryrefslogtreecommitdiffstats
path: root/lldb/gtest
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2014-09-27 01:11:17 +0000
committerTodd Fiala <todd.fiala@gmail.com>2014-09-27 01:11:17 +0000
commit9dd7334d69f3b6cec8d8fa8e3759763d0379adb4 (patch)
treea00e8a96d78c37661881b6511078c6ce7731288b /lldb/gtest
parent779c6f25731b7d07ccb1641cf3263436289f8ca2 (diff)
downloadbcm5719-llvm-9dd7334d69f3b6cec8d8fa8e3759763d0379adb4.tar.gz
bcm5719-llvm-9dd7334d69f3b6cec8d8fa8e3759763d0379adb4.zip
thread state coordinator: added test for notify after two pending thread stops.
Glad I did - caught a bug where the auto variable was not a reference to a set and instead was a copy. I need to review rules on that! llvm-svn: 218558
Diffstat (limited to 'lldb/gtest')
-rw-r--r--lldb/gtest/unittest/Plugins/Process/Linux/ThreadStateCoordinatorTest.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/lldb/gtest/unittest/Plugins/Process/Linux/ThreadStateCoordinatorTest.cpp b/lldb/gtest/unittest/Plugins/Process/Linux/ThreadStateCoordinatorTest.cpp
index 765a0ce861d..f83d99de402 100644
--- a/lldb/gtest/unittest/Plugins/Process/Linux/ThreadStateCoordinatorTest.cpp
+++ b/lldb/gtest/unittest/Plugins/Process/Linux/ThreadStateCoordinatorTest.cpp
@@ -111,6 +111,67 @@ TEST(ThreadStateCoordinatorTest, CallAfterThreadsStopFiresWhenOnePendingStop)
ASSERT_EQ (TRIGGERING_TID, reported_firing_tid);
}
+TEST(ThreadStateCoordinatorTest, CallAfterThreadsStopFiresWhenTwoPendingStops)
+{
+ ThreadStateCoordinator coordinator(NOPLogger);
+
+ const lldb::tid_t TRIGGERING_TID = 4105;
+ const lldb::tid_t PENDING_STOP_TID = 3;
+ const lldb::tid_t PENDING_STOP_TID_02 = 29016;
+
+ ThreadStateCoordinator::ThreadIDSet pending_stop_tids { PENDING_STOP_TID, PENDING_STOP_TID_02 };
+
+ bool call_after_fired = false;
+ lldb::tid_t reported_firing_tid = 0;
+
+ int request_thread_stop_calls = 0;
+ ThreadStateCoordinator::ThreadIDSet request_thread_stop_tids;
+
+ // Notify we have a trigger that needs to be fired when all threads in the wait tid set have stopped.
+ coordinator.CallAfterThreadsStop (TRIGGERING_TID,
+ pending_stop_tids,
+ [&](lldb::tid_t tid) {
+ ++request_thread_stop_calls;
+ request_thread_stop_tids.insert (tid);
+
+ },
+ [&](lldb::tid_t tid) {
+ call_after_fired = true;
+ reported_firing_tid = tid;
+ });
+
+ // Neither trigger should have gone off yet.
+ ASSERT_EQ (false, call_after_fired);
+ ASSERT_EQ (0, request_thread_stop_calls);
+
+ // Process next event.
+ ASSERT_EQ (true, coordinator.ProcessNextEvent ());
+
+ // Now the request thread stops should have been called for the pending stop tids.
+ ASSERT_EQ (2, request_thread_stop_calls);
+ ASSERT_EQ (1, request_thread_stop_tids.count (PENDING_STOP_TID));
+ ASSERT_EQ (1, request_thread_stop_tids.count (PENDING_STOP_TID_02));
+
+ // But we still shouldn't have the deferred signal call go off yet. Need to wait for the stop to be reported.
+ ASSERT_EQ (false, call_after_fired);
+
+ // Report the that the first pending stop occurred.
+ coordinator.NotifyThreadStop (PENDING_STOP_TID);
+ ASSERT_EQ (true, coordinator.ProcessNextEvent ());
+
+ // Shouldn't take effect until after both pending threads are notified.
+ ASSERT_EQ (false, call_after_fired);
+
+ // Report the that the first pending stop occurred.
+ coordinator.NotifyThreadStop (PENDING_STOP_TID_02);
+ ASSERT_EQ (false, call_after_fired);
+ ASSERT_EQ (true, coordinator.ProcessNextEvent ());
+
+ // Deferred signal notification should have fired now.
+ ASSERT_EQ (true, call_after_fired);
+ ASSERT_EQ (TRIGGERING_TID, reported_firing_tid);
+}
+
TEST(ThreadStateCoordinatorTest, CallAfterThreadsStopFiresWhenPendingAlreadyStopped)
{
ThreadStateCoordinator coordinator(NOPLogger);
OpenPOWER on IntegriCloud