summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-06-22 12:40:06 +0200
committerThomas Haller <thaller@redhat.com>2015-11-27 15:52:12 +0100
commita950a54516248af60ce986fd29b917d160df80c0 (patch)
tree8b667081db83d0487d71339b42ef94c003c8242b
parent61fd1ecf5c8f28dc540906a993a5260408429fa8 (diff)
downloadNetworkManager-a950a54516248af60ce986fd29b917d160df80c0.tar.gz
test: add NMTST_BUSY_WAIT() util
(cherry picked from commit 4eb48d8c872fa2b484b1fcc998a1a639a3f2a560)
-rw-r--r--include/nm-test-utils.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h
index e76496d023..d829e6d52e 100644
--- a/include/nm-test-utils.h
+++ b/include/nm-test-utils.h
@@ -129,6 +129,18 @@ nmtst_assert_error (GError *error,
}
}
+#define NMTST_BUSY_WAIT(max_wait_ms, condition, wait) \
+ G_STMT_START { \
+ gint64 _nmtst_end, _nmtst_max_wait_us = (max_wait_ms) * 1000L; \
+ \
+ _nmtst_end = g_get_monotonic_time () + _nmtst_max_wait_us; \
+ while (!(condition)) { \
+ { wait }; \
+ if (g_get_monotonic_time () > _nmtst_end) \
+ g_assert_not_reached (); \
+ } \
+ } G_STMT_END
+
inline static void
_nmtst_assert_success (gboolean success, GError *error, const char *file, int line)
{