aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_netjail_start_testsystem.c
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-10-28 16:13:47 +0200
committert3sserakt <t3ss@posteo.de>2021-10-28 16:13:47 +0200
commit6fb788ca2ec44837ea10a36be7fd0030fb08955b (patch)
treecba4a385aa8ab914d02db9a702f6c6230aa89a2a /src/testing/testing_api_cmd_netjail_start_testsystem.c
parent1609d627e509043a946f611d7589105cfae2364d (diff)
downloadgnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.tar.gz
gnunet-6fb788ca2ec44837ea10a36be7fd0030fb08955b.zip
- fixed coverity issues
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_start_testsystem.c')
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c109
1 files changed, 81 insertions, 28 deletions
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 9b567a01f..c3598d174 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -67,6 +67,12 @@ struct HelperMessage
67struct NetJailState 67struct NetJailState
68{ 68{
69 /** 69 /**
70 * Global state of the interpreter, used by a command
71 * to access information about other commands.
72 */
73 struct GNUNET_TESTING_Interpreter *is;
74
75 /**
70 * Context for our asynchronous completion. 76 * Context for our asynchronous completion.
71 */ 77 */
72 struct GNUNET_TESTING_AsyncContext ac; 78 struct GNUNET_TESTING_AsyncContext ac;
@@ -77,12 +83,6 @@ struct NetJailState
77 struct GNUNET_TESTING_NetjailTopology *topology; 83 struct GNUNET_TESTING_NetjailTopology *topology;
78 84
79 /** 85 /**
80 * Pointer to the return value of the test.
81 *
82 */
83 unsigned int *rv;
84
85 /**
86 * Head of the DLL which stores messages received by the helper. 86 * Head of the DLL which stores messages received by the helper.
87 * 87 *
88 */ 88 */
@@ -254,6 +254,7 @@ netjail_exec_cleanup (void *cls)
254 tbc_pos); 254 tbc_pos);
255 GNUNET_free (tbc_pos); 255 GNUNET_free (tbc_pos);
256 } 256 }
257 GNUNET_TESTING_free_topology (ns->topology);
257 GNUNET_free (ns); 258 GNUNET_free (ns);
258} 259}
259 260
@@ -429,18 +430,63 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
429 struct NetJailState *ns = cls;// tbc->ns; 430 struct NetJailState *ns = cls;// tbc->ns;
430 struct HelperMessage *hp_msg; 431 struct HelperMessage *hp_msg;
431 unsigned int total_number = ns->local_m * ns->global_n + ns->known; 432 unsigned int total_number = ns->local_m * ns->global_n + ns->known;
433 // uint16_t message_type = ntohs (message->type);
432 434
433 LOG (GNUNET_ERROR_TYPE_DEBUG, 435 /*switch (message_type)
434 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n", 436 {
435 total_number, 437 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY:
436 ns->number_of_testsystems_started, 438 ns->number_of_testsystems_started++;
437 ns->number_of_peers_started, 439 break;
438 ns->number_of_local_tests_prepared, 440 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_PEER_STARTED:
439 ns->number_of_local_tests_finished, 441 ns->number_of_peers_started++;
440 ns->local_m, 442 if (ns->number_of_peers_started == total_number)
441 ns->global_n, 443 {
442 ns->known); 444 for (int i = 1; i <= ns->known; i++)
445 {
446 send_all_peers_started (0,i, ns);
447 }
448 for (int i = 1; i <= ns->global_n; i++)
449 {
450 for (int j = 1; j <= ns->local_m; j++)
451 {
452 send_all_peers_started (i,j, ns);
453 }
454 }
455 ns->number_of_peers_started = 0;
456 }
457 break;
458 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED:
459 ns->number_of_local_tests_prepared++;
460 if (ns->number_of_local_tests_prepared == total_number)
461 {
462 for (int i = 1; i <= ns->known; i++)
463 {
464 send_all_local_tests_prepared (0,i, ns);
465 }
443 466
467 for (int i = 1; i <= ns->global_n; i++)
468 {
469 for (int j = 1; j <= ns->local_m; j++)
470 {
471 send_all_local_tests_prepared (i,j, ns);
472 }
473 }
474 }
475 break;
476 case GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED:
477 ns->number_of_local_tests_finished++;
478 if (ns->number_of_local_tests_finished == total_number)
479 {
480 GNUNET_TESTING_async_finish (&ns->ac);
481 }
482 break;
483 default:
484 hp_msg = GNUNET_new (struct HelperMessage);
485 hp_msg->bytes_msg = message->size;
486 memcpy (&hp_msg[1], message, message->size);
487 GNUNET_CONTAINER_DLL_insert (ns->hp_messages_head, ns->hp_messages_tail,
488 hp_msg);
489 }*/
444 if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) 490 if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type))
445 { 491 {
446 ns->number_of_testsystems_started++; 492 ns->number_of_testsystems_started++;
@@ -505,7 +551,16 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message)
505 } 551 }
506 552
507 553
508 554 LOG (GNUNET_ERROR_TYPE_DEBUG,
555 "total %u sysstarted %u peersstarted %u prep %u finished %u %u %u %u\n",
556 total_number,
557 ns->number_of_testsystems_started,
558 ns->number_of_peers_started,
559 ns->number_of_local_tests_prepared,
560 ns->number_of_local_tests_finished,
561 ns->local_m,
562 ns->global_n,
563 ns->known);
509 564
510 565
511 566
@@ -524,7 +579,7 @@ exp_cb (void *cls)
524 struct TestingSystemCount *tbc = cls; 579 struct TestingSystemCount *tbc = cls;
525 580
526 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); 581 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n");
527 GNUNET_TESTING_interpreter_fail (tbc->ns->ac.is); 582 GNUNET_TESTING_async_fail (&(tbc->ns->ac));
528} 583}
529 584
530 585
@@ -560,8 +615,7 @@ create_helper_init_msg_ (const char *plugin_name)
560 * 615 *
561 */ 616 */
562static void 617static void
563start_helper (struct NetJailState *ns, struct 618start_helper (struct NetJailState *ns,
564 GNUNET_CONFIGURATION_Handle *config,
565 unsigned int m, 619 unsigned int m,
566 unsigned int n) 620 unsigned int n)
567{ 621{
@@ -582,7 +636,6 @@ start_helper (struct NetJailState *ns, struct
582 struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; 636 struct GNUNET_TESTING_NetjailTopology *topology = ns->topology;
583 struct GNUNET_TESTING_NetjailNode *node; 637 struct GNUNET_TESTING_NetjailNode *node;
584 struct GNUNET_TESTING_NetjailNamespace *namespace; 638 struct GNUNET_TESTING_NetjailNamespace *namespace;
585 unsigned int *rv = ns->rv;
586 639
587 640
588 if (0 == n) 641 if (0 == n)
@@ -633,14 +686,14 @@ start_helper (struct NetJailState *ns, struct
633 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 686 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
634 "No SUID for %s!\n", 687 "No SUID for %s!\n",
635 NETJAIL_EXEC_SCRIPT); 688 NETJAIL_EXEC_SCRIPT);
636 *rv = 1; 689 GNUNET_TESTING_interpreter_fail (ns->is);
637 } 690 }
638 else if (GNUNET_NO == helper_check) 691 else if (GNUNET_NO == helper_check)
639 { 692 {
640 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 693 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
641 "%s not found!\n", 694 "%s not found!\n",
642 NETJAIL_EXEC_SCRIPT); 695 NETJAIL_EXEC_SCRIPT);
643 *rv = 1; 696 GNUNET_TESTING_interpreter_fail (ns->is);
644 } 697 }
645 698
646 LOG (GNUNET_ERROR_TYPE_DEBUG, 699 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -729,8 +782,9 @@ start_helper (struct NetJailState *ns, struct
729 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 782 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
730 "Send handle is NULL!\n"); 783 "Send handle is NULL!\n");
731 GNUNET_free (msg); 784 GNUNET_free (msg);
732 *rv = 1; 785 GNUNET_TESTING_interpreter_fail (ns->is);
733 } 786 }
787 GNUNET_free (hkey);
734} 788}
735 789
736 790
@@ -746,12 +800,11 @@ netjail_exec_run (void *cls,
746 struct GNUNET_TESTING_Interpreter *is) 800 struct GNUNET_TESTING_Interpreter *is)
747{ 801{
748 struct NetJailState *ns = cls; 802 struct NetJailState *ns = cls;
749 struct GNUNET_CONFIGURATION_Handle *config =
750 GNUNET_CONFIGURATION_create ();
751 803
804 ns->is = is;
752 for (int i = 1; i <= ns->known; i++) 805 for (int i = 1; i <= ns->known; i++)
753 { 806 {
754 start_helper (ns, config, 807 start_helper (ns,
755 i, 808 i,
756 0); 809 0);
757 } 810 }
@@ -760,7 +813,7 @@ netjail_exec_run (void *cls,
760 { 813 {
761 for (int j = 1; j <= ns->local_m; j++) 814 for (int j = 1; j <= ns->local_m; j++)
762 { 815 {
763 start_helper (ns, config, 816 start_helper (ns,
764 j, 817 j,
765 i); 818 i);
766 } 819 }