From d7fa0579995790840199ec86cb4d518f9d372fcd Mon Sep 17 00:00:00 2001 From: t3sserakt Date: Thu, 7 Oct 2021 13:07:30 +0200 Subject: - add generic topology configuration by file - cmd simple send using file configuration from file - added cmd to check the logs for backchannel encapsulation - added cmd which notifies the master loop of local loop being prepared to finish - added logging to helper.c - moved code from connecting peers cmd into global functions - added parameters given to the connecting peers cmd - added assertion when notifying the transport service about a new queue, if the communicator has no intial capacity - added optional valgrind cmd to test script - added flag für queues with unlimited length - added check for queues with higher priority - added attribute queue_capacity to struct Queue - bug fixing worker task for kce generation and transport notification about available queue in udp communicator - change value for unlimited queue length from 0 to UINT16_MAX in tcp communicator and service - added loop to stop the test system for the globally known peers in stop testsystem cmd - refactored endless growing array to handle further messages from the local loops, and added logic to handle the local test prepare msg - added utility methods in testing.c - added forwarding of all tests prepared msg in gnunet-cmds-helper.c - added cmd to end loop without shutdown - added without shutdown cmd to simple send testcase - added backchannel check, without shutdown and prepared cmd to udp backchannel testcase. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../testing_api_cmd_netjail_start_testsystem_v2.c | 181 +++++++++++++++------ 1 file changed, 135 insertions(+), 46 deletions(-) (limited to 'src/testing/testing_api_cmd_netjail_start_testsystem_v2.c') diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c b/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c index ccb3f5ae8..5e27a7a82 100644 --- a/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c +++ b/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c @@ -29,6 +29,11 @@ #define NETJAIL_EXEC_SCRIPT "./../testing/netjail_exec_v2.sh" +/** + * Generic logging shortcut + */ +#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) + /** * Struct to store messages send/received by the helper into a DLL * @@ -116,13 +121,13 @@ struct NetJailState /** * The send handle for the helper */ - struct GNUNET_HELPER_SendHandle **shandle; + // struct GNUNET_HELPER_SendHandle **shandle; /** * Size of the array NetJailState#shandle. * */ - unsigned int n_shandle; + // unsigned int n_shandle; /** * The messages send to the helper. @@ -151,7 +156,13 @@ struct NetJailState * Number of local tests finished. * */ - unsigned int number_of_local_test_finished; + unsigned int number_of_local_tests_finished; + + /** + * Number of local tests prepared to finish. + * + */ + unsigned int number_of_local_tests_prepared; /** * Name of the test case plugin the helper will load. @@ -188,6 +199,17 @@ struct TestingSystemCount */ struct TestingSystemCount *prev; + /** + * The send handle for the helper + */ + struct GNUNET_HELPER_SendHandle *shandle;// **shandle; + + /** + * Size of the array NetJailState#shandle. + * + */ + // unsigned int n_shandle; + /** * The number of the test environment. * @@ -277,10 +299,9 @@ netjail_exec_traits (void *cls, * @return #GNUNET_OK on success. */ int -GNUNET_TESTING_get_trait_helper_handles_v2 (const struct - GNUNET_TESTING_Command *cmd, - struct GNUNET_HELPER_Handle *** - helper) +GNUNET_TESTING_get_trait_helper_handles_v2 ( + const struct GNUNET_TESTING_Command *cmd, + struct GNUNET_HELPER_Handle ***helper) { return cmd->traits (cmd->cls, (const void **) helper, @@ -293,18 +314,19 @@ GNUNET_TESTING_get_trait_helper_handles_v2 (const struct * Continuation function from GNUNET_HELPER_send() * * @param cls closure - * @param result GNUNET_OK on success, - * GNUNET_NO if helper process died - * GNUNET_SYSERR during GNUNET_HELPER_stop + * @param result #GNUNET_OK on success, + * #GNUNET_NO if helper process died + * #GNUNET_SYSERR during GNUNET_HELPER_stop */ static void -clear_msg (void *cls, int result) +clear_msg (void *cls, + int result) { struct TestingSystemCount *tbc = cls; struct NetJailState *ns = tbc->ns; - GNUNET_assert (NULL != ns->shandle[tbc->count - 1]); - ns->shandle[tbc->count - 1] = NULL; + GNUNET_assert (NULL != tbc->shandle);// [tbc->count - 1]); + tbc->shandle = NULL;// [tbc->count - 1] = NULL; GNUNET_free (ns->msg[tbc->count - 1]); ns->msg[tbc->count - 1] = NULL; } @@ -323,10 +345,11 @@ clear_msg (void *cls, int result) * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing */ static int -helper_mst (void *cls, const struct GNUNET_MessageHeader *message) +helper_mst (void *cls, + const struct GNUNET_MessageHeader *message) { - struct TestingSystemCount *tbc = cls; - struct NetJailState *ns = tbc->ns; + // struct TestingSystemCount *tbc = cls; + struct NetJailState *ns = cls;// tbc->ns; struct HelperMessage *hp_msg; if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY == ntohs (message->type)) @@ -338,10 +361,18 @@ helper_mst (void *cls, const struct GNUNET_MessageHeader *message) { ns->number_of_peers_started++; } + else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED == ntohs ( + message->type)) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "received prepare msg %u\n", + ns->number_of_local_tests_prepared); + ns->number_of_local_tests_prepared++; + } else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED == ntohs ( message->type)) { - ns->number_of_local_test_finished++; + ns->number_of_local_tests_finished++; } else { @@ -364,8 +395,10 @@ static void exp_cb (void *cls) { struct NetJailState *ns = cls; + unsigned int *rv = ns->rv; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Called exp_cb.\n"); - *ns->rv = 1; + *rv = 1; } @@ -420,6 +453,7 @@ start_helper (struct NetJailState *ns, struct struct GNUNET_TESTING_NetjailTopology *topology = ns->topology; struct GNUNET_TESTING_NetjailNode *node; struct GNUNET_TESTING_NetjailNamespace *namespace; + unsigned int *rv = ns->rv; if (0 == n) @@ -460,7 +494,8 @@ start_helper (struct NetJailState *ns, struct else tbc->count = (n - 1) * ns->local_m + m + ns->known; - GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, ns->tbcs_tail, + GNUNET_CONTAINER_DLL_insert (ns->tbcs_head, + ns->tbcs_tail, tbc); @@ -469,14 +504,14 @@ start_helper (struct NetJailState *ns, struct GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No SUID for %s!\n", NETJAIL_EXEC_SCRIPT); - *ns->rv = 1; + *rv = 1; } else if (GNUNET_NO == helper_check) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s not found!\n", NETJAIL_EXEC_SCRIPT); - *ns->rv = 1; + *rv = 1; } GNUNET_array_append (ns->helper, ns->n_helper, GNUNET_HELPER_start ( @@ -485,7 +520,7 @@ start_helper (struct NetJailState *ns, struct script_argv, &helper_mst, &exp_cb, - tbc)); + ns)); helper = ns->helper[tbc->count - 1]; @@ -542,19 +577,20 @@ start_helper (struct NetJailState *ns, struct GNUNET_array_append (ns->msg, ns->n_msg, &msg->header); - GNUNET_array_append (ns->shandle, ns->n_shandle, GNUNET_HELPER_send ( - helper, - &msg->header, - GNUNET_NO, - &clear_msg, - tbc)); + // GNUNET_array_append (tbc->shandle, tbc->n_shandle, + tbc->shandle = GNUNET_HELPER_send ( + helper, + &msg->header, + GNUNET_NO, + &clear_msg, + tbc); // ); - if (NULL == ns->shandle[tbc->count - 1]) + if (NULL == tbc->shandle)// [tbc->count - 1]) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Send handle is NULL!\n"); GNUNET_free (msg); - *ns->rv = 1; + *rv = 1; } } @@ -595,39 +631,76 @@ netjail_exec_run (void *cls, static void -send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) +send_message_to_locals ( + unsigned int i, + unsigned int j, + struct NetJailState *ns, + struct GNUNET_MessageHeader *header + ) { - unsigned int total_number = ns->local_m * ns->global_n + ns->known; - struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; - size_t msg_length; + // unsigned int total_number = ns->local_m * ns->global_n + ns->known; struct GNUNET_HELPER_Handle *helper; struct TestingSystemCount *tbc; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "send message to locals\n"); tbc = GNUNET_new (struct TestingSystemCount); tbc->ns = ns; // 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. if (0 == i) - tbc->count = j + total_number; + tbc->count = j; // + total_number; else - tbc->count = (i - 1) * ns->local_m + j + total_number + ns->known; + tbc->count = (i - 1) * ns->local_m + j + ns->known; // + total_number ; - helper = ns->helper[tbc->count - 1 - total_number]; - msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); - reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); - reply->header.type = htons ( - GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); - reply->header.size = htons ((uint16_t) msg_length); + helper = ns->helper[tbc->count - 1];// - total_number]; - GNUNET_array_append (ns->msg, ns->n_msg, &reply->header); + GNUNET_array_append (ns->msg, ns->n_msg, header); struct GNUNET_HELPER_SendHandle *sh = GNUNET_HELPER_send ( helper, - &reply->header, + header, GNUNET_NO, &clear_msg, tbc); - GNUNET_array_append (ns->shandle, ns->n_shandle, sh); + tbc->shandle = sh; + // GNUNET_array_append (tbc->shandle, tbc->n_shandle, sh); +} + + +static void +send_all_local_tests_prepared (unsigned int i, unsigned int j, struct + NetJailState *ns) +{ + struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED *reply; + size_t msg_length; + + + msg_length = sizeof(struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED); + reply = GNUNET_new (struct GNUNET_CMDS_ALL_LOCAL_TESTS_PREPARED); + reply->header.type = htons ( + GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED); + reply->header.size = htons ((uint16_t) msg_length); + + send_message_to_locals (i, j, ns, &reply->header); +} + + +static void +send_all_peers_started (unsigned int i, unsigned int j, struct NetJailState *ns) +{ + + struct GNUNET_CMDS_ALL_PEERS_STARTED *reply; + size_t msg_length; + + + msg_length = sizeof(struct GNUNET_CMDS_ALL_PEERS_STARTED); + reply = GNUNET_new (struct GNUNET_CMDS_ALL_PEERS_STARTED); + reply->header.type = htons ( + GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED); + reply->header.size = htons ((uint16_t) msg_length); + + send_message_to_locals (i, j, ns, &reply->header); } @@ -650,12 +723,28 @@ netjail_start_finish (void *cls, unsigned int total_number = ns->local_m * ns->global_n + ns->known; - if (ns->number_of_local_test_finished == total_number) + if (ns->number_of_local_tests_finished == total_number) { ret = GNUNET_YES; cont (cont_cls); } + if (ns->number_of_local_tests_prepared == total_number) + { + for (int i = 1; i <= ns->known; i++) + { + send_all_local_tests_prepared (0,i, ns); + } + + for (int i = 1; i <= ns->global_n; i++) + { + for (int j = 1; j <= ns->local_m; j++) + { + send_all_local_tests_prepared (i,j, ns); + } + } + } + if (ns->number_of_testsystems_started == total_number) { ns->number_of_testsystems_started = 0; -- cgit v1.2.3