nmtst: refactor NMTST_BUSY_WAIT() and rename to NMTST_WAIT*()
This commit is contained in:
@@ -128,16 +128,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
|
||||
|
Reference in New Issue
Block a user