diff options
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_start_testsystem.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_start_testsystem.c | 319 |
1 files changed, 202 insertions, 117 deletions
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c index 531621eb5..a1d71c436 100644 --- a/src/testing/testing_api_cmd_netjail_start_testsystem.c +++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c | |||
@@ -62,6 +62,16 @@ struct HelperMessage | |||
62 | struct NetJailState | 62 | struct NetJailState |
63 | { | 63 | { |
64 | /** | 64 | /** |
65 | * Context for our asynchronous completion. | ||
66 | */ | ||
67 | struct GNUNET_TESTING_AsyncContext ac; | ||
68 | |||
69 | /** | ||
70 | * The complete topology information. | ||
71 | */ | ||
72 | struct GNUNET_TESTING_NetjailTopology *topology; | ||
73 | |||
74 | /** | ||
65 | * Pointer to the return value of the test. | 75 | * Pointer to the return value of the test. |
66 | * | 76 | * |
67 | */ | 77 | */ |
@@ -91,16 +101,22 @@ struct NetJailState | |||
91 | unsigned int n_helper; | 101 | unsigned int n_helper; |
92 | 102 | ||
93 | /** | 103 | /** |
94 | * Number of nodes in a network namespace. //TODO make this a unsigned int | 104 | * Number of nodes in a natted subnet. |
95 | * | 105 | * |
96 | */ | 106 | */ |
97 | char *local_m; | 107 | unsigned int local_m; |
98 | 108 | ||
99 | /** | 109 | /** |
100 | * Number of network namespaces. //TODO make this a unsigned int | 110 | * Number of natted subnets. |
101 | * | 111 | * |
102 | */ | 112 | */ |
103 | char *global_n; | 113 | unsigned int global_n; |
114 | |||
115 | /** | ||
116 | * Number of global known nodes. | ||
117 | * | ||
118 | */ | ||
119 | unsigned int known; | ||
104 | 120 | ||
105 | /** | 121 | /** |
106 | * The send handle for the helper | 122 | * The send handle for the helper |
@@ -194,11 +210,9 @@ struct TestingSystemCount | |||
194 | * Code to clean up resource this cmd used. | 210 | * Code to clean up resource this cmd used. |
195 | * | 211 | * |
196 | * @param cls closure | 212 | * @param cls closure |
197 | * @param cmd current CMD being cleaned up. | ||
198 | */ | 213 | */ |
199 | static void | 214 | static void |
200 | netjail_exec_cleanup (void *cls, | 215 | netjail_exec_cleanup (void *cls) |
201 | const struct GNUNET_TESTING_Command *cmd) | ||
202 | { | 216 | { |
203 | struct NetJailState *ns = cls; | 217 | struct NetJailState *ns = cls; |
204 | struct HelperMessage *message_pos; | 218 | struct HelperMessage *message_pos; |
@@ -268,7 +282,8 @@ netjail_exec_traits (void *cls, | |||
268 | int | 282 | int |
269 | GNUNET_TESTING_get_trait_helper_handles (const struct | 283 | GNUNET_TESTING_get_trait_helper_handles (const struct |
270 | GNUNET_TESTING_Command *cmd, | 284 | GNUNET_TESTING_Command *cmd, |
271 | struct GNUNET_HELPER_Handle ***helper) | 285 | struct GNUNET_HELPER_Handle *** |
286 | helper) | ||
272 | { | 287 | { |
273 | return cmd->traits (cmd->cls, | 288 | return cmd->traits (cmd->cls, |
274 | (const void **) helper, | 289 | (const void **) helper, |
@@ -298,6 +313,43 @@ clear_msg (void *cls, int result) | |||
298 | } | 313 | } |
299 | 314 | ||
300 | 315 | ||
316 | static void | ||
317 | send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) | ||
318 | { | ||
319 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | ||
320 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
321 | size_t msg_length; | ||
322 | struct GNUNET_HELPER_Handle *helper; | ||
323 | struct TestingSystemCount *tbc; | ||
324 | |||
325 | tbc = GNUNET_new (struct TestingSystemCount); | ||
326 | tbc->ns = ns; | ||
327 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | ||
328 | if (0 == i) | ||
329 | tbc->count = j + total_number; | ||
330 | else | ||
331 | tbc->count = (i - 1) * ns->local_m + j + total_number + ns->known; | ||
332 | |||
333 | helper = ns->helper[tbc->count - 1 - total_number]; | ||
334 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
335 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
336 | reply->header.type = htons ( | ||
337 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
338 | reply->header.size = htons ((uint16_t) msg_length); | ||
339 | |||
340 | GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); | ||
341 | |||
342 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | ||
343 | helper, | ||
344 | &reply->header, | ||
345 | GNUNET_NO, | ||
346 | &clear_msg, | ||
347 | tbc); | ||
348 | |||
349 | GNUNET_array_append (ns->shandle, ns->n_shandle, sh); | ||
350 | } | ||
351 | |||
352 | |||
301 | /** | 353 | /** |
302 | * Functions with this signature are called whenever a | 354 | * Functions with this signature are called whenever a |
303 | * complete message is received by the tokenizer. | 355 | * complete message is received by the tokenizer. |
@@ -316,6 +368,7 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
316 | struct TestingSystemCount *tbc = cls; | 368 | struct TestingSystemCount *tbc = cls; |
317 | struct NetJailState *ns = tbc->ns; | 369 | struct NetJailState *ns = tbc->ns; |
318 | struct HelperMessage *hp_msg; | 370 | struct HelperMessage *hp_msg; |
371 | unsigned int total_number = ns->local_m * ns->global_n + ns->known; | ||
319 | 372 | ||
320 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) | 373 | if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) |
321 | { | 374 | { |
@@ -325,11 +378,31 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
325 | message->type)) | 378 | message->type)) |
326 | { | 379 | { |
327 | ns->number_of_peers_started++; | 380 | ns->number_of_peers_started++; |
381 | if (ns->number_of_peers_started == total_number) | ||
382 | { | ||
383 | for (int i = 1; i <= ns->known; i++) | ||
384 | { | ||
385 | send_all_peers_started (0,i, ns); | ||
386 | } | ||
387 | |||
388 | for (int i = 1; i <= ns->global_n; i++) | ||
389 | { | ||
390 | for (int j = 1; j <= ns->local_m; j++) | ||
391 | { | ||
392 | send_all_peers_started (i,j, ns); | ||
393 | } | ||
394 | } | ||
395 | ns->number_of_peers_started = 0; | ||
396 | } | ||
328 | } | 397 | } |
329 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( | 398 | else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( |
330 | message->type)) | 399 | message->type)) |
331 | { | 400 | { |
332 | ns->number_of_local_test_finished++; | 401 | ns->number_of_local_test_finished++; |
402 | if (ns->number_of_local_test_finished == total_number) | ||
403 | { | ||
404 | GNUNET_TESTING_async_finish (&ns->ac); | ||
405 | } | ||
333 | } | 406 | } |
334 | else | 407 | else |
335 | { | 408 | { |
@@ -340,6 +413,12 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
340 | hp_msg); | 413 | hp_msg); |
341 | } | 414 | } |
342 | 415 | ||
416 | |||
417 | |||
418 | |||
419 | |||
420 | |||
421 | |||
343 | return GNUNET_OK; | 422 | return GNUNET_OK; |
344 | } | 423 | } |
345 | 424 | ||
@@ -351,24 +430,21 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) | |||
351 | static void | 430 | static void |
352 | exp_cb (void *cls) | 431 | exp_cb (void *cls) |
353 | { | 432 | { |
354 | struct NetJailState *ns = cls; | 433 | struct TestingSystemCount *tbc = cls; |
434 | |||
355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); | 435 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); |
356 | *ns->rv = 1; | 436 | GNUNET_TESTING_interpreter_fail (tbc->ns->ac.is); |
357 | } | 437 | } |
358 | 438 | ||
359 | 439 | ||
360 | /** | 440 | /** |
361 | * Function to initialize a init message for the helper. | 441 | * Function to initialize a init message for the helper. |
362 | * | 442 | * |
363 | * @param m_char The actual node in a namespace. //TODO Change this to unsigned int | ||
364 | * @param n_char The actual namespace. //TODO Change this to unsigned int | ||
365 | * @param plugin_name Name of the test case plugin the helper will load. | 443 | * @param plugin_name Name of the test case plugin the helper will load. |
366 | * | 444 | * |
367 | */ | 445 | */ |
368 | static struct GNUNET_CMDS_HelperInit * | 446 | static struct GNUNET_CMDS_HelperInit * |
369 | create_helper_init_msg_ (char *m_char, | 447 | create_helper_init_msg_ (const char *plugin_name) |
370 | char *n_char, | ||
371 | const char *plugin_name) | ||
372 | { | 448 | { |
373 | struct GNUNET_CMDS_HelperInit *msg; | 449 | struct GNUNET_CMDS_HelperInit *msg; |
374 | uint16_t plugin_name_len; | 450 | uint16_t plugin_name_len; |
@@ -395,22 +471,49 @@ create_helper_init_msg_ (char *m_char, | |||
395 | static void | 471 | static void |
396 | start_helper (struct NetJailState *ns, struct | 472 | start_helper (struct NetJailState *ns, struct |
397 | GNUNET_CONFIGURATION_Handle *config, | 473 | GNUNET_CONFIGURATION_Handle *config, |
398 | char *m_char, | 474 | unsigned int m, |
399 | char *n_char) | 475 | unsigned int n) |
400 | { | 476 | { |
401 | struct GNUNET_HELPER_Handle *helper; | 477 | struct GNUNET_HELPER_Handle *helper; |
402 | struct GNUNET_CMDS_HelperInit *msg; | 478 | struct GNUNET_CMDS_HelperInit *msg; |
403 | struct TestingSystemCount *tbc; | 479 | struct TestingSystemCount *tbc; |
480 | char *m_char, *n_char, *global_n_char, *local_m_char, *known_char, *node_id, | ||
481 | *plugin; | ||
482 | pid_t pid; | ||
483 | unsigned int script_num; | ||
484 | struct GNUNET_ShortHashCode *hkey; | ||
485 | struct GNUNET_HashCode hc; | ||
486 | struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; | ||
487 | struct GNUNET_TESTING_NetjailNode *node; | ||
488 | struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
489 | |||
490 | |||
491 | if (0 == n) | ||
492 | script_num = m - 1; | ||
493 | else | ||
494 | script_num = n - 1 + (n - 1) * ns->local_m + m + ns->known; | ||
495 | pid = getpid (); | ||
496 | |||
497 | GNUNET_asprintf (&m_char, "%u", m); | ||
498 | GNUNET_asprintf (&n_char, "%u", n); | ||
499 | GNUNET_asprintf (&local_m_char, "%u", ns->local_m); | ||
500 | GNUNET_asprintf (&global_n_char, "%u",ns->global_n); | ||
501 | GNUNET_asprintf (&known_char, "%u",ns->known); | ||
502 | GNUNET_asprintf (&node_id, "%06x-%08x\n", | ||
503 | pid, | ||
504 | script_num); | ||
505 | |||
506 | |||
404 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, | 507 | char *const script_argv[] = {NETJAIL_EXEC_SCRIPT, |
405 | m_char, | 508 | m_char, |
406 | n_char, | 509 | n_char, |
407 | GNUNET_OS_get_libexec_binary_path ( | 510 | GNUNET_OS_get_libexec_binary_path ( |
408 | HELPER_CMDS_BINARY), | 511 | HELPER_CMDS_BINARY), |
409 | ns->global_n, | 512 | global_n_char, |
410 | ns->local_m, | 513 | local_m_char, |
514 | node_id, | ||
411 | NULL}; | 515 | NULL}; |
412 | unsigned int m = atoi (m_char); | 516 | |
413 | unsigned int n = atoi (n_char); | ||
414 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( | 517 | unsigned int helper_check = GNUNET_OS_check_helper_binary ( |
415 | NETJAIL_EXEC_SCRIPT, | 518 | NETJAIL_EXEC_SCRIPT, |
416 | GNUNET_YES, | 519 | GNUNET_YES, |
@@ -418,7 +521,10 @@ start_helper (struct NetJailState *ns, struct | |||
418 | 521 | ||
419 | tbc = GNUNET_new (struct TestingSystemCount); | 522 | tbc = GNUNET_new (struct TestingSystemCount); |
420 | tbc->ns = ns; | 523 | tbc->ns = ns; |
421 | tbc->count = (n - 1) * atoi (ns->local_m) + m; | 524 | if (0 == n) |
525 | tbc->count = m; | ||
526 | else | ||
527 | tbc->count = (n - 1) * ns->local_m + m + ns->known; | ||
422 | 528 | ||
423 | GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, ns->tbcs_tail, | 529 | GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, ns->tbcs_tail, |
424 | tbc); | 530 | tbc); |
@@ -429,14 +535,14 @@ start_helper (struct NetJailState *ns, struct | |||
429 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 535 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
430 | "No SUID for %s!\n", | 536 | "No SUID for %s!\n", |
431 | NETJAIL_EXEC_SCRIPT); | 537 | NETJAIL_EXEC_SCRIPT); |
432 | *ns->rv = 1; | 538 | GNUNET_TESTING_interpreter_fail (ns->ac.is); |
433 | } | 539 | } |
434 | else if (GNUNET_NO == helper_check) | 540 | else if (GNUNET_NO == helper_check) |
435 | { | 541 | { |
436 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 542 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
437 | "%s not found!\n", | 543 | "%s not found!\n", |
438 | NETJAIL_EXEC_SCRIPT); | 544 | NETJAIL_EXEC_SCRIPT); |
439 | *ns->rv = 1; | 545 | GNUNET_TESTING_interpreter_fail (ns->ac.is); |
440 | } | 546 | } |
441 | 547 | ||
442 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( | 548 | GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( |
@@ -449,9 +555,57 @@ start_helper (struct NetJailState *ns, struct | |||
449 | 555 | ||
450 | helper = ns->helper[tbc->count - 1]; | 556 | helper = ns->helper[tbc->count - 1]; |
451 | 557 | ||
452 | msg = create_helper_init_msg_ (m_char, | 558 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
453 | n_char, | 559 | |
454 | ns->plugin_name); | 560 | plugin = topology->plugin; |
561 | |||
562 | if (0 == m) | ||
563 | { | ||
564 | |||
565 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | ||
566 | memcpy (hkey, | ||
567 | &hc, | ||
568 | sizeof (*hkey)); | ||
569 | if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_globals, | ||
570 | hkey)) | ||
571 | { | ||
572 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | ||
573 | hkey); | ||
574 | if (NULL != node->plugin) | ||
575 | plugin = node->plugin; | ||
576 | } | ||
577 | |||
578 | } | ||
579 | else | ||
580 | { | ||
581 | GNUNET_CRYPTO_hash (&m, sizeof(m), &hc); | ||
582 | memcpy (hkey, | ||
583 | &hc, | ||
584 | sizeof (*hkey)); | ||
585 | if (1 == GNUNET_CONTAINER_multishortmap_contains (topology->map_namespaces, | ||
586 | hkey)) | ||
587 | { | ||
588 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | ||
589 | hkey); | ||
590 | GNUNET_CRYPTO_hash (&n, sizeof(n), &hc); | ||
591 | memcpy (hkey, | ||
592 | &hc, | ||
593 | sizeof (*hkey)); | ||
594 | if (1 == GNUNET_CONTAINER_multishortmap_contains (namespace->nodes, | ||
595 | hkey)) | ||
596 | { | ||
597 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | ||
598 | hkey); | ||
599 | if (NULL != node->plugin) | ||
600 | plugin = node->plugin; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | |||
605 | } | ||
606 | |||
607 | msg = create_helper_init_msg_ (plugin); | ||
608 | |||
455 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); | 609 | GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); |
456 | 610 | ||
457 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( | 611 | GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( |
@@ -466,7 +620,7 @@ start_helper (struct NetJailState *ns, struct | |||
466 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 620 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
467 | "Send handle is NULL!\n"); | 621 | "Send handle is NULL!\n"); |
468 | GNUNET_free (msg); | 622 | GNUNET_free (msg); |
469 | *ns->rv = 1; | 623 | GNUNET_TESTING_interpreter_fail (ns->ac.is); |
470 | } | 624 | } |
471 | } | 625 | } |
472 | 626 | ||
@@ -480,95 +634,28 @@ start_helper (struct NetJailState *ns, struct | |||
480 | */ | 634 | */ |
481 | static void | 635 | static void |
482 | netjail_exec_run (void *cls, | 636 | netjail_exec_run (void *cls, |
483 | const struct GNUNET_TESTING_Command *cmd, | ||
484 | struct GNUNET_TESTING_Interpreter *is) | 637 | struct GNUNET_TESTING_Interpreter *is) |
485 | { | 638 | { |
486 | char str_m[12]; | ||
487 | char str_n[12]; | ||
488 | struct NetJailState *ns = cls; | 639 | struct NetJailState *ns = cls; |
489 | struct GNUNET_CONFIGURATION_Handle *config = | 640 | struct GNUNET_CONFIGURATION_Handle *config = |
490 | GNUNET_CONFIGURATION_create (); | 641 | GNUNET_CONFIGURATION_create (); |
491 | 642 | ||
492 | for (int i = 1; i <= atoi (ns->global_n); i++) | 643 | for (int i = 1; i <= ns->known; i++) |
493 | { | 644 | { |
494 | for (int j = 1; j <= atoi (ns->local_m); j++) | 645 | start_helper (ns, config, |
495 | { | 646 | i, |
496 | sprintf (str_n, "%d", i); | 647 | 0); |
497 | sprintf (str_m, "%d", j); | ||
498 | start_helper (ns, config, | ||
499 | str_m, | ||
500 | str_n); | ||
501 | } | ||
502 | } | 648 | } |
503 | } | ||
504 | 649 | ||
505 | 650 | for (int i = 1; i <= ns->global_n; i++) | |
506 | /** | ||
507 | * This function checks on three different information. | ||
508 | * | ||
509 | * 1. Did all helpers start. This is only logged. | ||
510 | * 2. Did all peer start. | ||
511 | * In this case a GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED is send to all peers. | ||
512 | * 3. Did all peers finished the test case. In this case interpreter_next will be called. | ||
513 | * | ||
514 | */ | ||
515 | static int | ||
516 | netjail_start_finish (void *cls, | ||
517 | GNUNET_SCHEDULER_TaskCallback cont, | ||
518 | void *cont_cls) | ||
519 | { | ||
520 | unsigned int ret = GNUNET_NO; | ||
521 | struct NetJailState *ns = cls; | ||
522 | unsigned int total_number = atoi (ns->local_m) * atoi (ns->global_n); | ||
523 | struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; | ||
524 | size_t msg_length; | ||
525 | struct GNUNET_HELPER_Handle *helper; | ||
526 | struct TestingSystemCount *tbc; | ||
527 | |||
528 | if (ns->number_of_local_test_finished == total_number) | ||
529 | { | ||
530 | ret = GNUNET_YES; | ||
531 | cont (cont_cls); | ||
532 | } | ||
533 | |||
534 | if (ns->number_of_testsystems_started == total_number) | ||
535 | { | ||
536 | ns->number_of_testsystems_started = 0; | ||
537 | } | ||
538 | |||
539 | if (ns->number_of_peers_started == total_number) | ||
540 | { | 651 | { |
541 | for (int i = 1; i <= atoi (ns->global_n); i++) | 652 | for (int j = 1; j <= ns->local_m; j++) |
542 | { | 653 | { |
543 | for (int j = 1; j <= atoi (ns->local_m); j++) | 654 | start_helper (ns, config, |
544 | { | 655 | j, |
545 | tbc = GNUNET_new (struct TestingSystemCount); | 656 | i); |
546 | tbc->ns = ns; | ||
547 | // TODO This needs to be more generic. As we send more messages back and forth, we can not grow the arrays again and again, because this is to error prone. | ||
548 | tbc->count = (i - 1) * atoi (ns->local_m) + j + total_number; | ||
549 | |||
550 | helper = ns->helper[tbc->count - 1 - total_number]; | ||
551 | msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
552 | reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); | ||
553 | reply->header.type = htons ( | ||
554 | GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); | ||
555 | reply->header.size = htons ((uint16_t) msg_length); | ||
556 | |||
557 | GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); | ||
558 | |||
559 | struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( | ||
560 | helper, | ||
561 | &reply->header, | ||
562 | GNUNET_NO, | ||
563 | &clear_msg, | ||
564 | tbc); | ||
565 | |||
566 | GNUNET_array_append (ns->shandle, ns->n_shandle, sh); | ||
567 | } | ||
568 | } | 657 | } |
569 | ns->number_of_peers_started = 0; | ||
570 | } | 658 | } |
571 | return ret; | ||
572 | } | 659 | } |
573 | 660 | ||
574 | 661 | ||
@@ -576,32 +663,30 @@ netjail_start_finish (void *cls, | |||
576 | * Create command. | 663 | * Create command. |
577 | * | 664 | * |
578 | * @param label Name for the command. | 665 | * @param label Name for the command. |
579 | * @param local_m Number of nodes in a network namespace. //TODO make this a unsigned int | 666 | * @param topology_config Configuration file for the test topology. |
580 | * @param global_n Number of network namespaces. //TODO make this a unsigned int | ||
581 | * @param plugin_name Name of the test case plugin the helper will load. | ||
582 | * @param rv Pointer to the return value of the test. | ||
583 | * @return command. | 667 | * @return command. |
584 | */ | 668 | */ |
585 | struct GNUNET_TESTING_Command | 669 | struct GNUNET_TESTING_Command |
586 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, | 670 | GNUNET_TESTING_cmd_netjail_start_testing_system (const char *label, |
587 | char *local_m, | 671 | const char *topology_config) |
588 | char *global_n, | ||
589 | char *plugin_name, | ||
590 | unsigned int *rv) | ||
591 | { | 672 | { |
592 | struct NetJailState *ns; | 673 | struct NetJailState *ns; |
593 | 674 | ||
675 | struct GNUNET_TESTING_NetjailTopology *topology = | ||
676 | GNUNET_TESTING_get_topo_from_file (topology_config); | ||
677 | |||
594 | ns = GNUNET_new (struct NetJailState); | 678 | ns = GNUNET_new (struct NetJailState); |
595 | ns->local_m = local_m; | 679 | ns->local_m = topology->nodes_m; |
596 | ns->global_n = global_n; | 680 | ns->global_n = topology->namespaces_n; |
597 | ns->plugin_name = plugin_name; | 681 | ns->known = topology->nodes_x; |
598 | ns->rv = rv; | 682 | ns->plugin_name = topology->plugin; |
683 | ns->topology = topology; | ||
599 | 684 | ||
600 | struct GNUNET_TESTING_Command cmd = { | 685 | struct GNUNET_TESTING_Command cmd = { |
601 | .cls = ns, | 686 | .cls = ns, |
602 | .label = label, | 687 | .label = label, |
603 | .run = &netjail_exec_run, | 688 | .run = &netjail_exec_run, |
604 | .finish = &netjail_start_finish, | 689 | .ac = &ns->ac, |
605 | .cleanup = &netjail_exec_cleanup, | 690 | .cleanup = &netjail_exec_cleanup, |
606 | .traits = &netjail_exec_traits | 691 | .traits = &netjail_exec_traits |
607 | }; | 692 | }; |