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
executor_id_SOURCES = executor_id.c
-executor_calls_SOURCES = executor_calls.c
\ No newline at end of file
+executor_calls_SOURCES = executor_calls.c
#include <error.h>
#include <fosa.h>
#include <stdio.h>
+#include <wvtest.h>
#define NUM_ORBS 5
#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; i<NUM_ORBS; i++) {
- orb[i] = forb_init(&argc, &argv, NULL);
- if (!orb[i]) {
- error(1, errno, "Orb no. %d was not created\n", i);
- }
- }
+ for (i=0; i<NUM_ORBS; i++)
+ WVPASS(orb[i] = forb_init(0, NULL, NULL));
fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &timeout);
timeout = fosa_abs_time_incr(timeout,
forb_peer_t *peer;
for (j=0; j<NUM_ORBS && all_peers_found; j++) {
if (i==j) continue;
- peer = forb_peer_find_timed(forb_data(orb[i]),
- &forb_data(orb[j])->server_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) {
}
}
}
-
- printf("OK\n");
- return 0;
+#endif
}
#include "hello_impl.h"
#include <forb.h>
#include <error.h>
+#include <wvtest.h>
-int main(int argc, char *argv[])
+WVTEST_MAIN("in-proccess hello world")
{
forb_orb orb;
hello hobj;
.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);
}
#include <error.h>
#include "../proto_inet.c"
+#include <wvtest.h>
const char *msg = "Hello world!";
const char *msg2 = "Blablabla!";
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];
for (i=0; i<NUM_PORTS; i++) {
addr[i].addr.s_addr = htonl(0x7f000001+i);
- if (forb_inet_port_init(&port[i].desc, addr[i].addr, 0) != 0)
+ if (!WVPASSEQ(forb_inet_port_init(&port[i].desc, addr[i].addr, 0), 0))
error(1, errno, "forb_inet_port_init(%d)", i);
}
/* Send from zeroth node to all others (starting from 1) */
for (i=1; i<NUM_PORTS; i++) {
- forb_peer_t *peer;
char buf[100];
char tmsg[100];
-
- peer = forb_peer_new();
+ forb_peer_t *peer;
+
+ WVPASS(peer = forb_peer_new());
peer->addr = 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);
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);
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<NUM_PORTS; i++) {
inet_port_destroy(&port[i]);
+ if (port[i].new_peer)
+ forb_peer_put(port[i].new_peer);
}
-
- printf("OK\n");
- return 0;
}