X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Futils.h;h=27bb38c3fe9e20a8abae834c1d802d941daee2a2;hb=dc0e52cb3e42620c3139e713b373d130aa30b698;hp=e1073df8f7e8468c1ee0936dc7d0c0c6323c912f;hpb=6bf3ea32f0afa91f1fed494542e873ca6abca9c9;p=meshlink diff --git a/test/utils.h b/test/utils.h index e1073df8..27bb38c3 100644 --- a/test/utils.h +++ b/test/utils.h @@ -10,7 +10,7 @@ struct sync_flag { bool flag; }; -extern void set_sync_flag(struct sync_flag *s); +extern void set_sync_flag(struct sync_flag *s, bool value); extern bool wait_sync_flag(struct sync_flag *s, int seconds); /// Create a pair of meshlink instances that are already joined together. @@ -25,5 +25,14 @@ extern void stop_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b); /// Stop and cleanup a pair of meshlink instances. extern void close_meshlink_pair(meshlink_handle_t *a, meshlink_handle_t *b, const char *prefix); +#define assert_after(cond, timeout)\ + do {\ + for(int i = 0; i++ <= timeout;) {\ + if(cond)\ + break;\ + if(i == timeout)\ + assert(cond);\ + sleep(1);\ + }\ + } while(0) #endif -