aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-11-16 13:53:15 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-11-16 13:53:15 +0000
commita9bf62ba111bf7c80700aee33b09c7ee77da1dc2 (patch)
treef5984e7b8e2a6615e965cb65e9dbe81f8107ffc7
parent1970e9b88ad49d85111a4462112c7b078e3ce64f (diff)
downloadgnunet-a9bf62ba111bf7c80700aee33b09c7ee77da1dc2.tar.gz
gnunet-a9bf62ba111bf7c80700aee33b09c7ee77da1dc2.zip
- towards testbed_create
-rw-r--r--src/testbed/testbed_api_testbed.c48
1 files changed, 41 insertions, 7 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index d597d47a6..11dedcd1f 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -28,6 +28,7 @@
28#include "platform.h" 28#include "platform.h"
29#include "gnunet_testbed_service.h" 29#include "gnunet_testbed_service.h"
30#include "testbed_api_peers.h" 30#include "testbed_api_peers.h"
31#include "testbed_api_hosts.h"
31 32
32/** 33/**
33 * Generic loggins shorthand 34 * Generic loggins shorthand
@@ -40,7 +41,20 @@
40 */ 41 */
41struct GNUNET_TESTBED_Testbed 42struct GNUNET_TESTBED_Testbed
42{ 43{
43 // FIXME! 44 /**
45 * The array of hosts
46 */
47 struct GNUNET_TESTBED_Host **hosts;
48
49 /**
50 * The number of hosts in the hosts array
51 */
52 unsigned int num_hosts;
53
54 /**
55 * The controller handle
56 */
57 struct GNUNET_TESTBED_Controller *c;
44}; 58};
45 59
46 60
@@ -701,21 +715,40 @@ GNUNET_TESTBED_run (const char *host_filename,
701 * use 'localhost' 715 * use 'localhost'
702 * @param hosts list of hosts to use for the testbed 716 * @param hosts list of hosts to use for the testbed
703 * @param num_peers number of peers to start 717 * @param num_peers number of peers to start
704 * @param peer_cfg peer configuration template to use 718 * @param cfg the configuration to use as a template for peers and also for
719 * checking the value of testbed helper binary
705 * @param underlay_topology underlay topology to create 720 * @param underlay_topology underlay topology to create
706 * @param va topology-specific options 721 * @param va topology-specific options
707 * @return handle to the testbed 722 * @return handle to the testbed; NULL upon error (error messaage will be printed)
708 */ 723 */
709struct GNUNET_TESTBED_Testbed * 724struct GNUNET_TESTBED_Testbed *
710GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller, 725GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
711 unsigned int num_hosts, 726 unsigned int num_hosts,
712 struct GNUNET_TESTBED_Host **hosts, 727 struct GNUNET_TESTBED_Host **hosts,
713 unsigned int num_peers, 728 unsigned int num_peers,
714 const struct GNUNET_CONFIGURATION_Handle *peer_cfg, 729 const struct GNUNET_CONFIGURATION_Handle *cfg,
715 enum GNUNET_TESTBED_TopologyOption underlay_topology, 730 enum GNUNET_TESTBED_TopologyOption underlay_topology,
716 va_list va) 731 va_list va)
717{ 732{
733 unsigned int nhost;
734
718 GNUNET_assert (underlay_topology < GNUNET_TESTBED_TOPOLOGY_NONE); 735 GNUNET_assert (underlay_topology < GNUNET_TESTBED_TOPOLOGY_NONE);
736 if (num_hosts != 0)
737 {
738 for (nhost = 0; nhost < num_hosts; nhost++)
739 {
740 if (GNUNET_YES != GNUNET_TESTBED_is_host_habitable (hosts[nhost], cfg))
741 {
742 LOG (GNUNET_ERROR_TYPE_ERROR, _("Host %s cannot start testbed\n"),
743 GNUNET_TESTBED_host_get_hostname_ (hosts[nhost]));
744 break;
745 }
746 }
747 if (num_hosts != nhost)
748 return NULL;
749 }
750 /* We need controller callback here to get operation done events while
751 linking hosts */
719 GNUNET_break (0); 752 GNUNET_break (0);
720 return NULL; 753 return NULL;
721} 754}
@@ -733,7 +766,8 @@ GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller,
733 * use 'localhost' 766 * use 'localhost'
734 * @param hosts list of hosts to use for the testbed 767 * @param hosts list of hosts to use for the testbed
735 * @param num_peers number of peers to start 768 * @param num_peers number of peers to start
736 * @param peer_cfg peer configuration template to use 769 * @param cfg the configuration to use as a template for peers and also for
770 * checking the value of testbed helper binary
737 * @param underlay_topology underlay topology to create 771 * @param underlay_topology underlay topology to create
738 * @param ... topology-specific options 772 * @param ... topology-specific options
739 */ 773 */
@@ -742,7 +776,7 @@ GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
742 unsigned int num_hosts, 776 unsigned int num_hosts,
743 struct GNUNET_TESTBED_Host **hosts, 777 struct GNUNET_TESTBED_Host **hosts,
744 unsigned int num_peers, 778 unsigned int num_peers,
745 const struct GNUNET_CONFIGURATION_Handle *peer_cfg, 779 const struct GNUNET_CONFIGURATION_Handle *cfg,
746 enum GNUNET_TESTBED_TopologyOption underlay_topology, 780 enum GNUNET_TESTBED_TopologyOption underlay_topology,
747 ...) 781 ...)
748{ 782{
@@ -751,7 +785,7 @@ GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller,
751 785
752 va_start (vargs, underlay_topology); 786 va_start (vargs, underlay_topology);
753 testbed = GNUNET_TESTBED_create_va (controller, num_hosts, hosts, num_peers, 787 testbed = GNUNET_TESTBED_create_va (controller, num_hosts, hosts, num_peers,
754 peer_cfg, underlay_topology, vargs); 788 cfg, underlay_topology, vargs);
755 va_end (vargs); 789 va_end (vargs);
756 return testbed; 790 return testbed;
757} 791}