New API test to verify uev_exit() terminates properly

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2018-09-01 18:54:56 +02:00
parent 04d9e1c80a
commit 2ff15101ae
3 changed files with 36 additions and 0 deletions
+1
View File
@@ -1,6 +1,7 @@
*.trs
*.log
active
api
complete
cronrun
signal
+1
View File
@@ -3,6 +3,7 @@ CLEANFILES = *~ *.trs *.log
TESTS =
TESTS += active
TESTS += api
TESTS += complete
TESTS += cronrun
TESTS += signal
+34
View File
@@ -0,0 +1,34 @@
#include "check.h"
uev_t timer, file;
int counter = 10;
static void cb(uev_t *w, void *UNUSED(arg), int events)
{
if (UEV_ERROR == events)
fprintf(stderr, "timer watcher failed, ignoring ...\n");
if (counter--)
return;
uev_exit(w->ctx);
}
int main(void)
{
uev_ctx_t ctx;
FILE *fp;
uev_init(&ctx);
uev_timer_init(&ctx, &timer, cb, NULL, 100, 100);
fp = fopen("/dev/one", "r");
if (fp)
uev_io_init(&ctx, &file, cb, NULL, fileno(fp), UEV_READ);
uev_run(&ctx, 0);
uev_exit(&ctx); /* Should not hang event loop, troglobit/uftpd#16 */
return 0;
}