1 #ifndef MESHLINK_TEST_UTILS_H
2 #define MESHLINK_TEST_UTILS_H
4 #include "../src/meshlink.h"
6 // Simple synchronisation between threads
13 extern void set_sync_flag(struct sync_flag *s, bool value);
14 extern bool check_sync_flag(struct sync_flag *s);
15 extern bool wait_sync_flag(struct sync_flag *s, int seconds);
17 /// Create a pair of meshlink instances that are already joined together.
18 extern void open_meshlink_pair(meshlink_handle_t **a, meshlink_handle_t **b, const char *prefix);
20 /// Start a pair of meshlink instances and wait for them to connect together.
21 extern void start_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b);
23 /// Stop a pair of meshlink instances.
24 extern void stop_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b);
26 /// Stop and cleanup a pair of meshlink instances.
27 extern void close_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b);
29 /// Link two meshlink instances.
30 extern void link_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b);
32 /// Default log callback
33 extern void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text);
35 #define assert_after(cond, timeout)\
37 for(int i = 0; i++ <= timeout;) {\