summaryrefslogtreecommitdiff
path: root/tests/testutil.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-13 07:26:54 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-14 05:00:25 +0200
commit06329e07437f56260c2c74ba9e272bc6d484cc81 (patch)
treeb5a88aef4f00370d0bfc41b817f3429c4139a8ef /tests/testutil.hpp
parentf34f71bbd5b9b00b295aa6438dd251845547225c (diff)
Checking for correct timeout in the test suite improved
This patch introduces 1/2 second tolerance for the timeouts in the tests. This will hopefully make tests not fail even on slow or heavily loaded machines. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'tests/testutil.hpp')
-rw-r--r--tests/testutil.hpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/testutil.hpp b/tests/testutil.hpp
index 4e0287a..58f1afd 100644
--- a/tests/testutil.hpp
+++ b/tests/testutil.hpp
@@ -173,4 +173,10 @@ inline void bounce (void *sb, void *sc)
assert (memcmp (buf2, content, 32) == 0);
}
+// Check whether measured time is the expected time (in milliseconds).
+// The upper tolerance is 1/2 sec so that the test doesn't fail even on
+// very slow or very loaded systems.
+#define time_assert(actual,expected) \
+ assert (actual > ((expected) - 50) && actual < ((expected) + 500));
+
#endif