summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-11-26 23:26:00 +0100
committerThomas Haller <thaller@redhat.com>2015-11-27 15:53:12 +0100
commit55403cd0322b84db8d30a2c63f2ee19387019fe3 (patch)
treeca1853e903bf005256eaad60b2ccaa46f673541d
parenta950a54516248af60ce986fd29b917d160df80c0 (diff)
downloadNetworkManager-55403cd0322b84db8d30a2c63f2ee19387019fe3.tar.gz
nmtst: refactor NMTST_BUSY_WAIT() and rename to NMTST_WAIT*()
(cherry picked from commit 998772805cf393c5855320c7121ba2df8935e8b1)
-rw-r--r--include/nm-test-utils.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h
index d829e6d52e..d23672b840 100644
--- a/include/nm-test-utils.h
+++ b/include/nm-test-utils.h
@@ -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