From 27aa6d45ef5ad46306f0f133214571abf6fc91bf Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sun, 20 Feb 2011 09:37:39 +0100 Subject: [PATCH] forb: Convert syncobj test to wvtest style --- src/tests/Makefile.omk | 4 ++-- src/tests/test_syncobj.c | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/tests/Makefile.omk b/src/tests/Makefile.omk index 1bc15b2..d05eadc 100644 --- a/src/tests/Makefile.omk +++ b/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/tests/test_syncobj.c b/src/tests/test_syncobj.c index 7e75a3c..f1b9ce3 100644 --- a/src/tests/test_syncobj.c +++ b/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); } -- 2.39.2