blob: 016e2d875377f8c07cca6f941dea72a37ab15690 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <limits.h>
#include "gtest/gtest.h"
#include "Plugins/Process/Linux/ThreadStateCoordinator.h"
using namespace lldb_private;
namespace
{
const ThreadStateCoordinator::ThreadIDSet EMPTY_THREAD_ID_SET;
void
NOPLogger (const char *format, va_list args)
{
// Do nothing.
}
}
TEST(ThreadStateCoordinatorTest, StopCoordinatorWorksNoPriorEvents)
{
ThreadStateCoordinator coordinator(NOPLogger);
coordinator.StopCoordinator ();
ASSERT_EQ(coordinator.ProcessNextEvent (), false);
}
TEST(ThreadStateCoordinatorTest, CallAfterThreadsStopFiresWhenNoPendingStops)
{
ThreadStateCoordinator coordinator(NOPLogger);
const lldb::tid_t TRIGGERING_TID = 4105;
bool call_after_fired = false;
// Notify we have a trigger that needs to be fired when all threads in the wait tid set have stopped.
coordinator.CallAfterThreadsStop (TRIGGERING_TID,
EMPTY_THREAD_ID_SET,
[](lldb::tid_t tid) {},
[&](lldb::tid_t tid) { call_after_fired = true; });
// Notification trigger shouldn't go off yet.
ASSERT_EQ (call_after_fired, false);
// Process next event. This will pick up the call after threads stop event.
ASSERT_EQ(coordinator.ProcessNextEvent (), true);
// Now the trigger should have fired.
ASSERT_EQ(call_after_fired, true);
}
|