1 /**************************************************************************/
2 /* ---------------------------------------------------------------------- */
3 /* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
5 /* Universidad de Cantabria, SPAIN */
6 /* University of York, UK */
7 /* Scuola Superiore Sant'Anna, ITALY */
8 /* Kaiserslautern University, GERMANY */
9 /* Univ. Politécnica Valencia, SPAIN */
10 /* Czech Technical University in Prague, CZECH REPUBLIC */
12 /* Thales Communication S.A. FRANCE */
13 /* Visual Tools S.A. SPAIN */
14 /* Rapita Systems Ltd UK */
17 /* See http://www.frescor.org for a link to partners' websites */
19 /* FRESCOR project (FP6/2005/IST/5-034026) is funded */
20 /* in part by the European Union Sixth Framework Programme */
21 /* The European Union is not liable of any use that may be */
22 /* made of this code. */
25 /* This file is part of FORB (Frescor Object Request Broker) */
27 /* FORB is free software; you can redistribute it and/or modify it */
28 /* under terms of the GNU General Public License as published by the */
29 /* Free Software Foundation; either version 2, or (at your option) any */
30 /* later version. FORB is distributed in the hope that it will be */
31 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
32 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
33 /* General Public License for more details. You should have received a */
34 /* copy of the GNU General Public License along with FORB; see file */
35 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
36 /* Cambridge, MA 02139, USA. */
38 /* As a special exception, including FORB header files in a file, */
39 /* instantiating FORB generics or templates, or linking other files */
40 /* with FORB objects to produce an executable application, does not */
41 /* by itself cause the resulting executable application to be covered */
42 /* by the GNU General Public License. This exception does not */
43 /* however invalidate any other reasons why the executable file might be */
44 /* covered by the GNU Public License. */
45 /**************************************************************************/
49 * @author Michal Sojka <sojkam1@fel.cvut.cz>
50 * @date Sun Oct 12 19:05:27 2008
52 * @brief Test for correctness of peer discovery protocol
54 * Multiple FORB obejcts are created and it is tested whether every
55 * FORB automatically discovers the other FORBs.
60 #include <forb/object.h>
61 #include <forb/forb-internal.h>
62 #include <forb/config.h>
71 #if !CONFIG_FORB_PROTO_UNIX && !CONFIG_FORB_PROTO_INET_DEFAULT
72 #error This test should only work if there is some local protocol enabled.
75 int main(int argc, char *argv[])
77 forb_orb orb[NUM_ORBS];
79 bool all_peers_found = true;
80 fosa_abs_time_t timeout;
82 for (i=0; i<NUM_ORBS; i++) {
83 orb[i] = forb_init(&argc, &argv, NULL);
85 error(1, errno, "Orb no. %d was not created\n", i);
89 fosa_clock_get_time(FOSA_CLOCK_ABSOLUTE, &timeout);
90 timeout = fosa_abs_time_incr(timeout,
91 fosa_msec_to_rel_time(1000));
93 /* Check whether all the peers are found */
94 for (i=0; i<NUM_ORBS && all_peers_found; i++) {
97 for (j=0; j<NUM_ORBS && all_peers_found; j++) {
99 peer = forb_peer_find_timed(forb_data(orb[i]),
100 &forb_data(orb[j])->server_id,
103 all_peers_found &= (peer != NULL);
104 if (!all_peers_found) {
106 error(1, 0, "Peer %d (%s) was not discovered on node %d",
107 j, forb_uuid_to_string(id,
108 (forb_uuid_t*)&forb_data(orb[i])->server_id.uuid,