moveit2
The MoveIt Motion Planning Framework for ROS 2.
|
Test class that allows the handling of asynchronous test objects. More...
#include <async_test.hpp>
Public Member Functions | |
void | triggerClearEvent (const std::string &event) |
Triggers a clear event. If a call to barricade is currently pending it will unblock as soon as all clear events are triggered. Else the event is put on the waitlist. This waitlist is emptied upon a call to barricade. More... | |
bool | barricade (const std::string &clear_event, const int timeout_ms=-1) |
Will block until the event given by clear_event is triggered or a timeout is reached. Unblocks immediately, if the event was on the waitlist. More... | |
bool | barricade (std::initializer_list< std::string > clear_events, const int timeout_ms=-1) |
Will block until all events given by clear_events are triggered or a timeout is reached. Events on the waitlist are taken into account, too. More... | |
Protected Attributes | |
std::mutex | m_ |
std::condition_variable | cv_ |
std::set< std::string > | clear_events_ {} |
std::set< std::string > | waitlist_ {} |
Test class that allows the handling of asynchronous test objects.
The class provides the two basic functions AsyncTest::barricade and AsyncTest::triggerClearEvent. During the test setup gates between the steps with one or more clear events. Allow passing on by calling triggerClearEvent after a test.
Usage:
Suppose you want to test a function that calls another function asynchronously, like the following example:
You expect that fun gets called, so your test thread has to wait for the completion, else it would fail. This can be achieved via:
Definition at line 69 of file async_test.hpp.
|
inline |
Will block until the event given by clear_event is triggered or a timeout is reached. Unblocks immediately, if the event was on the waitlist.
clear_event | Event that allows the test to pass on |
timeout_ms | Timeout [ms] (optional). |
Definition at line 134 of file async_test.hpp.
|
inline |
Will block until all events given by clear_events are triggered or a timeout is reached. Events on the waitlist are taken into account, too.
clear_events | List of events that allow the test to pass on |
timeout_ms | Timeout [ms] (optional). |
Definition at line 139 of file async_test.hpp.
|
inline |
Triggers a clear event. If a call to barricade is currently pending it will unblock as soon as all clear events are triggered. Else the event is put on the waitlist. This waitlist is emptied upon a call to barricade.
event | The event that is triggered |
Definition at line 118 of file async_test.hpp.
|
protected |
Definition at line 103 of file async_test.hpp.
|
protected |
Definition at line 102 of file async_test.hpp.
|
protected |
Definition at line 101 of file async_test.hpp.
|
protected |
Definition at line 104 of file async_test.hpp.