From bc421a4a4698bffca4b275705a2a17401b788a63 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Sat, 19 Feb 2011 16:22:37 +0100 Subject: [PATCH] forb: Convert some older tests to wvtest framework --- src/tests/Makefile.omk | 9 +++++---- src/tests/discovery.c | 22 +++++++++------------- src/tests/hello_inproc.c | 10 +++++----- src/tests/test_proto_inet.c | 33 +++++++++++++++++---------------- 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/src/tests/Makefile.omk b/src/tests/Makefile.omk index d3fa45d..1bc15b2 100644 --- a/src/tests/Makefile.omk +++ b/src/tests/Makefile.omk @@ -1,9 +1,10 @@ SUBDIRS = $(ALL_OMK_SUBDIRS) -test_PROGRAMS += hello_inproc hello_remote test_proto_inet discovery \ - syncobj regobjref executor_id #executor_calls +wvtest_PROGRAMS += hello_inproc test_proto_inet discovery + +test_PROGRAMS += hello_remote syncobj regobjref executor_id #executor_calls ifeq ($(CONFIG_FORB_PROTO_UNIX),y) -test_PROGRAMS += test_proto_unix +wvtest_PROGRAMS += test_proto_unix endif wvtest_PROGRAMS += sequence @@ -47,4 +48,4 @@ syncobj_SOURCES = test_syncobj.c executor_id_SOURCES = executor_id.c -executor_calls_SOURCES = executor_calls.c \ No newline at end of file +executor_calls_SOURCES = executor_calls.c diff --git a/src/tests/discovery.c b/src/tests/discovery.c index 48b0a08..51cf6fe 100644 --- a/src/tests/discovery.c +++ b/src/tests/discovery.c @@ -66,6 +66,7 @@ #include #include #include +#include #define NUM_ORBS 5 @@ -73,19 +74,16 @@ #error This test should only work if there is some local protocol enabled. #endif -int main(int argc, char *argv[]) +WVTEST_MAIN("Automatic discovery of FORB servers") { +#ifndef CONFIG_FORB_PROTO_INET_DEFAULT forb_orb orb[NUM_ORBS]; int i; bool all_peers_found = true; fosa_abs_time_t timeout; - for (i=0; iserver_id, - &timeout); + WVPASS(peer = forb_peer_find_timed(forb_data(orb[i]), + &forb_data(orb[j])->server_id, + &timeout)); all_peers_found &= (peer != NULL); if (!all_peers_found) { @@ -112,7 +110,5 @@ int main(int argc, char *argv[]) } } } - - printf("OK\n"); - return 0; +#endif } diff --git a/src/tests/hello_inproc.c b/src/tests/hello_inproc.c index 701c908..93015cd 100644 --- a/src/tests/hello_inproc.c +++ b/src/tests/hello_inproc.c @@ -58,8 +58,9 @@ #include "hello_impl.h" #include #include +#include -int main(int argc, char *argv[]) +WVTEST_MAIN("in-proccess hello world") { forb_orb orb; hello hobj; @@ -68,16 +69,15 @@ int main(int argc, char *argv[]) .orb_id = "hello_inproc" }; - orb = forb_init(&argc, &argv, &attr); + WVPASS(orb = forb_init(0, NULL, &attr)); if (!orb) { error(1, errno, "Cannot initialize FORB"); } hobj = hello_impl_initialize(orb); hello_message(hobj, "Hello world!", &env); - if (forb_exception_occurred(&env)) { + if (!WVPASS(!forb_exception_occurred(&env))) { error(1, 0, "FORB exception %d", env.major); } - - return 0; + forb_destroy(orb); } diff --git a/src/tests/test_proto_inet.c b/src/tests/test_proto_inet.c index 25e8348..2b7cbd2 100644 --- a/src/tests/test_proto_inet.c +++ b/src/tests/test_proto_inet.c @@ -54,6 +54,7 @@ #include #include "../proto_inet.c" +#include const char *msg = "Hello world!"; const char *msg2 = "Blablabla!"; @@ -63,10 +64,10 @@ char *timeout_msg = "timeout\n"; void timeout(int signal) { - error(1, 0, timeout_msg); + //error(1, 0, timeout_msg); } -int main() +WVTEST_MAIN("AF_INET inter-orb protocol") { int len; struct inet_addr addr[NUM_PORTS]; @@ -79,23 +80,23 @@ int main() for (i=0; iaddr = port[i].desc.addr; peer->port = &port[0]; len = strlen(msg)+1; - ret = inet_send(peer, msg, len); + WVPASSEQ(ret = inet_send(peer, msg, len), len); peer->addr = NULL; forb_peer_put(peer); @@ -105,18 +106,18 @@ int main() sprintf(tmsg, "Timeout when sending from 0 to %d\n", i); timeout_msg = tmsg; alarm(1); /* timeout 1s */ - ret = inet_recv(&port[i], buf, sizeof(buf)); + WVPASSEQ(ret = inet_recv(&port[i], buf, sizeof(buf)), len); alarm(0); if (ret != len) error(1, errno, "recv(port[%d]) = %d", i, ret); - if (strcmp(msg, buf) != 0) + if (!WVPASS(strcmp(msg, buf) == 0)) error(1, errno, "port %d: received wrong data", i); - } +#ifndef CONFIG_FORB_PROTO_INET_DEFAULT len = strlen(msg2)+1; - ret = inet_broadcast(&port[0], msg2, len); + WVPASSEQ(ret = inet_broadcast(&port[0], msg2, len), len); if (ret != len) error(1, errno, "broadcast(port[0]) = %d should be %d", ret, len); @@ -127,21 +128,21 @@ int main() sprintf(tmsg, "Timeout when receiving broadcast for port %d\n", i); timeout_msg = tmsg; alarm(1); - ret = inet_recv(&port[i], buf, sizeof(buf)); + WVPASSEQ(ret = inet_recv(&port[i], buf, sizeof(buf)), len); alarm(0); if (ret != len) error(1, errno, "broadcast recv(port[%d]) = %d should be %d (errno=%d)", i, ret, len, errno); //printf("broadcast received: %s\n", buf); - if (strcmp(msg2, buf) != 0) + if (!WVPASS(strcmp(msg2, buf) == 0)) error(1, errno, "port %d: broadcast received wrong data", i); } +#endif for (i=0; i