tests: Add basic error handling to callbacks, for reference

Many users look at both examples *and* unit tests to learn how to use a
library.  We should pride ourselves in that we have not just working but
also correct and readable tests.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2017-11-14 12:17:41 +01:00
1 parent 9df7cbfc52
commit 505a7214a8
4 files changed
+29 -6

No files matched your search

+4 -1
View File
@@ -5,10 +5,13 @@
#define TIMEOUT 2 /* 2 sec */
struct timeval start;
static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
static void cb(uev_t *w, void *UNUSED(arg), int events)
{
struct timeval now;
if (UEV_ERROR == events)
fprintf(stderr, "timer watcher failed, ignoring ...\n");
gettimeofday(&now, NULL);
fail_unless(now.tv_sec == start.tv_sec + TIMEOUT);