X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=test%2Futils.h;h=3576df594a70db81f7b3bfda871ba518f50051b8;hb=cb2c4617316df5b467c6a76bf118ee65f6e1c3a2;hp=bce2f9a5cc1e1a37fbca7b8d85292ad73e6f6c76;hpb=6558e508cc80ec97ec9c5bbcf7df922e13ed5b2e;p=meshlink diff --git a/test/utils.h b/test/utils.h index bce2f9a5..3576df59 100644 --- a/test/utils.h +++ b/test/utils.h @@ -1,6 +1,9 @@ #ifndef MESHLINK_TEST_UTILS_H #define MESHLINK_TEST_UTILS_H +#include +#include + #include "../src/meshlink.h" // Simple synchronisation between threads @@ -44,3 +47,12 @@ extern void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const ch } while(0) #endif + +/// Compare two timespec values. +static bool timespec_lt(const struct timespec *a, const struct timespec *b) { + if(a->tv_sec == b->tv_sec) { + return a->tv_nsec < b->tv_nsec; + } else { + return a->tv_sec < b->tv_sec; + } +}