From: Michal Sojka Date: Sun, 20 Feb 2011 08:37:39 +0000 (+0100) Subject: forb: Convert syncobj test to wvtest style X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/frsh-forb.git/commitdiff_plain/d15b3815d91c6ea592a319887b1629fdcf5cdcd7 forb: Convert syncobj test to wvtest style --- diff --git a/src/forb/src/tests/Makefile.omk b/src/forb/src/tests/Makefile.omk index 1bc15b2c..d05eadc5 100644 --- a/src/forb/src/tests/Makefile.omk +++ b/src/forb/src/tests/Makefile.omk @@ -1,8 +1,8 @@ SUBDIRS = $(ALL_OMK_SUBDIRS) -wvtest_PROGRAMS += hello_inproc test_proto_inet discovery +wvtest_PROGRAMS += hello_inproc test_proto_inet discovery syncobj -test_PROGRAMS += hello_remote syncobj regobjref executor_id #executor_calls +test_PROGRAMS += hello_remote regobjref executor_id #executor_calls ifeq ($(CONFIG_FORB_PROTO_UNIX),y) wvtest_PROGRAMS += test_proto_unix endif diff --git a/src/forb/src/tests/test_syncobj.c b/src/forb/src/tests/test_syncobj.c index 7e75a3c9..f1b9ce38 100644 --- a/src/forb/src/tests/test_syncobj.c +++ b/src/forb/src/tests/test_syncobj.c @@ -58,6 +58,7 @@ #include #include #include +#include forb_syncobj_t syncobj; @@ -69,40 +70,39 @@ void *thread(void *arg) fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &hello_time); hello_time = fosa_abs_time_incr(hello_time, hello_interval); - ret = forb_syncobj_timedwait(&syncobj, &hello_time); + WVPASSEQ(ret = forb_syncobj_timedwait(&syncobj, &hello_time), 0); if (ret != 0) { error(1, errno, "forb_syncobj_timedwait() error %d\n", ret); } fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &now); - if (fosa_abs_time_smaller_or_equal(hello_time, now)) { + if (WVFAIL(fosa_abs_time_smaller_or_equal(hello_time, now))) { error(1, 0, "Should not wait longet than timeout\n"); } return NULL; } -int main() +WVTEST_MAIN("FORB's syncobj") { fosa_abs_time_t now, hello_time; - fosa_rel_time_t hello_interval = fosa_msec_to_rel_time(1000); + fosa_rel_time_t hello_interval = fosa_msec_to_rel_time(100); int ret; - fosa_thread_id_t tid; + pthread_t tid; - forb_syncobj_init(&syncobj, 0); + WVPASSEQ(forb_syncobj_init(&syncobj, 0), 0); fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &hello_time); hello_time = fosa_abs_time_incr(hello_time, hello_interval); ret = forb_syncobj_timedwait(&syncobj, &hello_time); - if (ret != 0 && ret != FOSA_ETIMEDOUT) { + if (!WVPASS(ret == FOSA_ETIMEDOUT || ret == 0)) { error(1, errno, "forb_syncobj_timedwait() error %d\n", ret); } fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &now); - if (fosa_abs_time_smaller_or_equal(now, hello_time)) { + if (WVFAIL(fosa_abs_time_smaller_or_equal(now, hello_time))) { error(1, 0, "Wait less then timeout\n"); } - - fosa_thread_create(&tid, NULL, thread, NULL); + pthread_create(&tid, NULL, thread, NULL); forb_syncobj_signal(&syncobj); - return 0; + pthread_join(tid, NULL); }