tests/: Return result of tests, not return value of uev_run()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2018-01-28 16:32:38 +01:00
parent cebe66e8a4
commit 0e97bfdc5a
3 changed files with 31 additions and 3 deletions
+7
View File
@@ -52,3 +52,10 @@ int main(void)
return uev_run(&ctx, 0);
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/
+9 -2
View File
@@ -28,6 +28,7 @@
#define TIMEOUT 2
#define INTERVAL 2
int result = -1;
struct timeval tv;
static void cron_job(uev_t *w, void *UNUSED(arg), int events)
@@ -45,12 +46,15 @@ static void cron_job(uev_t *w, void *UNUSED(arg), int events)
printf("Cron job HELO %s", ctime(&now.tv_sec));
fail_unless(now.tv_sec == tv.tv_sec);
if (!laps--)
if (!laps--) {
result = 0;
uev_exit(w->ctx);
}
}
int main(void)
{
int rc;
uev_t cron_watcher;
uev_ctx_t ctx;
time_t when, interval;
@@ -66,7 +70,10 @@ int main(void)
interval = INTERVAL;
uev_cron_init(&ctx, &cron_watcher, cron_job, NULL, when, interval);
return uev_run(&ctx, 0);
rc = uev_run(&ctx, 0);
fail_unless(result == 0);
return rc;
}
/**
+15 -1
View File
@@ -3,6 +3,8 @@
#include <sys/time.h>
#define TIMEOUT 2 /* 2 sec */
int result = -1;
struct timeval start;
static void cb(uev_t *w, void *UNUSED(arg), int events)
@@ -15,11 +17,13 @@ static void cb(uev_t *w, void *UNUSED(arg), int events)
gettimeofday(&now, NULL);
fail_unless(now.tv_sec == start.tv_sec + TIMEOUT);
result = 0;
uev_exit(w->ctx);
}
int main(void)
{
int rc;
uev_t w;
uev_ctx_t ctx;
@@ -27,5 +31,15 @@ int main(void)
uev_timer_init(&ctx, &w, cb, NULL, TIMEOUT * 1000, 0);
gettimeofday(&start, NULL);
return uev_run(&ctx, 0);
rc = uev_run(&ctx, 0);
fail_unless(result == 0);
return rc;
}
/**
* Local Variables:
* indent-tabs-mode: t
* c-file-style: "linux"
* End:
*/