nmtst: refactor NMTST_BUSY_WAIT() and rename to NMTST_WAIT*()

(cherry picked from commit 998772805c)
This commit is contained in:
Thomas Haller 2015-11-26 23:26:00 +01:00
parent a950a54516
commit 55403cd032

View file

@ -129,16 +129,26 @@ nmtst_assert_error (GError *error,
}
}
#define NMTST_BUSY_WAIT(max_wait_ms, condition, wait) \
G_STMT_START { \
#define NMTST_WAIT(max_wait_ms, wait) \
({ \
gboolean _not_expired = TRUE; \
gint64 _nmtst_end, _nmtst_max_wait_us = (max_wait_ms) * 1000L; \
\
_nmtst_end = g_get_monotonic_time () + _nmtst_max_wait_us; \
while (!(condition)) { \
while (TRUE) { \
{ wait }; \
if (g_get_monotonic_time () > _nmtst_end) \
g_assert_not_reached (); \
if (g_get_monotonic_time () > _nmtst_end) { \
_not_expired = FALSE; \
break; \
} \
} \
_not_expired; \
})
#define NMTST_WAIT_ASSERT(max_wait_ms, wait) \
G_STMT_START { \
if (!(NMTST_WAIT (max_wait_ms, wait))) \
g_assert_not_reached (); \
} G_STMT_END
inline static void