aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/test_testbed_api_controllerlink.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-08-24 13:51:06 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-08-24 13:51:06 +0000
commitb0cd5f3c9bf3f87d89fc2f50221cd245b0498b8f (patch)
tree67be1099b2a26be7d6d6fc67db67c20961ec485a /src/testbed/test_testbed_api_controllerlink.c
parent33a2bb119e435a090315645bfec7552e44338baf (diff)
downloadgnunet-b0cd5f3c9bf3f87d89fc2f50221cd245b0498b8f.tar.gz
gnunet-b0cd5f3c9bf3f87d89fc2f50221cd245b0498b8f.zip
peer create fowarding with tests
Diffstat (limited to 'src/testbed/test_testbed_api_controllerlink.c')
-rw-r--r--src/testbed/test_testbed_api_controllerlink.c70
1 files changed, 62 insertions, 8 deletions
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c
index 70f6fa846..5236ada4a 100644
--- a/src/testbed/test_testbed_api_controllerlink.c
+++ b/src/testbed/test_testbed_api_controllerlink.c
@@ -75,8 +75,17 @@ enum Stage
75 /** 75 /**
76 * Link from slave 1 to slave 2 has been successfully created. 76 * Link from slave 1 to slave 2 has been successfully created.
77 */ 77 */
78 SUCCESS 78 SLAVE2_LINK_SUCCESS,
79
80 /**
81 * Peer create on slave 1 successful
82 */
83 SLAVE1_PEER_CREATE_SUCCESS,
79 84
85 /**
86 * Test is successful
87 */
88 SUCCESS
80 }; 89 };
81 90
82/** 91/**
@@ -125,6 +134,16 @@ static GNUNET_SCHEDULER_TaskIdentifier abort_task;
125static struct GNUNET_TESTBED_Operation *op; 134static struct GNUNET_TESTBED_Operation *op;
126 135
127/** 136/**
137 * Handle to peer started at slave 1
138 */
139static struct GNUNET_TESTBED_Peer *slave1_peer;
140
141/**
142 * Handle to peer started at slave 2
143 */
144static struct GNUNET_TESTBED_Peer *slave2_peer;
145
146/**
128 * Event mask 147 * Event mask
129 */ 148 */
130uint64_t event_mask; 149uint64_t event_mask;
@@ -180,6 +199,43 @@ do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc)
180 199
181 200
182/** 201/**
202 * Functions of this signature are called when a peer has been successfully
203 * created
204 *
205 * @param cls the closure from GNUNET_TESTBED_peer_create()
206 * @param peer the handle for the created peer; NULL on any error during
207 * creation
208 * @param emsg NULL if peer is not NULL; else MAY contain the error description
209 */
210static void
211peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg)
212{
213 switch (result)
214 {
215 case SLAVE2_LINK_SUCCESS:
216 GNUNET_assert (NULL != peer);
217 GNUNET_assert (NULL == emsg);
218 result = SLAVE1_PEER_CREATE_SUCCESS;
219 slave1_peer = peer;
220 GNUNET_TESTBED_operation_done (op);
221 op = GNUNET_TESTBED_peer_create (mc, slave2, cfg, peer_create_cb, NULL);
222 GNUNET_assert (NULL != op);
223 break;
224 case SLAVE1_PEER_CREATE_SUCCESS:
225 GNUNET_assert (NULL != peer);
226 GNUNET_assert (NULL == emsg);
227 result = SUCCESS;
228 slave2_peer = peer;
229 GNUNET_TESTBED_operation_done (op);
230 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
231 break;
232 default:
233 GNUNET_assert (0);
234 }
235}
236
237
238/**
183 * Signature of the event handler function called by the 239 * Signature of the event handler function called by the
184 * respective event controller. 240 * respective event controller.
185 * 241 *
@@ -218,9 +274,10 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
218 GNUNET_assert (NULL == event->details.operation_finished.op_result.generic); 274 GNUNET_assert (NULL == event->details.operation_finished.op_result.generic);
219 GNUNET_TESTBED_operation_done (op); 275 GNUNET_TESTBED_operation_done (op);
220 op = NULL; 276 op = NULL;
221 result = SUCCESS; 277 result = SLAVE2_LINK_SUCCESS;
222 GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); 278 op = GNUNET_TESTBED_peer_create (mc, slave, cfg, peer_create_cb, NULL);
223 break; 279 GNUNET_assert (NULL != op);
280 break;
224 default: 281 default:
225 GNUNET_assert (0); 282 GNUNET_assert (0);
226 } 283 }
@@ -256,10 +313,7 @@ registration_cont (void *cls, const char *emsg)
256 op = GNUNET_TESTBED_controller_link (mc, slave, NULL, cfg, GNUNET_YES); 313 op = GNUNET_TESTBED_controller_link (mc, slave, NULL, cfg, GNUNET_YES);
257 GNUNET_assert (NULL != op); 314 GNUNET_assert (NULL != op);
258 break; 315 break;
259 case INIT: 316 default:
260 case SUCCESS:
261 case SLAVE2_REGISTERED:
262 case SLAVE1_LINK_SUCCESS:
263 GNUNET_assert (0); 317 GNUNET_assert (0);
264 } 318 }
265} 319}