multiple operation queues for an operation
[oweals/gnunet.git] / src / testbed / test_testbed_api_3peers_3controllers.c
1 /*
2       This file is part of GNUnet
3       (C) 2008--2012 Christian Grothoff (and other contributing authors)
4
5       GNUnet is free software; you can redistribute it and/or modify
6       it under the terms of the GNU General Public License as published
7       by the Free Software Foundation; either version 3, or (at your
8       option) any later version.
9
10       GNUnet is distributed in the hope that it will be useful, but
11       WITHOUT ANY WARRANTY; without even the implied warranty of
12       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13       General Public License for more details.
14
15       You should have received a copy of the GNU General Public License
16       along with GNUnet; see the file COPYING.  If not, write to the
17       Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18       Boston, MA 02111-1307, USA.
19  */
20
21 /**
22  * @file testbed/test_testbed_api_3peers_3controllers.c
23  * @brief testcases for the testbed api: 3 peers are configured, started and
24  *          connected together. Each peer resides on its own controller.
25  * @author Sree Harsha Totakura
26  */
27
28
29 /**
30  * The testing architecture is:
31  *                  A
32  *                 / \
33  *                /   \
34  *               B === C 
35  * A is the master controller and B, C are slave controllers. B links to C
36  * laterally.
37  * Peers are mapped to controllers in the following relations:
38  *             Peer         Controller
39  *               1              A
40  *               2              B
41  *               3              C
42  *
43  */
44
45 #include "platform.h"
46 #include "gnunet_util_lib.h"
47 #include "gnunet_testing_lib-new.h"
48 #include "gnunet_testbed_service.h"
49
50
51 /**
52  * Generic logging shortcut
53  */
54 #define LOG(kind,...)                           \
55   GNUNET_log (kind, __VA_ARGS__)
56
57 /**
58  * Relative time seconds shorthand
59  */
60 #define TIME_REL_SECS(sec) \
61   GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, sec)
62
63
64 /**
65  * Peer context
66  */
67 struct PeerContext
68 {
69   /**
70    * The peer handle
71    */
72   struct GNUNET_TESTBED_Peer *peer;
73
74   /**
75    * Operations involving this peer
76    */
77   struct GNUNET_TESTBED_Operation *operation;
78
79   /**
80    * set to GNUNET_YES when peer is started
81    */
82   int is_running;
83 };
84
85 /**
86  * Our localhost
87  */
88 static struct GNUNET_TESTBED_Host *host;
89
90 /**
91  * The controller process of one controller
92  */
93 static struct GNUNET_TESTBED_ControllerProc *cp1;
94
95 /**
96  * A neighbouring host
97  */
98 static struct GNUNET_TESTBED_Host *neighbour1;
99
100 /**
101  * Another neighbouring host
102  */
103 static struct GNUNET_TESTBED_Host *neighbour2;
104
105 /**
106  * Handle for neighbour registration
107  */
108 static struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle;
109
110 /**
111  * The controller handle of one controller
112  */
113 static struct GNUNET_TESTBED_Controller *controller1;
114
115 /**
116  * peer 1
117  */
118 static struct PeerContext peer1;
119
120 /**
121  * peer2
122  */
123 static struct PeerContext peer2;
124
125 /**
126  * peer3
127  */
128 static struct PeerContext peer3;
129
130 /**
131  * Handle to starting configuration
132  */
133 static struct GNUNET_CONFIGURATION_Handle *cfg;
134
135 /**
136  * Handle to slave controller C's configuration, used to establish lateral link from
137  * master controller
138  */
139 static struct GNUNET_CONFIGURATION_Handle *cfg2;
140
141 /**
142  * Handle to operations involving both peers
143  */
144 static struct GNUNET_TESTBED_Operation *common_operation;
145
146 /**
147  * Abort task identifier
148  */
149 static GNUNET_SCHEDULER_TaskIdentifier abort_task;
150
151 /**
152  * Delayed connect job identifier
153  */
154 static GNUNET_SCHEDULER_TaskIdentifier delayed_connect_task;
155
156 /**
157  * Different stages in testing
158  */
159 enum Stage
160 {
161
162   /**
163    * Initial stage
164    */
165   INIT,
166
167   /**
168    * Controller 1 has started
169    */
170   CONTROLLER1_UP,
171
172   /**
173    * peer1 is created
174    */
175   PEER1_CREATED,
176
177   /**
178    * peer1 is started
179    */
180   PEER1_STARTED,
181
182   /**
183    * Controller 2 has started
184    */
185   CONTROLLER2_UP,
186
187   /**
188    * peer2 is created
189    */
190   PEER2_CREATED,
191
192   /**
193    * peer2 is started
194    */
195   PEER2_STARTED,
196
197   /**
198    * Controller 3 has started
199    */
200   CONTROLLER3_UP,
201
202   /**
203    * Peer3 is created
204    */
205   PEER3_CREATED,
206
207   /**
208    * Peer3 started
209    */
210   PEER3_STARTED,
211
212   /**
213    * peer1 and peer2 are connected
214    */
215   PEERS_1_2_CONNECTED,
216
217   /**
218    * peer2 and peer3 are connected
219    */
220   PEERS_2_3_CONNECTED,
221
222   /**
223    * Peers are connected once again (this should not fail as they are already connected)
224    */
225   PEERS_CONNECTED_2,
226
227   /**
228    * peers are stopped
229    */
230   PEERS_STOPPED,
231
232   /**
233    * Final success stage
234    */
235   SUCCESS
236 };
237
238 /**
239  * The testing result
240  */
241 static enum Stage result;
242
243 /**
244  * Shutdown nicely
245  *
246  * @param cls NULL
247  * @param tc the task context
248  */
249 static void
250 do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
251 {
252   if (GNUNET_SCHEDULER_NO_TASK != abort_task)
253     GNUNET_SCHEDULER_cancel (abort_task);
254   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task);
255   if (NULL != reg_handle)
256     GNUNET_TESTBED_cancel_registration (reg_handle);
257   if (NULL != controller1)
258     GNUNET_TESTBED_controller_disconnect (controller1);
259   GNUNET_CONFIGURATION_destroy (cfg);
260   if (NULL != cfg2)
261     GNUNET_CONFIGURATION_destroy (cfg2);
262   if (NULL != cp1)
263     GNUNET_TESTBED_controller_stop (cp1);
264   if (NULL != host)
265     GNUNET_TESTBED_host_destroy (host);
266   if (NULL != neighbour1)
267     GNUNET_TESTBED_host_destroy (neighbour1);
268   if (NULL != neighbour2)
269     GNUNET_TESTBED_host_destroy (neighbour2);
270 }
271
272
273 /**
274  * abort task to run on test timed out
275  *
276  * @param cls NULL
277  * @param tc the task context
278  */
279 static void
280 do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
281 {
282   LOG (GNUNET_ERROR_TYPE_WARNING, "Test timedout -- Aborting\n");
283   abort_task = GNUNET_SCHEDULER_NO_TASK;
284   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == delayed_connect_task);
285   do_shutdown (cls, tc);
286 }
287
288
289 /**
290  * Callback to be called when an operation is completed
291  *
292  * @param cls the callback closure from functions generating an operation
293  * @param op the operation that has been finished
294  * @param emsg error message in case the operation has failed; will be NULL if
295  *          operation has executed successfully.
296  */
297 static void 
298 op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg);
299
300
301 /**
302  * task for delaying a connect
303  *
304  * @param cls NULL
305  * @param tc the task context
306  */
307 static void
308 do_delayed_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
309 {
310   delayed_connect_task = GNUNET_SCHEDULER_NO_TASK;
311   GNUNET_assert (NULL == common_operation);
312   common_operation = GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, 
313                                                      peer1.peer, peer2.peer);
314 }
315
316
317 /**
318  * Callback to be called when an operation is completed
319  *
320  * @param cls the callback closure from functions generating an operation
321  * @param op the operation that has been finished
322  * @param emsg error message in case the operation has failed; will be NULL if
323  *          operation has executed successfully.
324  */
325 static void 
326 op_comp_cb (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
327 {
328   GNUNET_assert (common_operation == op);
329   switch(result)
330   {
331   case PEER3_STARTED:
332     GNUNET_assert (NULL == peer1.operation);
333     GNUNET_assert (NULL == peer2.operation);
334     GNUNET_assert (NULL != common_operation);
335     GNUNET_TESTBED_operation_done (common_operation);
336     common_operation = NULL;
337     result = PEERS_1_2_CONNECTED;
338     LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n");
339     common_operation = 
340         GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer,
341                                           peer3.peer);
342     break;
343   case PEERS_1_2_CONNECTED:
344     GNUNET_assert (NULL != common_operation);
345     GNUNET_TESTBED_operation_done (common_operation);
346     common_operation = NULL;
347     result = PEERS_2_3_CONNECTED;
348     delayed_connect_task =
349           GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (3),
350                                         &do_delayed_connect, NULL);
351     break;
352   case PEERS_2_3_CONNECTED:
353     GNUNET_assert (NULL == peer1.operation);
354     GNUNET_assert (NULL == peer2.operation);
355     GNUNET_assert (NULL != common_operation);
356     GNUNET_TESTBED_operation_done (common_operation);
357     common_operation = NULL;
358     result = PEERS_CONNECTED_2;
359     LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected again\n");
360     peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer, NULL, NULL);
361     peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer, NULL, NULL);
362     peer3.operation = GNUNET_TESTBED_peer_stop (peer3.peer, NULL, NULL);
363     break;
364   default:
365     GNUNET_assert (0);
366   }
367 }
368
369
370 /**
371  * Functions of this signature are called when a peer has been successfully
372  * created
373  *
374  * @param cls NULL
375  * @param peer the handle for the created peer; NULL on any error during
376  *          creation
377  * @param emsg NULL if peer is not NULL; else MAY contain the error description
378  */
379 static void
380 peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
381 {
382   switch (result)
383   {
384   case CONTROLLER1_UP:
385     GNUNET_assert (NULL != peer1.operation);
386     GNUNET_assert (NULL != peer);
387     GNUNET_assert (NULL == peer1.peer);
388     peer1.peer = peer;
389     GNUNET_TESTBED_operation_done (peer1.operation);
390     result = PEER1_CREATED;
391     peer1.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL);
392     break;
393   case CONTROLLER2_UP:
394     GNUNET_assert (NULL != peer2.operation);
395     GNUNET_assert (NULL != peer);
396     GNUNET_assert (NULL == peer2.peer);
397     peer2.peer = peer;
398     GNUNET_TESTBED_operation_done (peer2.operation);
399     result = PEER2_CREATED;
400     peer2.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL);
401     break;
402   case CONTROLLER3_UP:
403     GNUNET_assert (NULL != peer3.operation);
404     GNUNET_assert (NULL != peer);
405     GNUNET_assert (NULL == peer3.peer);
406     peer3.peer = peer;
407     GNUNET_TESTBED_operation_done (peer3.operation);
408     result = PEER3_CREATED;
409     peer3.operation = GNUNET_TESTBED_peer_start (NULL, peer, NULL, NULL);
410     break;
411   default:
412     GNUNET_assert (0);
413   }  
414 }
415
416
417 /**
418  * Callback to signal successfull startup of the controller process
419  *
420  * @param cls the closure from GNUNET_TESTBED_controller_start()
421  * @param cfg the configuration with which the controller has been started;
422  *          NULL if status is not GNUNET_OK
423  * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
424  *          GNUNET_TESTBED_controller_stop() shouldn't be called in this case
425  */
426 static void
427 status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int status);
428
429
430 /**
431  * Signature of the event handler function called by the
432  * respective event controller.
433  *
434  * @param cls closure
435  * @param event information about the event
436  */
437 static void
438 controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
439 {
440   switch (event->type)
441   {
442   case GNUNET_TESTBED_ET_OPERATION_FINISHED:
443     GNUNET_assert (NULL == event->details.operation_finished.op_cls);
444     GNUNET_assert (NULL == event->details.operation_finished.emsg);
445     switch (result)
446     {      
447     case PEERS_STOPPED:
448       GNUNET_assert (NULL == event->details.operation_finished.generic);
449       if (event->details.operation_finished.operation == peer1.operation)
450       {
451         GNUNET_TESTBED_operation_done (peer1.operation);
452         peer1.operation = NULL;
453         peer1.peer = NULL;
454       }
455       else if (event->details.operation_finished.operation == peer2.operation)
456       {
457         GNUNET_TESTBED_operation_done (peer2.operation);
458         peer2.operation = NULL;
459         peer2.peer = NULL;
460       }
461       else if (event->details.operation_finished.operation == peer3.operation)
462       {
463         GNUNET_TESTBED_operation_done (peer3.operation);
464         peer3.operation = NULL;
465         peer3.peer = NULL;
466       }
467       else
468         GNUNET_assert (0);
469       if ((NULL == peer1.peer) && (NULL == peer2.peer) && (NULL == peer3.peer))
470       {
471         result = SUCCESS;
472         GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
473       }
474       break;
475     case PEER1_STARTED:
476       GNUNET_assert (NULL == event->details.operation_finished.generic);
477       GNUNET_assert (NULL != common_operation);
478       GNUNET_TESTBED_operation_done (common_operation);
479       common_operation = NULL;
480       result = CONTROLLER2_UP;
481       peer2.operation =
482           GNUNET_TESTBED_peer_create (controller1, neighbour1, cfg,
483                                       &peer_create_cb, NULL);
484       GNUNET_assert (NULL != peer2.operation);
485       break;
486     case PEER2_STARTED:
487       GNUNET_assert (NULL == event->details.operation_finished.generic);
488       GNUNET_assert (NULL != common_operation);
489       GNUNET_TESTBED_operation_done (common_operation);
490       common_operation = NULL;
491       result = CONTROLLER3_UP;
492       peer3.operation =
493           GNUNET_TESTBED_peer_create (controller1, neighbour2, cfg,
494                                       &peer_create_cb, NULL);
495       GNUNET_assert (NULL != peer3.operation);
496       break;
497     default:
498       GNUNET_assert (0);
499     }
500     break;
501   case GNUNET_TESTBED_ET_PEER_START:    
502     switch (result)
503     {
504     case PEER1_CREATED:
505       GNUNET_assert (event->details.peer_start.host == host);
506       peer1.is_running = GNUNET_YES;
507       GNUNET_TESTBED_operation_done (peer1.operation);
508       peer1.operation = NULL;
509       result = PEER1_STARTED;
510       common_operation =
511           GNUNET_TESTBED_controller_link (NULL, controller1, neighbour1, NULL, cfg,
512                                           GNUNET_YES); 
513       break;
514     case PEER2_CREATED:
515       GNUNET_assert (event->details.peer_start.host == neighbour1);
516       peer2.is_running = GNUNET_YES;
517       GNUNET_TESTBED_operation_done (peer2.operation);
518       peer2.operation = NULL;
519       result = PEER2_STARTED;
520       GNUNET_assert (NULL == common_operation);              
521       common_operation =
522           GNUNET_TESTBED_controller_link (NULL, controller1, neighbour2, NULL, cfg,
523                                           GNUNET_YES);
524       GNUNET_assert (NULL != common_operation);
525       break;
526     case PEER3_CREATED:
527       GNUNET_assert (event->details.peer_start.host == neighbour2);
528       peer3.is_running = GNUNET_YES;
529       GNUNET_TESTBED_operation_done (peer3.operation);
530       peer3.operation = NULL;
531       result = PEER3_STARTED;
532       common_operation =
533           GNUNET_TESTBED_overlay_connect (NULL, &op_comp_cb, NULL, peer2.peer,
534                                           peer1.peer);
535       break;
536     default:
537       GNUNET_assert (0);
538     }    
539     break;
540   case GNUNET_TESTBED_ET_PEER_STOP:
541     GNUNET_assert (PEERS_CONNECTED_2 == result);
542     if (event->details.peer_stop.peer == peer1.peer)
543     {
544       peer1.is_running = GNUNET_NO;
545       GNUNET_TESTBED_operation_done (peer1.operation);
546     }
547     else if (event->details.peer_stop.peer == peer2.peer)
548     {
549       peer2.is_running = GNUNET_NO;
550       GNUNET_TESTBED_operation_done (peer2.operation);
551     }
552     else if (event->details.peer_stop.peer == peer3.peer)
553     {
554       peer3.is_running = GNUNET_NO;
555       GNUNET_TESTBED_operation_done (peer3.operation);
556     }
557     else
558       GNUNET_assert (0);
559     if ((GNUNET_NO == peer1.is_running) &&
560         (GNUNET_NO == peer2.is_running) &&
561         (GNUNET_NO == peer3.is_running))
562     {
563       result = PEERS_STOPPED;
564       peer1.operation = GNUNET_TESTBED_peer_destroy (peer1.peer);
565       peer2.operation = GNUNET_TESTBED_peer_destroy (peer2.peer);
566       peer3.operation = GNUNET_TESTBED_peer_destroy (peer3.peer);
567     }
568     break;
569   case GNUNET_TESTBED_ET_CONNECT:
570     GNUNET_assert (NULL == peer1.operation);
571     GNUNET_assert (NULL == peer2.operation);
572     GNUNET_assert (NULL == peer3.operation);
573     switch (result)
574     {
575     case PEER3_STARTED:
576       GNUNET_assert (NULL != common_operation);
577       GNUNET_assert ((event->details.peer_connect.peer1 == peer2.peer) &&
578                      (event->details.peer_connect.peer2 == peer1.peer));
579       break;
580     case PEERS_2_3_CONNECTED:
581       GNUNET_assert (NULL != common_operation);
582       GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) &&
583                      (event->details.peer_connect.peer2 == peer2.peer));
584       break;
585     case PEERS_1_2_CONNECTED: 
586       GNUNET_assert (NULL != common_operation);
587       GNUNET_assert ((event->details.peer_connect.peer1 == peer2.peer) &&
588                      (event->details.peer_connect.peer2 == peer3.peer));      
589       break;
590     default:
591       GNUNET_assert (0);
592     }
593     break;
594   default:
595     GNUNET_assert (0);
596   };
597 }
598
599
600 /**
601  * Callback which will be called to after a host registration succeeded or failed
602  *
603  * @param cls the host which has been registered
604  * @param emsg the error message; NULL if host registration is successful
605  */
606 static void
607 registration_comp (void *cls, const char *emsg)
608 {
609   reg_handle = NULL;
610   if (cls == neighbour1)
611   {
612     neighbour2 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, 0);
613     GNUNET_assert (NULL != neighbour2);
614     reg_handle =
615         GNUNET_TESTBED_register_host (controller1, neighbour2, &registration_comp,
616                                       neighbour2);
617     GNUNET_assert (NULL != reg_handle);
618     return;
619   }
620   GNUNET_assert (cls == neighbour2);
621   peer1.operation =
622       GNUNET_TESTBED_peer_create (controller1, host, cfg, &peer_create_cb,
623                                   &peer1);
624   GNUNET_assert (NULL != peer1.operation);  
625 }
626
627
628 /**
629  * Callback to signal successfull startup of the controller process
630  *
631  * @param cls the closure from GNUNET_TESTBED_controller_start()
632  * @param cfg the configuration with which the controller has been started;
633  *          NULL if status is not GNUNET_OK
634  * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
635  *          GNUNET_TESTBED_controller_stop() shouldn't be called in this case
636  */
637 static void
638 status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, int status)
639 {
640   uint64_t event_mask;
641   
642   GNUNET_assert (GNUNET_OK == status);
643   event_mask = 0;
644   event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START);
645   event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
646   event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT);
647   event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED);
648   switch (result)
649   {
650   case INIT:
651     controller1 =
652         GNUNET_TESTBED_controller_connect (config, host, event_mask, &controller_cb,
653                                            NULL);
654     GNUNET_assert (NULL != controller1);
655     result = CONTROLLER1_UP;
656     neighbour1 = GNUNET_TESTBED_host_create ("127.0.0.1", NULL, 0);
657     GNUNET_assert (NULL != neighbour1);
658     reg_handle =
659         GNUNET_TESTBED_register_host (controller1, neighbour1, &registration_comp,
660                                       neighbour1);
661     GNUNET_assert (NULL != reg_handle);
662     break;
663   default:
664     GNUNET_assert (0);
665   }  
666 }
667
668
669 /**
670  * Main run function.
671  *
672  * @param cls NULL
673  * @param args arguments passed to GNUNET_PROGRAM_run
674  * @param cfgfile the path to configuration file
675  * @param cfg the configuration file handle
676  */
677 static void
678 run (void *cls, char *const *args, const char *cfgfile,
679      const struct GNUNET_CONFIGURATION_Handle *config)
680 {
681   host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
682   GNUNET_assert (NULL != host);
683   cfg = GNUNET_CONFIGURATION_dup (config);
684   cp1 = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb,
685                                          NULL);
686   abort_task =
687       GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
688                                     (GNUNET_TIME_UNIT_MINUTES, 3), &do_abort,
689                                     NULL);
690 }
691
692
693 /**
694  * Function to check if 
695  * 1. Password-less SSH logins to given ip work
696  * 2. gnunet-helper-testbed is found on the PATH on the remote side
697  *
698  * @param host_str numeric representation of the host's ip
699  * @return GNUNET_YES if password-less SSH login to the given host works;
700  *           GNUNET_NO if not
701  */
702 static int
703 check_ssh (char *host_str)
704 {
705   char *const remote_args[] = {
706     "ssh", "-o", "BatchMode=yes", "-o", "CheckHostIP=no", 
707     "-o", "NoHostAuthenticationForLocalhost=yes", "-q",
708     host_str, "which", "gnunet-helper-testbed", NULL
709   };
710   struct GNUNET_OS_Process *auxp;
711   enum GNUNET_OS_ProcessStatusType type;
712   unsigned long code;
713   int ret;
714
715   auxp =
716       GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
717                                    NULL, "ssh", remote_args);
718   GNUNET_assert (NULL != auxp);
719   do
720   {
721     ret = GNUNET_OS_process_status (auxp, &type, &code);
722     GNUNET_assert (GNUNET_SYSERR != ret);
723     (void) usleep (300);
724   }
725   while (GNUNET_NO == ret);
726   (void) GNUNET_OS_process_wait (auxp);
727   GNUNET_OS_process_destroy (auxp);
728   return (0 != code) ? GNUNET_NO : GNUNET_YES;
729 }
730
731
732 /**
733  * Main function
734  */
735 int
736 main (int argc, char **argv)
737 {
738   char *const argv2[] = { "test_testbed_api_3peers_3controllers",
739                           "-c", "test_testbed_api.conf",
740                           NULL
741   };
742   struct GNUNET_GETOPT_CommandLineOption options[] = {
743     GNUNET_GETOPT_OPTION_END
744   };
745   int ret;
746
747   if (GNUNET_YES != check_ssh ("127.0.0.1"))
748     goto error_exit;
749   result = INIT;
750   ret =
751       GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
752                           "test_testbed_api_3peers_3controllers", "nohelp",
753                           options, &run, NULL);
754   if ((GNUNET_OK != ret) || (SUCCESS != result))
755     return 1;
756   return 0;
757
758  error_exit:
759   (void) PRINTF ("%s",
760                  "Unable to run the test as this system is not configured "
761                  "to use password less SSH logins to localhost.\n"
762                  "Marking test as successful\n");
763   return 0;
764 }
765
766 /* end of test_testbed_api_3peers_3controllers.c */