diff options
author | Thomas Haller <thaller@redhat.com> | 2018-06-20 14:41:03 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2018-11-30 11:56:21 +0100 |
commit | e8b1a2613e538fbfcd30ceb46a6744893214a474 (patch) | |
tree | 40eb02c065c792e9f35b9cff2e63f75498135e8e | |
parent | e522b90d3f7ac174dfab9e9cbba8b6ebfe21f61a (diff) | |
download | NetworkManager-e8b1a2613e538fbfcd30ceb46a6744893214a474.tar.gz |
tests: expose current state in local context of NMTST_WAIT()
Inside the loop-handler, it can be interesting to know the current iteration,
and how much time is left.
(cherry picked from commit 86dc1f13947d8361d7a9c8d062f5e5739c7b6485)
(cherry picked from commit 945f51d6231153b7d331f9d08e9bbbf5249786dc)
(cherry picked from commit 03b6653679d6bee6828c602907a882ba377cf885)
-rw-r--r-- | shared/nm-utils/nm-test-utils.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h index 19b904603c..64cf8362a7 100644 --- a/shared/nm-utils/nm-test-utils.h +++ b/shared/nm-utils/nm-test-utils.h @@ -140,10 +140,16 @@ const gint64 nmtst_wait_start_us = g_get_monotonic_time (); \ const gint64 nmtst_wait_duration_us = (max_wait_ms) * 1000L; \ const gint64 nmtst_wait_end_us = nmtst_wait_start_us + nmtst_wait_duration_us; \ + gint64 _nmtst_wait_remaining_us = nmtst_wait_duration_us; \ + int _nmtst_wait_iteration = 0; \ \ while (TRUE) { \ + _nm_unused const gint64 nmtst_wait_remaining_us = _nmtst_wait_remaining_us; \ + _nm_unused int nmtst_wait_iteration = _nmtst_wait_iteration++; \ + \ { wait }; \ - if (g_get_monotonic_time () > nmtst_wait_end_us) { \ + _nmtst_wait_remaining_us = (nmtst_wait_end_us - g_get_monotonic_time ()); \ + if (_nmtst_wait_remaining_us <= 0) { \ _not_expired = FALSE; \ break; \ } \ |