summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-10-04 12:15:43 +0200
committerChristian Grothoff <christian@grothoff.org>2021-10-04 12:15:43 +0200
commitf146e80752e73247acb9d6c7463188a82d26a774 (patch)
tree13ed03d817ce04daa133507778ac6a1b71bf147f /src
parent7ecc3a03a0670a1620c603502c9958b95e6dc1d0 (diff)
-taking a first stab at cleaning up the testing mess
Diffstat (limited to 'src')
-rw-r--r--src/dhtu/Makefile.am15
-rw-r--r--src/dhtu/test_dhtu_ip.c39
-rw-r--r--src/dhtu/testing_dhtu_cmd_send.c170
-rw-r--r--src/include/gnunet_testing_ng_lib.h100
-rw-r--r--src/testing/Makefile.am1
-rw-r--r--src/testing/testing_api_cmd_batch.c22
-rw-r--r--src/testing/testing_api_cmd_block_until_all_peers_started.c4
-rw-r--r--src/testing/testing_api_cmd_block_until_external_trigger.c6
-rw-r--r--src/testing/testing_api_cmd_hello_world.c65
-rw-r--r--src/testing/testing_api_cmd_hello_world_birth.c10
-rw-r--r--src/testing/testing_api_cmd_local_test_finished.c49
-rw-r--r--src/testing/testing_api_cmd_netjail_start.c47
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c5
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem_v2.c5
-rw-r--r--src/testing/testing_api_cmd_netjail_start_v2.c20
-rw-r--r--src/testing/testing_api_cmd_netjail_stop.c49
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem.c35
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c32
-rw-r--r--src/testing/testing_api_cmd_netjail_stop_v2.c42
-rw-r--r--src/testing/testing_api_cmd_send_peer_ready.c29
-rw-r--r--src/testing/testing_api_cmd_system_create.c4
-rw-r--r--src/testing/testing_api_cmd_system_destroy.c33
-rw-r--r--src/testing/testing_api_loop.c388
-rw-r--r--src/testing/testing_api_trait_cmd.c2
-rw-r--r--src/testing/testing_api_traits.c2
25 files changed, 555 insertions, 619 deletions
diff --git a/src/dhtu/Makefile.am b/src/dhtu/Makefile.am
index 61ca84ee3..772bee60a 100644
--- a/src/dhtu/Makefile.am
+++ b/src/dhtu/Makefile.am
@@ -41,6 +41,21 @@ libgnunet_plugin_dhtu_gnunet_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
+lib_LTLIBRARIES = \
+ libgnunettestingdhtu.la
+
+libgnunettestingdhtu_la_SOURCES = \
+ testing_dhtu_cmd_send.c
+libgnunettestingdhtu_la_LIBADD = \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(LTLIBINTL)
+libgnunettestingdhtu_la_LDFLAGS = \
+ $(GN_LIB_LDFLAGS) \
+ -version-info 0:0:0
+
+
+
test_dhtu_ip_SOURCES = \
test_dhtu_ip.c
test_dhtu_ip_LDADD = \
diff --git a/src/dhtu/test_dhtu_ip.c b/src/dhtu/test_dhtu_ip.c
index f350905b8..eb886e994 100644
--- a/src/dhtu/test_dhtu_ip.c
+++ b/src/dhtu/test_dhtu_ip.c
@@ -32,20 +32,9 @@
#define CONFIG_FILE "test_dhtu_ip.conf"
-/**
- * Return value of the test.
- *
- */
-static int rv;
-
-
-/**
- * Main function to run the test cases.
- *
- * @param cls not used.
- */
-static void
-run (void *cls)
+int
+main (int argc,
+ char *const *argv)
{
struct GNUNET_TESTING_Command commands[] = {
GNUNET_TESTING_cmd_netjail_start_v2 ("netjail-start",
@@ -55,23 +44,7 @@ run (void *cls)
GNUNET_TESTING_cmd_end ()
};
- (void) cls;
- if (GNUNET_OK !=
- GNUNET_TESTING_run (NULL, /* config file */
- commands,
- TIMEOUT))
- {
- GNUNET_break (0);
- rv = EXIT_FAILURE;
- }
-}
-
-
-int
-main (int argc,
- char *const *argv)
-{
- GNUNET_SCHEDULER_run (&run,
- NULL);
- return rv;
+ return GNUNET_TESTING_main (NULL,
+ commands,
+ TIMEOUT);
}
diff --git a/src/dhtu/testing_dhtu_cmd_send.c b/src/dhtu/testing_dhtu_cmd_send.c
new file mode 100644
index 000000000..129a31205
--- /dev/null
+++ b/src/dhtu/testing_dhtu_cmd_send.c
@@ -0,0 +1,170 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file testing/testing_dhtu_cmd_send.c
+ * @brief use DHTU to send a message
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "gnunet_testing_ng_lib.h"
+
+
+/**
+ * State for the 'send' command.
+ */
+struct SendState
+{
+
+ /**
+ * Function to call when done.
+ */
+ GNUNET_SCHEDULER_TaskCallback cont;
+
+ /**
+ * Closure for @e cont.
+ */
+ void *cont_cls;
+
+ enum GNUNET_GenericReturnValue finished;
+};
+
+
+/**
+ *
+ *
+ * @param cls a `struct SendState`
+ */
+static void
+send_cleanup (void *cls)
+{
+ struct SendState *ss = cls;
+
+ GNUNET_free (ss);
+}
+
+
+/**
+ * Return trains of the ``send`` command.
+ *
+ * @param cls closure.
+ * @param[out] ret result
+ * @param trait name of the trait.
+ * @param index index number of the object to offer.
+ * @return #GNUNET_OK on success.
+ * #GNUNET_NO if no trait was found
+ */
+static enum GNUNET_GenericReturnValue
+send_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
+{
+ return GNUNET_NO;
+}
+
+
+/**
+ * Run the 'send' command.
+ *
+ * @param cls closure.
+ * @param is interpreter state.
+ */
+static void
+send_run (void *cls,
+ struct GNUNET_TESTING_Interpreter *is)
+{
+ struct SendState *ss = cls;
+
+#if 0
+ other_cmd = GNUNET_TESTING_interpreter_lookup_command (ss->other_label);
+ GNUNET_TESTING_get_trait_XXX (other_cmd,
+ &data);
+#endif
+ ss->finished = GNUNET_OK;
+}
+
+
+/**
+ * This function checks the flag NetJailState#finished, if this cmd finished.
+ *
+ * @param cls a `struct SendState`
+ * @param cont function to call upon completion, can be NULL
+ * @param cont_cls closure for @a cont
+ * @return
+ * #GNUNET_NO if the command is still running and @a cont will be called later
+ * #GNUNET_OK if the command completed successfully and @a cont was called
+ * #GNUNET_SYSERR if the operation @a cont was NOT called
+ */
+static enum GNUNET_GenericReturnValue
+send_finish (void *cls,
+ GNUNET_SCHEDULER_TaskCallback cont,
+ void *cont_cls)
+{
+ struct SendState *ss = cls;
+
+ switch (ss->finished)
+ {
+ case GNUNET_OK:
+ cont (cont_cls);
+ break;
+ case GNUNET_SYSERR:
+ GNUNET_break (0);
+ break;
+ case GNUNET_NO:
+ if (NULL != ss->cont)
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
+ ss->cont = cont;
+ ss->cont_cls = cont_cls;
+ break;
+ }
+ return ss->finished;
+}
+
+
+/**
+ * Create 'send' command.
+ *
+ * @param label name for command.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_DHTU_cmd_send (const char *label)
+{
+ struct SendState *ss;
+
+ ss = GNUNET_new (struct SendState);
+
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = ss,
+ .label = label,
+ .run = &send_run,
+ .finish = &send_finish,
+ .cleanup = &send_cleanup,
+ .traits = &send_traits
+ };
+
+ return cmd;
+ }
+}
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h
index 31665f8f7..363c7ff0c 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -279,15 +279,16 @@ struct GNUNET_TESTING_Command
* the asynchronous activity to terminate.
*
* @param cls closure
- * @param cmd command being run
- * @param i interpreter state
+ * @param is interpreter state
*/
void
(*run)(void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *i);
+ struct GNUNET_TESTING_Interpreter *is);
/**
+ * FIXME: logic is basically always the same!
+ * => Refactor API to avoid duplication!
+ *
* Wait for any asynchronous execution of @e run to conclude,
* then call finish_cont. Finish may only be called once per command.
*
@@ -297,27 +298,24 @@ struct GNUNET_TESTING_Command
* @param cls closure
* @param cont function to call upon completion, can be NULL
* @param cont_cls closure for @a cont
+ * @return
+ * #GNUNET_NO if the command is still running and @a cont will be called later
+ * #GNUNET_OK if the command completed successfully and @a cont was called
+ * #GNUNET_SYSERR if the operation @a cont was NOT called
*/
- int
+ enum GNUNET_GenericReturnValue
(*finish)(void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
void *cont_cls);
/**
- * Task for running the finish function.
- */
- struct GNUNET_SCHEDULER_Task *finish_task;
-
- /**
* Clean up after the command. Run during forced termination
* (CTRL-C) or test failure or test success.
*
* @param cls closure
- * @param cmd command being cleaned up
*/
void
- (*cleanup)(void *cls,
- const struct GNUNET_TESTING_Command *cmd);
+ (*cleanup)(void *cls);
/**
* Extract information from a command that is useful for other
@@ -327,9 +325,10 @@ struct GNUNET_TESTING_Command
* @param[out] ret result (could be anything)
* @param trait name of the trait
* @param index index number of the object to extract.
- * @return #GNUNET_OK on success
+ * @return #GNUNET_OK on success,
+ * #GNUNET_NO if no trait was found
*/
- int
+ enum GNUNET_GenericReturnValue
(*traits)(void *cls,
const void **ret,
const char *trait,
@@ -383,40 +382,15 @@ struct GNUNET_TESTING_Command
/**
- * Struct to use for command-specific context information closure of a command waiting
- * for another command.
- */
-struct SyncState
-{
- /**
- * Closure for all commands with command-specific context information.
- */
- void *cls;
-
- /**
- * The asynchronous command the synchronous command of this closure waits for.
- */
- const struct GNUNET_TESTING_Command *async_cmd;
-
- /**
- * Task for running the finish method of the asynchronous task the command is waiting for.
- */
- struct GNUNET_SCHEDULER_Task *finish_task;
-
- /**
- * When did the execution of this commands finish function start?
- */
- struct GNUNET_TIME_Absolute start_finish_time;
-};
-
-/**
* Lookup command by label.
*
+ * @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);
@@ -437,7 +411,7 @@ GNUNET_TESTING_interpreter_get_current_label (
* @param is interpreter state.
*/
void
-GNUNET_TESTING_interpreter_fail ();
+GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is);
/**
@@ -455,8 +429,8 @@ GNUNET_TESTING_cmd_end (void);
* @param cmd command to make synchronous.
* @return a finish-command.
*/
-const struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_make_unblocking (const struct GNUNET_TESTING_Command cmd);
+struct GNUNET_TESTING_Command
+GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd);
/**
@@ -492,19 +466,10 @@ GNUNET_TESTING_cmd_rewind_ip (const char *label,
/**
- * Wait until we receive SIGCHLD signal. Then obtain the process trait of the
- * current command, wait on the the zombie and continue with the next command.
- *
- * @param is interpreter state.
- */
-// void
-// GNUNET_TESTING_wait_for_sigchld (struct GNUNET_TESTING_Interpreter *is);
-// => replace with child_management.c
-
-
-/**
- * Start scheduling loop with signal handlers and run the
- * test suite with the @a commands.
+ * Run the testsuite. Note, CMDs are copied into
+ * the interpreter state because they are _usually_
+ * defined into the "run" method that returns after
+ * having scheduled the test interpreter.
*
* @param cfg_name name of configuration file to use
* @param commands the list of command to execute
@@ -513,13 +478,29 @@ GNUNET_TESTING_cmd_rewind_ip (const char *label,
* non-GNUNET_OK codes are #GNUNET_SYSERR most of the
* times.
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_TESTING_run (const char *cfg_filename,
struct GNUNET_TESTING_Command *commands,
struct GNUNET_TIME_Relative timeout);
/**
+ * Start a GNUnet scheduler event loop and
+ * run the testsuite. Return 0 upon success.
+ * Expected to be called directly from main().
+ *
+ * @param cfg_name name of configuration file to use
+ * @param commands the list of command to execute
+ * @param timeout how long to wait for each command to execute
+ * @return EXIT_SUCCESS on success, EXIT_FAILURE on failure
+ */
+int
+GNUNET_TESTING_main (const char *cfg_filename,
+ struct GNUNET_TESTING_Command *commands,
+ struct GNUNET_TIME_Relative timeout);
+
+
+/**
* Look for substring in a programs' name.
*
* @param prog program's name to look into
@@ -1191,4 +1172,5 @@ struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_local_test_finished (const char *label,
TESTING_CMD_HELPER_write_cb
write_message);
+
#endif
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index efb22b279..3e0d4d443 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -44,6 +44,7 @@ libgnunet_test_testing_plugin_testcmd_la_LDFLAGS = \
libgnunettesting_la_SOURCES = \
testing_api_cmd_local_test_finished.c \
+ testing_api_cmd_finish.c \
testing_api_cmd_send_peer_ready.c \
testing_api_cmd_block_until_all_peers_started.c \
testing_api_cmd_block_until_external_trigger.c \
diff --git a/src/testing/testing_api_cmd_batch.c b/src/testing/testing_api_cmd_batch.c
index af260f80d..e39489616 100644
--- a/src/testing/testing_api_cmd_batch.c
+++ b/src/testing/testing_api_cmd_batch.c
@@ -39,6 +39,11 @@ struct BatchState
struct GNUNET_TESTING_Command *batch;
/**
+ * Our label.
+ */
+ const char *label;
+
+ /**
* Internal command pointer.
*/
unsigned int batch_ip;
@@ -49,12 +54,10 @@ struct BatchState
* Run the command.
*
* @param cls closure.
- * @param cmd the command being executed.
* @param is the interpreter state.
*/
static void
batch_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct BatchState *bs = cls;
@@ -69,7 +72,7 @@ batch_run (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Exiting from batch: %s\n",
- cmd->label);
+ bs->label);
return;
}
bs->batch[bs->batch_ip].start_time
@@ -77,7 +80,6 @@ batch_run (void *cls,
= GNUNET_TIME_absolute_get ();
bs->batch[bs->batch_ip].num_tries = 1;
bs->batch[bs->batch_ip].run (bs->batch[bs->batch_ip].cls,
- &bs->batch[bs->batch_ip],
is);
}
@@ -87,20 +89,16 @@ batch_run (void *cls,
* cancel a pending operation thereof.
*
* @param cls closure.
- * @param cmd the command which is being cleaned up.
*/
static void
-batch_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+batch_cleanup (void *cls)
{
struct BatchState *bs = cls;
- (void) cmd;
for (unsigned int i = 0;
NULL != bs->batch[i].label;
i++)
- bs->batch[i].cleanup (bs->batch[i].cls,
- &bs->batch[i]);
+ bs->batch[i].cleanup (bs->batch[i].cls);
GNUNET_free (bs->batch);
GNUNET_free (bs);
}
@@ -115,7 +113,7 @@ batch_cleanup (void *cls,
* @param index index number of the object to offer.
* @return #GNUNET_OK on success.
*/
-static int
+static enum GNUNET_GenericReturnValue
batch_traits (void *cls,
const void **ret,
const char *trait,
@@ -162,7 +160,7 @@ GNUNET_TESTING_cmd_batch (const char *label,
unsigned int i;
bs = GNUNET_new (struct BatchState);
-
+ bs->label = label;
/* Get number of commands. */
for (i = 0; NULL != batch[i].label; i++)
/* noop */
diff --git a/src/testing/testing_api_cmd_block_until_all_peers_started.c b/src/testing/testing_api_cmd_block_until_all_peers_started.c
index e9d3f0ed3..fb51c1066 100644
--- a/src/testing/testing_api_cmd_block_until_all_peers_started.c
+++ b/src/testing/testing_api_cmd_block_until_all_peers_started.c
@@ -65,8 +65,7 @@ block_until_all_peers_started_traits (void *cls,
*
*/
static void
-block_until_all_peers_started_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+block_until_all_peers_started_cleanup (void *cls)
{
struct BlockState *bs = cls;
@@ -80,7 +79,6 @@ block_until_all_peers_started_cleanup (void *cls,
*/
static void
block_until_all_peers_started_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
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 2439afeaf..d69040b75 100644
--- a/src/testing/testing_api_cmd_block_until_external_trigger.c
+++ b/src/testing/testing_api_cmd_block_until_external_trigger.c
@@ -56,7 +56,7 @@ block_until_all_peers_started_traits (void *cls,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -65,8 +65,7 @@ block_until_all_peers_started_traits (void *cls,
*
*/
static void
-block_until_all_peers_started_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+block_until_all_peers_started_cleanup (void *cls)
{
struct BlockState *bs = cls;
@@ -80,7 +79,6 @@ block_until_all_peers_started_cleanup (void *cls,
*/
static void
block_until_all_peers_started_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/testing/testing_api_cmd_hello_world.c b/src/testing/testing_api_cmd_hello_world.c
index 4347ac818..73dcd6dff 100644
--- a/src/testing/testing_api_cmd_hello_world.c
+++ b/src/testing/testing_api_cmd_hello_world.c
@@ -32,50 +32,51 @@ struct HelloWorldState
const char *birthLabel;
};
+
/**
-*
-*
-* @param cls closure
-* @param cmd current CMD being cleaned up.
-*/
+ *
+ *
+ * @param cls closure
+ */
static void
-hello_world_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+hello_world_cleanup (void *cls)
{
struct HelloWorldState *hs = cls;
+
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Cleaning up message %s\n",
hs->message);
+ GNUNET_free (hs);
}
+
/**
-*
-*
-* @param cls closure.
-* @param[out] ret result
-* @param trait name of the trait.
-* @param index index number of the object to offer.
-* @return #GNUNET_OK on success.
-*/
-static int
+ *
+ *
+ * @param cls closure.
+ * @param[out] ret result
+ * @param trait name of the trait.
+ * @param index index number of the object to offer.
+ * @return #GNUNET_OK on success.
+ */
+static enum GNUNET_GenericReturnValue
hello_world_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
+
/**
* Run the "hello world" CMD.
*
* @param cls closure.
-* @param cmd CMD being run.
* @param is interpreter state.
*/
static void
hello_world_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct HelloWorldState *hs = cls;
@@ -84,13 +85,16 @@ hello_world_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"%s\n",
hs->message);
- birth_cmd = GNUNET_TESTING_interpreter_lookup_command (hs->birthLabel);
- GNUNET_TESTING_get_trait_what_am_i (birth_cmd, &hs->message);
+ birth_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ hs->birthLabel);
+ GNUNET_TESTING_get_trait_what_am_i (birth_cmd,
+ &hs->message);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Now I am a %s\n",
hs->message);
}
+
/**
* Create command.
*
@@ -108,14 +112,15 @@ GNUNET_TESTING_cmd_hello_world (const char *label,
hs = GNUNET_new (struct HelloWorldState);
hs->message = "Hello World, I was nobody!";
hs->birthLabel = birthLabel;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = hs,
+ .label = label,
+ .run = &hello_world_run,
+ .cleanup = &hello_world_cleanup,
+ .traits = &hello_world_traits
+ };
- struct GNUNET_TESTING_Command cmd = {
- .cls = hs,
- .label = label,
- .run = &hello_world_run,
- .cleanup = &hello_world_cleanup,
- .traits = &hello_world_traits
- };
-
- return cmd;
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_hello_world_birth.c b/src/testing/testing_api_cmd_hello_world_birth.c
index 9d60059a5..8415b99f0 100644
--- a/src/testing/testing_api_cmd_hello_world_birth.c
+++ b/src/testing/testing_api_cmd_hello_world_birth.c
@@ -40,8 +40,7 @@ struct HelloWorldBirthState
* @param cmd current CMD being cleaned up.
*/
static void
-hello_world_birth_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+hello_world_birth_cleanup (void *cls)
{
struct HelloWorldBirthState *hbs = cls;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -49,6 +48,7 @@ hello_world_birth_cleanup (void *cls,
hbs->what_am_i);
}
+
/**
*
*
@@ -82,6 +82,7 @@ hello_world_birth_traits (void *cls,
index);
}
+
/**
* Run the "hello world" CMD.
*
@@ -91,14 +92,13 @@ hello_world_birth_traits (void *cls,
*/
static void
hello_world_birth_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct HelloWorldBirthState *hbs = cls;
struct GNUNET_TIME_Relative relative;
relative = GNUNET_TIME_absolute_get_difference (*hbs->date,
- GNUNET_TIME_absolute_get ());
+ GNUNET_TIME_absolute_get ());
if (0 == relative.rel_value_us % 10)
{
@@ -114,6 +114,7 @@ hello_world_birth_run (void *cls,
}
}
+
/**
* Offer data from trait
*
@@ -131,6 +132,7 @@ GNUNET_TESTING_get_trait_what_am_i (const struct GNUNET_TESTING_Command *cmd,
(unsigned int) 0);
}
+
/**
* Create command.
*
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c
index 383de4c10..da4aff80f 100644
--- a/src/testing/testing_api_cmd_local_test_finished.c
+++ b/src/testing/testing_api_cmd_local_test_finished.c
@@ -19,7 +19,7 @@
*/
/**
- * @file testing_api_cmd_block_until_all_peers_started.c
+ * @file testing_api_cmd_local_test_finished.c
* @brief cmd to block the interpreter loop until all peers started.
* @author t3sserakt
*/
@@ -58,13 +58,13 @@ struct LocalFinishedState
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
local_test_finished_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -73,8 +73,7 @@ local_test_finished_traits (void *cls,
*
*/
static void
-local_test_finished_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+local_test_finished_cleanup (void *cls)
{
struct LocalFinishedState *lfs = cls;
@@ -89,11 +88,9 @@ local_test_finished_cleanup (void *cls,
*/
static void
local_test_finished_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct LocalFinishedState *lfs = cls;
-
struct GNUNET_CMDS_LOCAL_FINISHED *reply;
size_t msg_length;
@@ -102,15 +99,18 @@ local_test_finished_run (void *cls,
reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
reply->header.size = htons ((uint16_t) msg_length);
lfs->reply = reply;
- lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
+ lfs->write_message ((struct GNUNET_MessageHeader *) reply,
+ msg_length);
}
/**
- * This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method.
+ * This finish function will stop the local loop without shutting down the
+ * scheduler, because we do not call the continuation, which is the
+ * interpreter_next method.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
local_test_finished_finish (void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
void *cont_cls)
@@ -129,23 +129,24 @@ local_test_finished_finish (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_local_test_finished (const char *label,
- TESTING_CMD_HELPER_write_cb
- write_message)
+GNUNET_TESTING_cmd_local_test_finished (
+ const char *label,
+ TESTING_CMD_HELPER_write_cb write_message)
{
struct LocalFinishedState *lfs;
lfs = GNUNET_new (struct LocalFinishedState);
lfs->write_message = write_message;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = lfs,
- .label = label,
- .run = &local_test_finished_run,
- .finish = &local_test_finished_finish,
- .cleanup = &local_test_finished_cleanup,
- .traits = &local_test_finished_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = lfs,
+ .label = label,
+ .run = &local_test_finished_run,
+ .finish = &local_test_finished_finish,
+ .cleanup = &local_test_finished_cleanup,
+ .traits = &local_test_finished_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_netjail_start.c b/src/testing/testing_api_cmd_netjail_start.c
index 536b356a6..1815b64d2 100644
--- a/src/testing/testing_api_cmd_netjail_start.c
+++ b/src/testing/testing_api_cmd_netjail_start.c
@@ -49,8 +49,10 @@ struct NetJailState
*/
struct GNUNET_OS_Process *start_proc;
- // Flag indication if the script finished.
- unsigned int finished;
+ /**
+ * Flag indication if the script finished.
+ */
+ enum GNUNET_GenericReturnValue finished;
};
@@ -59,8 +61,7 @@ struct NetJailState
*
*/
static void
-netjail_start_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+netjail_start_cleanup (void *cls)
{
struct NetJailState *ns = cls;
@@ -90,13 +91,13 @@ netjail_start_cleanup (void *cls,
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
netjail_start_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -126,17 +127,14 @@ child_completed_callback (void *cls,
}
-
/**
* The run method starts the script which setup the network namespaces.
*
* @param cls closure.
-* @param cmd CMD being run.
* @param is interpreter state.
*/
static void
netjail_start_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct NetJailState *ns = cls;
@@ -154,14 +152,14 @@ netjail_start_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No SUID for %s!\n",
NETJAIL_START_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
}
else if (GNUNET_NO == helper_check)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%s not found!\n",
NETJAIL_START_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
}
ns->start_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR,
@@ -182,7 +180,7 @@ netjail_start_run (void *cls,
* This function checks the flag NetJailState#finished, if this cmd finished.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
netjail_start_finish (void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
void *cont_cls)
@@ -196,6 +194,7 @@ netjail_start_finish (void *cls,
return ns->finished;
}
+
/**
* Create command.
*
@@ -214,16 +213,16 @@ GNUNET_TESTING_cmd_netjail_start (const char *label,
ns = GNUNET_new (struct NetJailState);
ns->local_m = local_m;
ns->global_n = global_n;
- ns->finished = GNUNET_NO;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = ns,
- .label = label,
- .run = &netjail_start_run,
- .finish = &netjail_start_finish,
- .cleanup = &netjail_start_cleanup,
- .traits = &netjail_start_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = ns,
+ .label = label,
+ .run = &netjail_start_run,
+ .finish = &netjail_start_finish,
+ .cleanup = &netjail_start_cleanup,
+ .traits = &netjail_start_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index 531621eb5..1222ae54b 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -194,11 +194,9 @@ struct TestingSystemCount
* Code to clean up resource this cmd used.
*
* @param cls closure
-* @param cmd current CMD being cleaned up.
*/
static void
-netjail_exec_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+netjail_exec_cleanup (void *cls)
{
struct NetJailState *ns = cls;
struct HelperMessage *message_pos;
@@ -480,7 +478,6 @@ start_helper (struct NetJailState *ns, struct
*/
static void
netjail_exec_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
char str_m[12];
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..bb9421aa7 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem_v2.c
@@ -205,11 +205,9 @@ struct TestingSystemCount
* Code to clean up resource this cmd used.
*
* @param cls closure
-* @param cmd current CMD being cleaned up.
*/
static void
-netjail_exec_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+netjail_exec_cleanup (void *cls)
{
struct NetJailState *ns = cls;
struct HelperMessage *message_pos;
@@ -568,7 +566,6 @@ start_helper (struct NetJailState *ns, struct
*/
static void
netjail_exec_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct NetJailState *ns = cls;
diff --git a/src/testing/testing_api_cmd_netjail_start_v2.c b/src/testing/testing_api_cmd_netjail_start_v2.c
index 9123148a7..faabed98e 100644
--- a/src/testing/testing_api_cmd_netjail_start_v2.c
+++ b/src/testing/testing_api_cmd_netjail_start_v2.c
@@ -19,7 +19,7 @@
*/
/**
- * @file testing/testing_api_cmd_hello_world.c
+ * @file testing/testing_api_cmd_netjail_start_v2.c
* @brief Command to start the netjail script.
* @author t3sserakt
*/
@@ -59,8 +59,7 @@ struct NetJailState
*
*/
static void
-netjail_start_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+netjail_start_cleanup (void *cls)
{
struct NetJailState *ns = cls;
@@ -90,13 +89,13 @@ netjail_start_cleanup (void *cls,
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
netjail_start_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -127,17 +126,14 @@ child_completed_callback (void *cls,
}
-
/**
* The run method starts the script which setup the network namespaces.
*
* @param cls closure.
-* @param cmd CMD being run.
* @param is interpreter state.
*/
static void
netjail_start_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct NetJailState *ns = cls;
@@ -157,7 +153,7 @@ netjail_start_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No SUID for %s!\n",
NETJAIL_START_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
if (GNUNET_SYSERR == helper_check)
@@ -165,7 +161,7 @@ netjail_start_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%s not found!\n",
NETJAIL_START_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
return;
}
@@ -180,7 +176,7 @@ netjail_start_run (void *cls,
pid,
NULL
};
-
+
ns->start_proc
= GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR,
NULL,
@@ -198,7 +194,7 @@ netjail_start_run (void *cls,
/**
* This function checks the flag NetJailState
- *
+ *
* FIXME: fix comment!
* #finished, if this cmd finished.
*
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c
index 99084d9af..c93e5cca3 100644
--- a/src/testing/testing_api_cmd_netjail_stop.c
+++ b/src/testing/testing_api_cmd_netjail_stop.c
@@ -19,7 +19,7 @@
*/
/**
- * @file testing/testing_api_cmd_hello_world.c
+ * @file testing/testing_api_cmd_netjail_stop.c
* @brief Command to stop the netjail script.
* @author t3sserakt
*/
@@ -60,8 +60,7 @@ struct NetJailState
*
*/
static void
-netjail_stop_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+netjail_stop_cleanup (void *cls)
{
struct NetJailState *ns = cls;
@@ -87,13 +86,13 @@ netjail_stop_cleanup (void *cls,
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
netjail_stop_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -131,14 +130,15 @@ child_completed_callback (void *cls,
*/
static void
netjail_stop_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct NetJailState *ns = cls;
- char *const script_argv[] = {NETJAIL_STOP_SCRIPT,
- ns->local_m,
- ns->global_n,
- NULL};
+ char *const script_argv[] = {
+ NETJAIL_STOP_SCRIPT,
+ ns->local_m,
+ ns->global_n,
+ NULL
+ };
unsigned int helper_check = GNUNET_OS_check_helper_binary (
NETJAIL_STOP_SCRIPT,
GNUNET_YES,
@@ -149,14 +149,14 @@ netjail_stop_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No SUID for %s!\n",
NETJAIL_STOP_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
}
else if (GNUNET_NO == helper_check)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%s not found!\n",
NETJAIL_STOP_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
}
ns->stop_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR,
@@ -178,7 +178,7 @@ netjail_stop_run (void *cls,
* This function checks the flag NetJailState#finished, if this cmd finished.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
netjail_stop_finish (void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
void *cont_cls)
@@ -211,15 +211,16 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label,
ns = GNUNET_new (struct NetJailState);
ns->local_m = local_m;
ns->global_n = global_n;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = ns,
- .label = label,
- .run = &netjail_stop_run,
- .finish = &netjail_stop_finish,
- .cleanup = &netjail_stop_cleanup,
- .traits = &netjail_stop_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = ns,
+ .label = label,
+ .run = &netjail_stop_run,
+ .finish = &netjail_stop_finish,
+ .cleanup = &netjail_stop_cleanup,
+ .traits = &netjail_stop_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem.c b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
index 0ae82a26a..04b0e4e94 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem.c
@@ -55,10 +55,8 @@ struct StopHelperState
* @param cmd current CMD being cleaned up.
*/
static void
-stop_testing_system_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+stop_testing_system_cleanup (void *cls)
{
-
}
@@ -66,13 +64,13 @@ stop_testing_system_cleanup (void *cls,
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
stop_testing_system_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -80,12 +78,10 @@ stop_testing_system_traits (void *cls,
* This function stops the helper process for each node.
*
* @param cls closure.
-* @param cmd CMD being run.
* @param is interpreter state.
*/
static void
stop_testing_system_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct StopHelperState *shs = cls;
@@ -93,6 +89,7 @@ stop_testing_system_run (void *cls,
const struct GNUNET_TESTING_Command *start_helper_cmd;
start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (
+ is,
shs->helper_start_label);
GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd,
&helper);
@@ -121,8 +118,7 @@ struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_stop_testing_system (const char *label,
const char *helper_start_label,
char *local_m,
- char *global_n
- )
+ char *global_n)
{
struct StopHelperState *shs;
@@ -130,14 +126,15 @@ GNUNET_TESTING_cmd_stop_testing_system (const char *label,
shs->helper_start_label = helper_start_label;
shs->local_m = local_m;
shs->global_n = global_n;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = shs,
- .label = label,
- .run = &stop_testing_system_run,
- .cleanup = &stop_testing_system_cleanup,
- .traits = &stop_testing_system_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = shs,
+ .label = label,
+ .run = &stop_testing_system_run,
+ .cleanup = &stop_testing_system_cleanup,
+ .traits = &stop_testing_system_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c b/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c
index 8eccc5764..65eb85d9a 100644
--- a/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c
+++ b/src/testing/testing_api_cmd_netjail_stop_testsystem_v2.c
@@ -52,11 +52,9 @@ struct StopHelperState
* Code to clean up resource this cmd used.
*
* @param cls closure
-* @param cmd current CMD being cleaned up.
*/
static void
-stop_testing_system_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+stop_testing_system_cleanup (void *cls)
{
}
@@ -66,13 +64,13 @@ stop_testing_system_cleanup (void *cls,
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
stop_testing_system_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -80,12 +78,10 @@ stop_testing_system_traits (void *cls,
* This function stops the helper process for each node.
*
* @param cls closure.
-* @param cmd CMD being run.
* @param is interpreter state.
*/
static void
stop_testing_system_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct StopHelperState *shs = cls;
@@ -93,6 +89,7 @@ stop_testing_system_run (void *cls,
const struct GNUNET_TESTING_Command *start_helper_cmd;
start_helper_cmd = GNUNET_TESTING_interpreter_lookup_command (
+ is,
shs->helper_start_label);
GNUNET_TESTING_get_trait_helper_handles (start_helper_cmd,
&helper);
@@ -130,14 +127,15 @@ GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label,
shs->helper_start_label = helper_start_label;
shs->local_m = topology->nodes_m;
shs->global_n = topology->namespaces_n;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = shs,
- .label = label,
- .run = &stop_testing_system_run,
- .cleanup = &stop_testing_system_cleanup,
- .traits = &stop_testing_system_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = shs,
+ .label = label,
+ .run = &stop_testing_system_run,
+ .cleanup = &stop_testing_system_cleanup,
+ .traits = &stop_testing_system_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_netjail_stop_v2.c b/src/testing/testing_api_cmd_netjail_stop_v2.c
index 8c1f3cedd..348e8c9f7 100644
--- a/src/testing/testing_api_cmd_netjail_stop_v2.c
+++ b/src/testing/testing_api_cmd_netjail_stop_v2.c
@@ -19,7 +19,7 @@
*/
/**
- * @file testing/testing_api_cmd_hello_world.c
+ * @file testing/testing_api_cmd_netjail_stop_v2.c
* @brief Command to stop the netjail script.
* @author t3sserakt
*/
@@ -50,7 +50,7 @@ struct NetJailState
struct GNUNET_OS_Process *stop_proc;
// Flag indication if the script finished.
- unsigned int finished;
+ enum GNUNET_GenericReturnValue finished;
};
@@ -59,8 +59,7 @@ struct NetJailState
*
*/
static void
-netjail_stop_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+netjail_stop_cleanup (void *cls)
{
struct NetJailState *ns = cls;
@@ -86,13 +85,13 @@ netjail_stop_cleanup (void *cls,
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
netjail_stop_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -125,12 +124,10 @@ child_completed_callback (void *cls,
* The run method starts the script which deletes the network namespaces.
*
* @param cls closure.
-* @param cmd CMD being run.
* @param is interpreter state.
*/
static void
netjail_stop_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct NetJailState *ns = cls;
@@ -152,14 +149,14 @@ netjail_stop_run (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No SUID for %s!\n",
NETJAIL_STOP_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
}
else if (GNUNET_NO == helper_check)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"%s not found!\n",
NETJAIL_STOP_SCRIPT);
- GNUNET_TESTING_interpreter_fail ();
+ GNUNET_TESTING_interpreter_fail (is);
}
ns->stop_proc = GNUNET_OS_start_process_vap (GNUNET_OS_INHERIT_STD_ERR,
@@ -181,7 +178,7 @@ netjail_stop_run (void *cls,
* This function checks the flag NetJailState#finished, if this cmd finished.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
netjail_stop_finish (void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
void *cont_cls)
@@ -211,15 +208,16 @@ GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label,
ns = GNUNET_new (struct NetJailState);
ns->topology_config = topology_config;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = ns,
- .label = label,
- .run = &netjail_stop_run,
- .finish = &netjail_stop_finish,
- .cleanup = &netjail_stop_cleanup,
- .traits = &netjail_stop_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = ns,
+ .label = label,
+ .run = &netjail_stop_run,
+ .finish = &netjail_stop_finish,
+ .cleanup = &netjail_stop_cleanup,
+ .traits = &netjail_stop_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_send_peer_ready.c b/src/testing/testing_api_cmd_send_peer_ready.c
index 016837214..8b4c11deb 100644
--- a/src/testing/testing_api_cmd_send_peer_ready.c
+++ b/src/testing/testing_api_cmd_send_peer_ready.c
@@ -53,13 +53,13 @@ struct SendPeerReadyState
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
send_peer_ready_traits (void *cls,
const void **ret,
const char *trait,
unsigned int index)
{
- return GNUNET_OK;
+ return GNUNET_NO;
}
@@ -68,8 +68,7 @@ send_peer_ready_traits (void *cls,
*
*/
static void
-send_peer_ready_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+send_peer_ready_cleanup (void *cls)
{
struct SendPeerReadyState *sprs = cls;
@@ -84,7 +83,6 @@ send_peer_ready_cleanup (void *cls,
*/
static void
send_peer_ready_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct SendPeerReadyState *sprs = cls;
@@ -115,14 +113,15 @@ GNUNET_TESTING_cmd_send_peer_ready (const char *label,
sprs = GNUNET_new (struct SendPeerReadyState);
sprs->write_message = write_message;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = sprs,
- .label = label,
- .run = &send_peer_ready_run,
- .cleanup = &send_peer_ready_cleanup,
- .traits = &send_peer_ready_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = sprs,
+ .label = label,
+ .run = &send_peer_ready_run,
+ .cleanup = &send_peer_ready_cleanup,
+ .traits = &send_peer_ready_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_cmd_system_create.c b/src/testing/testing_api_cmd_system_create.c
index f3a0b1a4c..820adf1bd 100644
--- a/src/testing/testing_api_cmd_system_create.c
+++ b/src/testing/testing_api_cmd_system_create.c
@@ -46,7 +46,6 @@ struct TestSystemState
*/
static void
system_create_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct TestSystemState *tss = cls;
@@ -115,8 +114,7 @@ GNUNET_TESTING_get_trait_test_system (const struct
*
*/
static void
-system_create_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+system_create_cleanup (void *cls)
{
struct TestSystemState *tss = cls;
diff --git a/src/testing/testing_api_cmd_system_destroy.c b/src/testing/testing_api_cmd_system_destroy.c
index 5ed0c2fd2..338123d91 100644
--- a/src/testing/testing_api_cmd_system_destroy.c
+++ b/src/testing/testing_api_cmd_system_destroy.c
@@ -46,17 +46,18 @@ struct TestSystemState
*/
static void
system_destroy_run (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
struct GNUNET_TESTING_Interpreter *is)
{
struct TestSystemState *tss = cls;
const struct GNUNET_TESTING_Command *system_cmd;
struct GNUNET_TESTING_System *tl_system;
- system_cmd = GNUNET_TESTING_interpreter_lookup_command (tss->create_label);
+ system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
+ tss->create_label);
GNUNET_TESTING_get_trait_test_system (system_cmd,
&tl_system);
- GNUNET_TESTING_system_destroy (tl_system, GNUNET_YES);
+ GNUNET_TESTING_system_destroy (tl_system,
+ GNUNET_YES);
}
@@ -65,8 +66,7 @@ system_destroy_run (void *cls,
*
*/
static void
-system_destroy_cleanup (void *cls,
- const struct GNUNET_TESTING_Command *cmd)
+system_destroy_cleanup (void *cls)
{
struct TestSystemState *tss = cls;
@@ -78,7 +78,7 @@ system_destroy_cleanup (void *cls,
* Trait function of this cmd does nothing.
*
*/
-static int
+static enum GNUNET_GenericReturnValue
system_destroy_traits (void *cls,
const void **ret,
const char *trait,
@@ -103,14 +103,15 @@ GNUNET_TESTING_cmd_system_destroy (const char *label,
tss = GNUNET_new (struct TestSystemState);
tss->create_label = create_label;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = tss,
- .label = label,
- .run = &system_destroy_run,
- .cleanup = &system_destroy_cleanup,
- .traits = &system_destroy_traits
- };
-
- return cmd;
+ {
+ struct GNUNET_TESTING_Command cmd = {
+ .cls = tss,
+ .label = label,
+ .run = &system_destroy_run,
+ .cleanup = &system_destroy_cleanup,
+ .traits = &system_destroy_traits
+ };
+
+ return cmd;
+ }
}
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index 0c24c0e26..1c8eb1db6 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -24,67 +24,29 @@
* @author Christian Grothoff (GNU Taler testing)
* @author Marcello Stanisci (GNU Taler testing)
* @author t3sserakt
-*/
+ *
+ * FIXME:
+ * - interpreter failure is NOT returned properly yet!
+ * - abuse of shutdown logic for interpreter termination
+ * => API design flaw to be fixed!
+ */
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "testing.h"
-#define CHECK_FINISHED_PERIOD \
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
-
-struct GNUNET_TESTING_Interpreter *is;
-
-
-/**
- * Closure used to sync an asynchronous with an synchronous command.
- */
-struct SyncTaskClosure
-{
-
- /**
- * The asynchronous command the synchronous command waits for.
- */
- const struct GNUNET_TESTING_Command *async_cmd;
-
- /**
- * The synchronous command that waits for the asynchronous command.
- */
- const struct GNUNET_TESTING_Command *sync_cmd;
-
- /**
- * The interpreter of the test.
- */
- struct GNUNET_TESTING_Interpreter *is;
-};
-
-
-/**
-* Closure used to run the finish task.
-*/
-struct FinishTaskClosure
-{
-
- /**
- * The asynchronous command the synchronous command waits for.
- */
- const struct GNUNET_TESTING_Command *cmd;
-
- /**
- * The interpreter of the test.
- */
- struct GNUNET_TESTING_Interpreter *is;
-};
-
/**
* Lookup command by label.
*
+ * @param is interpreter to lookup command in
* @param label label to look for
* @return NULL if command was not found
*/
const struct GNUNET_TESTING_Command *
-GNUNET_TESTING_interpreter_lookup_command (const char *label)
+GNUNET_TESTING_interpreter_lookup_command (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *label)
{
if (NULL == label)
{
@@ -189,210 +151,35 @@ interpreter_next (void *cls)
/**
- * This function checks if the finish function of a command returns GNUNET_YES, when the command is finished. In this case the finish function might have called interpreter_next. IF GNUNET_NO was returned this function is added to the scheduler again. In case of an error interpreter_fail is called.
- *
- */
-static void
-run_finish_task_next (void *cls)
-{
- struct FinishTaskClosure *ftc = cls;
- const struct GNUNET_TESTING_Command *cmd = ftc->cmd;
- struct GNUNET_TESTING_Interpreter *is = ftc->is;
- unsigned int finished = cmd->finish (cmd->cls, &interpreter_next, is);
-
- if (GNUNET_YES == finished)
- {
- is->finish_task = NULL;
- }
- else if (GNUNET_NO == finished)
- {
- is->finish_task = GNUNET_SCHEDULER_add_delayed (CHECK_FINISHED_PERIOD,
- &run_finish_task_next, ftc);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Next task finished with an error.\n");
- GNUNET_TESTING_interpreter_fail ();
- }
-
-}
-
-
-/**
- * This function checks if the finish function of an asynchronous command returns GNUNET_YES, when the command is finished. In this case the finish function might have called interpreter_next. IF GNUNET_NO was returned this function is added to the scheduler again. In case of an error interpreter_fail is called.
- *
- * //TODO run_finish_task_next and this function can be merged.
- *
- */
-static void
-run_finish_task_sync (void *cls)
-{
- struct SyncTaskClosure *stc = cls;
- const struct GNUNET_TESTING_Command *cmd = stc->async_cmd;
- const struct GNUNET_TESTING_Command *sync_cmd = stc->sync_cmd;
- struct FinishTaskClosure *ftc;
- struct SyncState *sync_state = sync_cmd->cls;
- struct GNUNET_SCHEDULER_Task *finish_task = sync_state->finish_task;
- unsigned int finished = cmd->finish (cmd->cls, &interpreter_next, is);
-
- GNUNET_assert (NULL != finish_task);
- ftc = GNUNET_new (struct FinishTaskClosure);
- ftc->cmd = stc->sync_cmd;
- ftc->is = stc->is;
- struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
- if (cmd->default_timeout.rel_value_us < now.abs_value_us
- - sync_state->start_finish_time.abs_value_us)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "The command with label %s did not finish its asynchronous task in time.\n",
- cmd->label);
- GNUNET_TESTING_interpreter_fail ();
- }
-
- if (GNUNET_YES == finished)
- {
- finish_task = NULL;
- }
- else if (GNUNET_NO == finished)
- {
- finish_task = GNUNET_SCHEDULER_add_delayed (CHECK_FINISHED_PERIOD,
- &run_finish_task_sync, stc);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Sync task finished with an error.\n");
- GNUNET_TESTING_interpreter_fail ();
- }
-}
-
-
-/**
- * run method of the command created by the interpreter to wait for another command to finish.
- *
- */
-static void
-start_finish_on_ref (void *cls,
- const struct GNUNET_TESTING_Command *cmd,
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct SyncState *sync_state = cls;
- struct SyncTaskClosure *stc;
- const struct GNUNET_TESTING_Command *async_cmd;
-
- async_cmd = sync_state->async_cmd;
- stc = GNUNET_new (struct SyncTaskClosure);
- stc->async_cmd = async_cmd;
- stc->sync_cmd = cmd;
- stc->is = is;
- sync_state->start_finish_time = GNUNET_TIME_absolute_get ();
- sync_state->finish_task = GNUNET_SCHEDULER_add_delayed (
- CHECK_FINISHED_PERIOD,
- &run_finish_task_sync,
- stc);
-}
-
-
-/**
- * Create (synchronous) command that waits for another command to finish.
- * If @a cmd_ref did not finish after @a timeout, this command will fail
- * the test case.
- *
- * @param finish_label label for this command
- * @param cmd_ref reference to a previous command which we should
- * wait for (call `finish()` on)
- * @param timeout how long to wait at most for @a cmd_ref to finish
- * @return a finish-command.
- */
-const struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_finish (const char *finish_label,
- const char *cmd_ref,
- struct GNUNET_TIME_Relative timeout)
-{
- const struct GNUNET_TESTING_Command *async_cmd;
- struct SyncState *sync_state;
-
- async_cmd = GNUNET_TESTING_interpreter_lookup_command (cmd_ref);
- sync_state = GNUNET_new (struct SyncState);
- sync_state->async_cmd = async_cmd;
-
- struct GNUNET_TESTING_Command cmd = {
- .cls = sync_state,
- .label = finish_label,
- .run = &start_finish_on_ref,
- .asynchronous_finish = GNUNET_NO
- };
-
- return cmd;
-}
-
-
-const struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_make_unblocking (const struct GNUNET_TESTING_Command cmd)
-{
-
- GNUNET_assert (NULL != cmd.finish);
- const struct GNUNET_TESTING_Command async_cmd = {
- .cls = cmd.cls,
- .label = cmd.label,
- .run = cmd.run,
- .cleanup = cmd.cleanup,
- .traits = cmd.traits,
- .finish = cmd.finish,
- .asynchronous_finish = GNUNET_YES
- };
-
- return async_cmd;
-}
-
-
-/**
* Current command failed, clean up and fail the test case.
*
* @param is interpreter of the test
*/
void
-GNUNET_TESTING_interpreter_fail ()
+GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is)
{
struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
if (GNUNET_SYSERR == is->result)
return; /* ignore, we already failed! */
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "interpreter_fail!\n");
-
if (NULL != cmd)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed at command `%s'\n",
+ cmd->label);
while (GNUNET_TESTING_cmd_is_batch (cmd))
{
cmd = GNUNET_TESTING_cmd_batch_get_current (cmd);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Batch is at command `%s'\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed in batch at command `%s'\n",
cmd->label);
}
-
}
else
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "cmd is NULL.\n");
- }
-
- if (NULL == cmd->label)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Failed at command `%s'\n",
- cmd->label);
-
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "cmd->label is NULL.\n");
+ "Failed with CMD being NULL!\n");
}
-
is->result = GNUNET_SYSERR;
GNUNET_SCHEDULER_shutdown ();
}
@@ -406,8 +193,9 @@ GNUNET_TESTING_interpreter_fail ()
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_end (void)
{
- static struct GNUNET_TESTING_Command cmd;
- cmd.label = NULL;
+ static struct GNUNET_TESTING_Command cmd = {
+ .label = NULL
+ };
return cmd;
}
@@ -417,8 +205,8 @@ GNUNET_TESTING_cmd_end (void)
* Obtain current label.
*/
const char *
-GNUNET_TESTING_interpreter_get_current_label (struct
- GNUNET_TESTING_Interpreter *is)
+GNUNET_TESTING_interpreter_get_current_label (
+ struct GNUNET_TESTING_Interpreter *is)
{
struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
@@ -434,46 +222,36 @@ GNUNET_TESTING_interpreter_get_current_label (struct
static void
interpreter_run (void *cls)
{
- struct FinishTaskClosure *ftc;
struct GNUNET_TESTING_Interpreter *is = cls;
struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
is->task = NULL;
-
if (NULL == cmd->label)
{
-
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Running command END %p\n",
- is);
+ "Running command END\n");
is->result = GNUNET_OK;
GNUNET_SCHEDULER_shutdown ();
return;
}
- else if (NULL != cmd)
+ if (NULL != cmd)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Running command `%s' %p\n",
- cmd->label,
- is);
+ "Running command `%s'\n",
+ cmd->label);
}
cmd->start_time
= cmd->last_req_time
= GNUNET_TIME_absolute_get ();
cmd->num_tries = 1;
cmd->run (cmd->cls,
- cmd,
is);
- if ((NULL != cmd->finish) && (GNUNET_NO == cmd->asynchronous_finish))
+ if ( (NULL != cmd->finish) &&
+ (! cmd->asynchronous_finish) )
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Next task will not be called directly!\n");
- ftc = GNUNET_new (struct FinishTaskClosure);
- ftc->cmd = cmd;
- ftc->is = is;
- is->finish_task = GNUNET_SCHEDULER_add_delayed (CHECK_FINISHED_PERIOD,
- &run_finish_task_next,
- ftc);
+ cmd->finish (cmd->cls,
+ &interpreter_next,
+ is);
}
else
{
@@ -491,37 +269,33 @@ interpreter_run (void *cls)
static void
do_shutdown (void *cls)
{
- (void) cls;
+ struct GNUNET_TESTING_Interpreter *is = cls;
struct GNUNET_TESTING_Command *cmd;
const char *label;
label = is->commands[is->ip].label;
if (NULL == label)
label = "END";
-
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Executing shutdown at `%s'\n",
label);
-
for (unsigned int j = 0;
NULL != (cmd = &is->commands[j])->label;
- j++) {
+ j++)
+ {
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cleaning up cmd %s\n",
cmd->label);
- cmd->cleanup (cmd->cls,
- cmd);
+ cmd->cleanup (cmd->cls);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cleaned up cmd %s\n",
cmd->label);
}
-
if (NULL != is->finish_task)
{
GNUNET_SCHEDULER_cancel (is->finish_task);
- cmd->finish_task = NULL;
+ is->finish_task = NULL;
}
-
if (NULL != is->task)
{
GNUNET_SCHEDULER_cancel (is->task);
@@ -533,18 +307,19 @@ do_shutdown (void *cls)
is->timeout_task = NULL;
}
GNUNET_free (is->commands);
+ GNUNET_free (is);
}
/**
* Function run when the test terminates (good or bad) with timeout.
*
- * @param cls NULL
+ * @param cls the interpreter state
*/
static void
do_timeout (void *cls)
{
- (void) cls;
+ struct GNUNET_TESTING_Interpreter *is = cls;
is->timeout_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -553,30 +328,15 @@ do_timeout (void *cls)
}
-/**
- * Run the testsuite. Note, CMDs are copied into
- * the interpreter state because they are _usually_
- * defined into the "run" method that returns after
- * having scheduled the test interpreter.
- *
- * @param is the interpreter state
- * @param commands the list of command to execute
- * @param timeout how long to wait
- */
-int
+enum GNUNET_GenericReturnValue
GNUNET_TESTING_run (const char *cfg_filename,
struct GNUNET_TESTING_Command *commands,
struct GNUNET_TIME_Relative timeout)
{
+ struct GNUNET_TESTING_Interpreter *is;
unsigned int i;
is = GNUNET_new (struct GNUNET_TESTING_Interpreter);
-
- if (NULL != is->timeout_task)
- {
- GNUNET_SCHEDULER_cancel (is->timeout_task);
- is->timeout_task = NULL;
- }
/* get the number of commands */
for (i = 0; NULL != commands[i].label; i++)
;
@@ -585,15 +345,67 @@ GNUNET_TESTING_run (const char *cfg_filename,
memcpy (is->commands,
commands,
sizeof (struct GNUNET_TESTING_Command) * i);
-
- is->timeout_task = GNUNET_SCHEDULER_add_delayed
- (timeout,
- &do_timeout,
- is);
- GNUNET_SCHEDULER_add_shutdown (&do_shutdown, is);
- is->task = GNUNET_SCHEDULER_add_now (&interpreter_run, is);
+ is->timeout_task
+ = GNUNET_SCHEDULER_add_delayed (timeout,
+ &do_timeout,
+ is);
+ GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
+ is);
+ is->task = GNUNET_SCHEDULER_add_now (&interpreter_run,
+ is);
return GNUNET_OK;
}
+/**
+ * Closure for #loop_run().
+ */
+struct MainParams
+{
+ const char *cfg_filename;
+ struct GNUNET_TESTING_Command *commands;
+ struct GNUNET_TIME_Relative timeout;
+ int rv;
+};
+
+
+/**
+ * Main function to run the test cases.
+ *
+ * @param cls a `struct MainParams *`
+ */
+static void
+loop_run (void *cls)
+{
+ struct MainParams *mp = cls;
+
+ if (GNUNET_OK !=
+ GNUNET_TESTING_run (mp->cfg_filename,
+ mp->commands,
+ mp->timeout))
+ {
+ GNUNET_break (0);
+ mp->rv = EXIT_FAILURE;
+ }
+}
+
+
+int
+GNUNET_TESTING_main (const char *cfg_filename,
+ struct GNUNET_TESTING_Command *commands,
+ struct GNUNET_TIME_Relative timeout)
+{
+ struct MainParams mp = {
+ .cfg_filename = cfg_filename,
+ .commands = commands,
+ .timeout = timeout,
+ .rv = EXIT_SUCCESS
+ };
+
+ GNUNET_SCHEDULER_run (&loop_run,
+ &mp);
+ return mp.rv;
+}
+
+
/* end of testing_api_loop.c */
diff --git a/src/testing/testing_api_trait_cmd.c b/src/testing/testing_api_trait_cmd.c
index 886baee5b..7afa8b264 100644
--- a/src/testing/testing_api_trait_cmd.c
+++ b/src/testing/testing_api_trait_cmd.c
@@ -41,7 +41,7 @@
* @param[out] _cmd where to write the wire details.
* @return #GNUNET_OK on success.
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_TESTING_get_trait_cmd (const struct GNUNET_TESTING_Command *cmd,
unsigned int index,
struct GNUNET_TESTING_Command **_cmd)
diff --git a/src/testing/testing_api_traits.c b/src/testing/testing_api_traits.c
index 66626833d..2f836ddfa 100644
--- a/src/testing/testing_api_traits.c
+++ b/src/testing/testing_api_traits.c
@@ -55,7 +55,7 @@ GNUNET_TESTING_trait_end ()
* @param index index number of the object to extract.
* @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
const void **ret,
const char *trait,