From 06329e07437f56260c2c74ba9e272bc6d484cc81 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 13 Apr 2012 07:26:54 +0200 Subject: 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 --- tests/testutil.hpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/testutil.hpp') 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 -- cgit v1.2.3