From 6a043a9228022fcce97fd50739db74abdabde055 Mon Sep 17 00:00:00 2001 From: t3sserakt Date: Fri, 19 Nov 2021 15:18:24 +0100 Subject: - Fixed header, fixed log level, changed block until connect logic, fixed memory issues. --- src/testing/gnunet-cmds-helper.c | 6 +- src/testing/testing.c | 93 +++++++++-------- .../testing_api_cmd_block_until_external_trigger.c | 61 +++++++---- src/testing/testing_api_cmd_netjail_start.c | 4 + src/testing/testing_api_cmd_netjail_stop.c | 1 + src/testing/testing_api_loop.c | 116 +++++++++++++++++++-- 6 files changed, 208 insertions(+), 73 deletions(-) (limited to 'src/testing') diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c index f90cc3cc4..5ff7c04ea 100644 --- a/src/testing/gnunet-cmds-helper.c +++ b/src/testing/gnunet-cmds-helper.c @@ -415,8 +415,6 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) plugin->n, plugin->local_m, ni->topology_data, ni->read_file); - GNUNET_free (binary); - msg_length = sizeof(struct GNUNET_CMDS_HelperReply); reply = GNUNET_new (struct GNUNET_CMDS_HelperReply); reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_REPLY); @@ -424,6 +422,10 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message) write_message ((struct GNUNET_MessageHeader *) reply, msg_length); + GNUNET_free (binary); + GNUNET_free (router_ip); + GNUNET_free (plugin_name); + return GNUNET_OK; } else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( diff --git a/src/testing/testing.c b/src/testing/testing.c index ced04e65d..9e664292b 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -1838,7 +1838,7 @@ get_first_string_value (char *line) memcpy (copy, line, slen); token = strtok_r (copy, ":", &rest); token = strtok_r (NULL, ":", &rest); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "first token %s\n", token); slen_token = strlen (token); @@ -1924,7 +1924,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) node_connection->node_type = GNUNET_TESTING_GLOBAL_NODE; token = strtok_r (NULL, ":", &rest); GNUNET_assert (1 == sscanf (token, "%u", &node_n)); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "node_n %u\n", node_n); node_connection->node_n = node_n; @@ -1939,7 +1939,7 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) token = strtok_r (NULL, ":", &rest); sscanf (token, "%u", &node_n); node_connection->node_n = node_n; - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "node_n %u namespace_n %u node->node_n %u node->namespace_n %u\n", node_n, namespace_n, @@ -1963,14 +1963,14 @@ get_connect_value (char *line, struct GNUNET_TESTING_NetjailNode *node) memcpy (prefix->address_prefix, token, slen); } - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "address_prefix %s\n", prefix->address_prefix); GNUNET_CONTAINER_DLL_insert (node_connection->address_prefixes_head, node_connection->address_prefixes_tail, prefix); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "address_prefix %s\n", prefix->address_prefix); } @@ -2028,7 +2028,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) struct GNUNET_TESTING_NodeConnection *pos_connection; struct GNUNET_TESTING_AddressPrefix *pos_prefix; - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "plugin: %s space: %u node: %u global: %u\n", node->plugin, node->namespace_n, @@ -2039,7 +2039,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) pos_connection = pos_connection->next) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "namespace_n: %u node_n: %u node_type: %u\n", pos_connection->namespace_n, pos_connection->node_n, @@ -2049,7 +2049,7 @@ log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) pos_prefix = pos_prefix->next) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "prefix: %s\n", pos_prefix->address_prefix); } @@ -2071,7 +2071,7 @@ log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) static int log_topo (struct GNUNET_TESTING_NetjailTopology *topology) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "plugin: %s spaces: %u nodes: %u known: %u\n", topology->plugin, topology->namespaces_n, @@ -2218,6 +2218,8 @@ free_nodes_cb (void *cls, GNUNET_free (pos_connection); pos_connection = tmp_connection; } + GNUNET_free (node->plugin); + GNUNET_free (node); return GNUNET_OK; } @@ -2248,8 +2250,11 @@ GNUNET_TESTING_free_topology (struct GNUNET_TESTING_NetjailTopology *topology) { GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, free_namespaces_cb, NULL); + GNUNET_CONTAINER_multishortmap_destroy (topology->map_namespaces); GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, free_nodes_cb, NULL); + GNUNET_CONTAINER_multishortmap_destroy (topology->map_globals); + GNUNET_free (topology->plugin); GNUNET_free (topology); } @@ -2294,7 +2299,7 @@ GNUNET_TESTING_get_address (struct GNUNET_TESTING_NodeConnection *connection, char *addr; char *template; - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "node_n: %u\n", connection->node_n); @@ -2374,7 +2379,7 @@ GNUNET_TESTING_get_topo_from_string (char *data) char *key = NULL; unsigned int out; char *rest = NULL; - char *value; + char *value = NULL; char *value2; int ret; struct GNUNET_TESTING_NetjailTopology *topo; @@ -2384,9 +2389,6 @@ GNUNET_TESTING_get_topo_from_string (char *data) struct GNUNET_ShortHashCode *hkey; struct GNUNET_HashCode hc; - LOG (GNUNET_ERROR_TYPE_DEBUG, - "data %s\n", - data); token = strtok_r (data, "\n", &rest); topo = GNUNET_new (struct GNUNET_TESTING_NetjailTopology); topo->map_namespaces = @@ -2399,46 +2401,46 @@ GNUNET_TESTING_get_topo_from_string (char *data) if (NULL != key) free (key); key = get_key (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "In the loop with token: %s beginning with %s\n", token, key); if (0 == strcmp (key, "M")) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get first Value for M.\n"); out = get_first_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "M: %u\n", out); topo->nodes_m = out; } else if (0 == strcmp (key, "N")) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get first Value for N.\n"); out = get_first_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "N: %u\n", out); topo->namespaces_n = out; } else if (0 == strcmp (key, "X")) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get first Value for X.\n"); out = get_first_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "X: %u\n", out); topo->nodes_x = out; } else if (0 == strcmp (key, "T")) { - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get first string value for T.\n"); value = get_first_string_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "value: %s\n", value); topo->plugin = value; @@ -2448,10 +2450,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) hkey = GNUNET_new (struct GNUNET_ShortHashCode); node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get first Value for K.\n"); out = get_first_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "K: %u\n", out); node->node_n = out; @@ -2470,10 +2472,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) hkey, node, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get value for key value on K.\n"); value = get_value ("plugin", token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "value: %s\n", value); node->plugin = value; @@ -2485,10 +2487,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) router = GNUNET_new (struct GNUNET_TESTING_NetjailRouter); node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get first Value for R.\n"); out = get_first_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "R: %u\n", out); node->node_n = out; @@ -2496,22 +2498,22 @@ GNUNET_TESTING_get_topo_from_string (char *data) memcpy (hkey, &hc, sizeof (*hkey)); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get value for key tcp_port on R.\n"); value = get_value ("tcp_port", token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "tcp_port: %s\n", value); ret = sscanf (value, "%u", &(router->tcp_port)); GNUNET_break (0 != ret && 1 >= router->tcp_port); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get value for key udp_port on R.\n"); value2 = get_value ("udp_port", token); ret = sscanf (value2, "%u", &(router->udp_port)); GNUNET_break (0 != ret && 1 >= router->udp_port); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "udp_port: %s\n", value2); @@ -2540,10 +2542,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) hkey = GNUNET_new (struct GNUNET_ShortHashCode); node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get first Value for P.\n"); out = get_first_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "P: %u\n", out); GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); @@ -2568,10 +2570,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) namespace, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); } - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get second Value for P.\n"); out = get_second_value (token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "P: %u\n", out); GNUNET_CRYPTO_hash (&out, sizeof(out), &hc); @@ -2591,10 +2593,10 @@ GNUNET_TESTING_get_topo_from_string (char *data) hkey, node, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Get value for key plugin on P.\n"); value = get_value ("plugin", token); - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "plugin: %s\n", value); node->plugin = value; @@ -2605,10 +2607,14 @@ GNUNET_TESTING_get_topo_from_string (char *data) } token = strtok_r (NULL, "\n", &rest); if (NULL != token) - LOG (GNUNET_ERROR_TYPE_ERROR, + LOG (GNUNET_ERROR_TYPE_DEBUG, "Next token %s\n", token); } + if (NULL != key) + GNUNET_free (key); + /*if (NULL != value) + GNUNET_free (value);*/ return topo; } @@ -2642,7 +2648,7 @@ GNUNET_TESTING_get_topo_from_file (const char *filename) filename); return NULL; } - data = GNUNET_malloc (fs); + data = GNUNET_malloc (fs + 1); if (fs != GNUNET_DISK_fn_read (filename, data, fs)) { LOG (GNUNET_ERROR_TYPE_ERROR, @@ -2653,9 +2659,8 @@ GNUNET_TESTING_get_topo_from_file (const char *filename) } LOG (GNUNET_ERROR_TYPE_DEBUG, - "data: %s\n", - data); - + "file lenght %lu\n", + fs); data[fs] = '\0'; topo = GNUNET_TESTING_get_topo_from_string (data); diff --git a/src/testing/testing_api_cmd_block_until_external_trigger.c b/src/testing/testing_api_cmd_block_until_external_trigger.c index 7ff554280..9360dd02e 100644 --- a/src/testing/testing_api_cmd_block_until_external_trigger.c +++ b/src/testing/testing_api_cmd_block_until_external_trigger.c @@ -33,23 +33,6 @@ */ #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) -/** - * Struct with information for callbacks. - * - */ -struct BlockState -{ - /** - * Context for our asynchronous completion. - */ - struct GNUNET_TESTING_AsyncContext ac; - - /** - * The label of this command. - */ - const char *label; -}; - /** * The cleanup function of this cmd frees resources the cmd allocated. @@ -77,6 +60,11 @@ block_until_external_trigger_traits (void *cls, .trait_name = "async_context", .ptr = (const void *) ac, }, + { + .index = 1, + .trait_name = "block_state", + .ptr = (const void *) bs, + }, GNUNET_TESTING_trait_end () }; @@ -87,10 +75,28 @@ block_until_external_trigger_traits (void *cls, } +/** + * Function to get the trait with the internal command state BlockState. + * + * * @param[out] ac struct BlockState. +* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. + */ +int +GNUNET_TESTING_get_trait_block_state ( + const struct GNUNET_TESTING_Command *cmd, + struct BlockState **bs) +{ + return cmd->traits (cmd->cls, + (const void **) bs, + "block_state", + (unsigned int) 1); +} + + /** * Function to get the trait with the async context. * - * @param[out] ac GNUNET_TESTING_AsyncContext. + * @param[out] ac struct GNUNET_TESTING_AsyncContext. * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. */ int @@ -114,10 +120,20 @@ block_until_all_peers_started_run (void *cls, struct GNUNET_TESTING_Interpreter *is) { struct BlockState *bs = cls; + struct GNUNET_TESTING_Command *cmd = + GNUNET_TESTING_interpreter_get_current_command (is); LOG (GNUNET_ERROR_TYPE_DEBUG, - "block %s running!\n", - bs->label); + "block %s running %u!\n", + bs->label, + bs->asynchronous_finish); + if (GNUNET_YES == bs->asynchronous_finish) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "block %s running asynchronous!\n", + bs->label); + cmd->asynchronous_finish = bs->asynchronous_finish; + } } @@ -126,15 +142,18 @@ block_until_all_peers_started_run (void *cls, * * @param label name for command. * @param all_peers_started Flag which will be set from outside. + * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL. * @return command. */ struct GNUNET_TESTING_Command -GNUNET_TESTING_cmd_block_until_external_trigger (const char *label) +GNUNET_TESTING_cmd_block_until_external_trigger ( + const char *label) { struct BlockState *bs; bs = GNUNET_new (struct BlockState); bs->label = label; + bs->asynchronous_finish = GNUNET_NO; { struct GNUNET_TESTING_Command cmd = { .cls = bs, diff --git a/src/testing/testing_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c index 2ff70c33e..6cd648c3a 100644 --- a/src/testing/testing_api_cmd_netjail_start.c +++ b/src/testing/testing_api_cmd_netjail_start.c @@ -193,11 +193,15 @@ netjail_start_run (void *cls, NULL, script_name, script_argv); + } ns->cwh = GNUNET_wait_child (ns->start_proc, &child_completed_callback, ns); GNUNET_break (NULL != ns->cwh); + GNUNET_free (read_file); + GNUNET_free (script_name); + GNUNET_free (data_dir); } diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c index e3bf7da62..f1b2260ab 100644 --- a/src/testing/testing_api_cmd_netjail_stop.c +++ b/src/testing/testing_api_cmd_netjail_stop.c @@ -87,6 +87,7 @@ netjail_stop_cleanup (void *cls) GNUNET_OS_process_destroy (ns->stop_proc); ns->stop_proc = NULL; } + GNUNET_free (ns); } diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c index 3727d2543..e82ec33ab 100644 --- a/src/testing/testing_api_loop.c +++ b/src/testing/testing_api_loop.c @@ -52,6 +52,11 @@ struct GNUNET_TESTING_Interpreter */ struct GNUNET_TESTING_Command *commands; + /** + * Number of GNUNET_TESTING_Command in commands. + */ + unsigned int cmds_n; + /** * Interpreter task (if one is scheduled). */ @@ -83,21 +88,32 @@ struct GNUNET_TESTING_Interpreter const struct GNUNET_TESTING_Command * -GNUNET_TESTING_interpreter_lookup_command ( - struct GNUNET_TESTING_Interpreter *is, - const char *label) +get_command (struct GNUNET_TESTING_Interpreter *is, + const char *label, + unsigned int future) { + int start_i = GNUNET_NO == future ? is->ip : is->cmds_n - 1; + int end_i = GNUNET_NO == future ? 0 : is->ip + 1; + + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "start_i: %u end_i: %u\n", + start_i, + end_i); if (NULL == label) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Attempt to lookup command for empty label\n"); return NULL; } - /* Search backwards as we most likely reference recent commands */ - for (int i = is->ip; i >= 0; i--) + + for (int i = start_i; i >= end_i; i--) { const struct GNUNET_TESTING_Command *cmd = &is->commands[i]; + if (NULL != cmd->label) + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "label to compare %s\n", + cmd->label); /* Give precedence to top-level commands. */ if ( (NULL != cmd->label) && (0 == strcmp (cmd->label, @@ -141,6 +157,40 @@ GNUNET_TESTING_interpreter_lookup_command ( } +/** + * Lookup command by label. + * Only future commands are looked up. + * + * @param is interpreter to lookup command in + * @param label label of the command to lookup. + * @return the command, if it is found, or NULL. + */ +const struct GNUNET_TESTING_Command * +GNUNET_TESTING_interpreter_lookup_future_command ( + struct GNUNET_TESTING_Interpreter *is, + const char *label) +{ + return get_command (is, label, GNUNET_YES); +} + + +/** + * Lookup command by label. + * Only commands from current command to commands in the past are looked up. + * + * @param is interpreter to lookup command in + * @param label label of the command to lookup. + * @return the command, if it is found, or NULL. + */ +const struct GNUNET_TESTING_Command * +GNUNET_TESTING_interpreter_lookup_command ( + struct GNUNET_TESTING_Interpreter *is, + const char *label) +{ + return get_command (is, label, GNUNET_NO); +} + + /** * Finish the test run, return the final result. * @@ -267,6 +317,20 @@ GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is) } +/** + * Returns the actual running command. + * + * @param is Global state of the interpreter, used by a command + * to access information about other commands. + * @return The actual running command. + */ +struct GNUNET_TESTING_Command * +GNUNET_TESTING_interpreter_get_current_command ( + struct GNUNET_TESTING_Interpreter *is) +{ + return &is->commands[is->ip]; +} + const char * GNUNET_TESTING_interpreter_get_current_label ( struct GNUNET_TESTING_Interpreter *is) @@ -300,9 +364,17 @@ interpreter_run (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Running command `%s'\n", cmd->label); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "start time of %p expected 0 is `%lu'\n", + cmd, + cmd->start_time.abs_value_us); cmd->start_time = cmd->last_req_time = GNUNET_TIME_absolute_get (); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "start time of %p expected something is `%lu'\n", + cmd, + cmd->start_time.abs_value_us); cmd->num_tries = 1; if (NULL != cmd->ac) { @@ -344,6 +416,37 @@ do_timeout (void *cls) } +/** + * Check if the command is running. + * + * @param cmd The command to check. + * @return GNUNET_NO if the command is not running, GNUNET_YES if it is running. + */ +enum GNUNET_GenericReturnValue +GNUNET_TESTING_running (const struct GNUNET_TESTING_Command *command) +{ + return 0 != command->start_time.abs_value_us && 0 == + command->finish_time.abs_value_us; +} + + +/** + * Check if a command is finished. + * + * @param cmd The command to check. + * @return GNUNET_NO if the command is not finished, GNUNET_YES if it is finished. + */ +enum GNUNET_GenericReturnValue +GNUNET_TESTING_finished (struct GNUNET_TESTING_Command *command) +{ + struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); + struct GNUNET_TIME_Relative diff = GNUNET_TIME_absolute_get_difference ( + command->finish_time, + now); + return 0 < diff.rel_value_us; +} + + void GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, struct GNUNET_TIME_Relative timeout, @@ -359,7 +462,8 @@ GNUNET_TESTING_run (struct GNUNET_TESTING_Command *commands, /* get the number of commands */ for (i = 0; NULL != commands[i].label; i++) ; - is->commands = GNUNET_new_array (i + 1, + is->cmds_n = i + 1; + is->commands = GNUNET_new_array (is->cmds_n, struct GNUNET_TESTING_Command); memcpy (is->commands, commands, -- cgit v1.2.3