[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: NEWS: libgnunettesting first major testi
From: |
gnunet |
Subject: |
[gnunet] branch master updated: NEWS: libgnunettesting first major testing NG refactor towards getting dependency structure streamlined |
Date: |
Wed, 29 Nov 2023 09:38:42 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 0df5ce8d4 NEWS: libgnunettesting first major testing NG refactor
towards getting dependency structure streamlined
0df5ce8d4 is described below
commit 0df5ce8d4215b83c908de5631b12a3939ce1ca9e
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Wed Nov 29 17:37:50 2023 +0900
NEWS: libgnunettesting first major testing NG refactor towards getting
dependency structure streamlined
---
src/include/Makefile.am | 2 +
src/include/gnunet_core_testing_lib.h | 158 ++++
src/include/gnunet_testing_barrier.h | 15 +-
..._testing_ng_lib.h => gnunet_testing_loop_lib.h} | 583 +++----------
src/include/gnunet_testing_netjail_lib.h | 2 +-
src/include/gnunet_testing_ng_lib.h | 951 +--------------------
src/include/gnunet_testing_plugin.h | 28 +-
src/include/gnunet_transport_testing_ng_lib.h | 170 +++-
src/service/core/Makefile.am | 2 +
src/service/core/core_api_cmd_connecting_peers.c | 29 +-
src/service/core/test_core_plugin_cmd_just_run.c | 1 +
src/service/dht/gnunet-service-dht.c | 2 +-
src/service/dhtu/testing_dhtu_cmd_send.c | 10 +-
src/service/peerstore/peerstore_api.c | 1 -
src/service/testing/Makefile.am | 2 -
src/service/testing/gnunet-cmds-helper.c | 4 +-
src/service/testing/testing.h | 45 +-
src/service/testing/testing_api_cmd_barrier.c | 62 +-
.../testing/testing_api_cmd_barrier_reached.c | 14 +-
src/service/testing/testing_api_cmd_batch.c | 14 +-
.../testing_api_cmd_netjail_start_cmds_helper.c | 85 +-
src/service/testing/testing_api_loop.c | 567 ++++++------
src/service/testing/testing_api_traits.c | 6 +
src/service/testing/testing_cmds.h | 4 +-
src/service/transport/Makefile.am | 2 +
.../transport/test_transport_plugin_cmd_nat_upnp.c | 4 +-
.../test_transport_plugin_cmd_simple_send.c | 4 +-
...st_transport_plugin_cmd_simple_send_broadcast.c | 3 -
.../test_transport_plugin_cmd_simple_send_dv.c | 7 +-
..._transport_plugin_cmd_simple_send_performance.c | 8 +-
.../test_transport_plugin_cmd_udp_backchannel.c | 4 +-
.../testing_api_cmd_start_peer.c | 7 +-
.../testing_api_cmd_stop_peer.c | 2 +-
src/service/transport/transport-testing-cmds.h | 132 +--
.../transport_api_cmd_backchannel_check.c | 4 +-
.../transport/transport_api_cmd_connecting_peers.c | 18 +-
.../transport/transport_api_cmd_send_simple.c | 4 +-
.../transport_api_cmd_send_simple_performance.c | 4 +-
.../transport/transport_api_cmd_start_peer.c | 14 +-
.../transport/transport_api_cmd_stop_peer.c | 4 +-
src/service/transport/transport_api_traits.c | 2 +-
41 files changed, 997 insertions(+), 1983 deletions(-)
diff --git a/src/include/Makefile.am b/src/include/Makefile.am
index cf8c49cf1..5e4582ec2 100644
--- a/src/include/Makefile.am
+++ b/src/include/Makefile.am
@@ -33,6 +33,7 @@ gnunetinclude_HEADERS = \
gnunet_container_lib.h \
gnunet_conversation_service.h \
gnunet_core_service.h \
+ gnunet_core_testing_lib.h \
gnunet_crypto_lib.h \
gnunet_curl_lib.h \
gnunet_datacache_lib.h \
@@ -114,6 +115,7 @@ gnunetinclude_HEADERS = \
gnunet_testing_lib.h \
gnunet_testing_plugin.h \
gnunet_testing_ng_lib.h \
+ gnunet_testing_loop_lib.h \
gnunet_testing_netjail_lib.h \
gnunet_time_lib.h \
gnunet_transport_application_service.h \
diff --git a/src/include/gnunet_core_testing_lib.h
b/src/include/gnunet_core_testing_lib.h
new file mode 100644
index 000000000..afb71b2cf
--- /dev/null
+++ b/src/include/gnunet_core_testing_lib.h
@@ -0,0 +1,158 @@
+/*
+ This file is part of GNUnet
+ Copyright (C) 2021-2023 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
+ */
+
+/**
+ * @brief API for cmds working with core sub system provided by
libgnunetcoretesting
+ * @author t3sserakt
+ */
+#ifndef GNUNET_CORE_TESTING_LIB_H
+#define GNUNET_CORE_TESTING_LIB_H
+
+
+#include "gnunet_util_lib.h"
+#include "gnunet_testing_ng_lib.h"
+
+
+/**
+ * Struct to store information needed in callbacks.
+ */
+// FIXME: breaks naming conventions
+struct GNUNET_TESTING_ConnectPeersState
+{
+ /**
+ * Receive callback
+ */
+ struct GNUNET_MQ_MessageHandler *handlers;
+
+ /**
+ * A map with struct GNUNET_MQ_Handle values for each peer this peer
+ * is connected to.
+ */
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
+
+ /**
+ * Handle for transport.
+ */
+ struct GNUNET_TRANSPORT_ApplicationHandle *ah;
+
+ /**
+ * Core handle.
+ */
+ struct GNUNET_TRANSPORT_CoreHandle *th;
+
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
+ * The testing system of this node.
+ */
+ const struct GNUNET_TESTING_System *tl_system;
+
+ // Label of the cmd which started the test system.
+ const char *create_label;
+
+ /**
+ * Number globally identifying the node.
+ *
+ */
+ uint32_t num;
+
+ /**
+ * Label of the cmd to start a peer.
+ *
+ */
+ const char *start_peer_label;
+
+ /**
+ * The topology of the test setup.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+ /**
+ * Connections to other peers.
+ */
+ struct GNUNET_TESTING_NodeConnection *node_connections_head;
+
+ struct GNUNET_TESTING_Interpreter *is;
+
+ /**
+ * Number of connections.
+ */
+ unsigned int con_num;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by
this cmd.
+ */
+ unsigned int additional_connects;
+
+ /**
+ * Number of connections we already have a notification for.
+ */
+ unsigned int con_num_notified;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by
this cmd we already have a notification for.
+ */
+ unsigned int additional_connects_notified;
+
+ /**
+ * Flag indicating, whether the command is waiting for peers to connect that
are configured to connect.
+ */
+ unsigned int wait_for_connect;
+};
+
+
+/**
+ * FIXME: document properly!
+ * Create command
+ *
+ * @param label name for command
+ * @param start_peer_label Label of the cmd to start a peer.
+ * @param create_label Label of the cmd which started the test system.
+ * @param num Number globally identifying the node.
+ * @param topology The topology for the test setup.
+ * @param additional_connects Number of additional connects this cmd will wait
for not triggered by this cmd.
+ * @return command.
+ */
+struct GNUNET_TESTING_Command
+GNUNET_CORE_cmd_connect_peers (
+ const char *label,
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num,
+ struct GNUNET_TESTING_NetjailTopology *topology,
+ unsigned int additional_connects,
+ unsigned int wait_for_connect,
+ struct GNUNET_MQ_MessageHandler *handlers);
+
+
+/**
+ * Call #op on all simple traits.
+ */
+#define GNUNET_CORE_TESTING_SIMPLE_TRAITS(op) \
+ op (connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState)
+
+GNUNET_CORE_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
+
+
+
+#endif
diff --git a/src/include/gnunet_testing_barrier.h
b/src/include/gnunet_testing_barrier.h
index 4384dd055..b0f4e1c03 100644
--- a/src/include/gnunet_testing_barrier.h
+++ b/src/include/gnunet_testing_barrier.h
@@ -29,10 +29,15 @@
#include "gnunet_testing_plugin.h"
+
+struct GNUNET_TESTING_Barrier;
+
+
#define GNUNET_TESTING_BARRIER_MAX 32
/**
* An entry for a barrier list
+ * FIXME: why is this in the public API!??!
*/
struct GNUNET_TESTING_BarrierListEntry
{
@@ -53,6 +58,7 @@ struct GNUNET_TESTING_BarrierListEntry
/**
* A list to hold barriers provided by plugins
+ * FIXME: why is this in the public API!??!
*/
struct GNUNET_TESTING_BarrierList
{
@@ -87,6 +93,7 @@ GNUNET_TESTING_cmd_barrier_create (
double percentage_to_be_reached,
unsigned int number_to_be_reached);
+
/**
* If this command is executed the the process is signaling the master process
* that it reached a barrier. If this command is synchronous it will block.
@@ -96,7 +103,7 @@ GNUNET_TESTING_cmd_barrier_create (
*
* @param label name for command.
* @param barrier_label The name of the barrier we waited for and which was
reached.
- * @param asynchronous_finish If GNUNET_YES this command will not block.
+ * @param asynchronous_finish If #GNUNET_YES this command will not block.
* @param node_number The global number of the node the cmd runs on.
* @param running_on_master Is this cmd running on the master loop?
* @param write_message Callback to write messages to the master loop.
@@ -106,10 +113,10 @@ struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_barrier_reached (
const char *label,
const char *barrier_label,
- unsigned int asynchronous_finish,
+ unsigned int asynchronous_finish, /* FIXME: why not a bool? */
unsigned int node_number,
- unsigned int running_on_master,
- GNUNET_TESTING_cmd_helper_write_cb write_message);
+ unsigned int running_on_master, /* FIXME: why not a bool? */
+ GNUNET_TESTING_cmd_helper_write_cb write_message); /* FIXME: no 'cls'
closure argument!? */
#endif
/* end of testing_barrier.h */
diff --git a/src/include/gnunet_testing_ng_lib.h
b/src/include/gnunet_testing_loop_lib.h
similarity index 57%
copy from src/include/gnunet_testing_ng_lib.h
copy to src/include/gnunet_testing_loop_lib.h
index 991eddbe4..e4a7653e8 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_loop_lib.h
@@ -19,17 +19,13 @@
*/
/**
- * @brief API for writing an interpreter to test GNUnet components
+ * @brief Central interpreter and command loop for writing an interpreter to
test asynchronous systems
* @author Christian Grothoff <christian@grothoff.org>
* @author Marcello Stanisci
* @author t3sserakt
*/
-#ifndef GNUNET_TESTING_NG_LIB_H
-#define GNUNET_TESTING_NG_LIB_H
-
-
-#include "gnunet_util_lib.h"
-#include "gnunet_testing_lib.h"
+#ifndef GNUNET_TESTING_LOOP_LIB_H
+#define GNUNET_TESTING_LOOP_LIB_H
/**
* Maximum length of label in command
@@ -68,7 +64,7 @@ struct GNUNET_TESTING_AsyncContext
/**
* Interpreter we are part of.
*/
- struct GNUNET_TESTING_Interpreter *is; // Why needed? When available?
+ struct GNUNET_TESTING_Interpreter *is; // FIXME: Why needed? When available?
/**
* Function to call when done.
@@ -89,6 +85,24 @@ struct GNUNET_TESTING_AsyncContext
};
+/**
+ * The asynchronous command of @a ac has failed.
+ *
+ * @param ac command-specific context
+ */
+void
+GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac);
+
+
+/**
+ * The asynchronous command of @a ac has finished.
+ *
+ * @param ac command-specific context
+ */
+void
+GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac);
+
+
/**
* Signature of a function used to start executing a command
* of a test.
@@ -146,6 +160,28 @@ GNUNET_TESTING_command_new (void *cls,
GNUNET_TESTING_CommandGetTraits traits,
struct GNUNET_TESTING_AsyncContext *ac);
+
+/**
+ * Structure with storage space for a label.
+ */
+struct GNUNET_TESTING_CommandLabel
+{
+ char value[GNUNET_TESTING_CMD_MAX_LABEL_LENGTH + 1];
+};
+
+
+/**
+ * Set @a label to @a value. Asserts that @a value is
+ * not longer than #GNUNET_TESTING_CMD_MAX_LABEL_LENGTH.
+ *
+ * @param[out] label label to initialize
+ * @param value value to store into @a label
+ */
+void
+GNUNET_TESTING_set_label (struct GNUNET_TESTING_CommandLabel *label,
+ const char *value);
+
+
/**
* A command to be run by the interpreter.
*/
@@ -159,7 +195,7 @@ struct GNUNET_TESTING_Command
/**
* Label for the command.
*/
- char label[GNUNET_TESTING_CMD_MAX_LABEL_LENGTH + 1];
+ struct GNUNET_TESTING_CommandLabel label;
/**
* Runs the command. Note that upon return, the interpreter
@@ -263,6 +299,7 @@ struct GNUNET_TESTING_Command
* @param is interpreter to lookup command in
* @param label label of the command to lookup.
* @return the command, if it is found, or NULL.
+ * @deprecated (still in use in a very odd way)
*/
// FIXME: think harder about whether this is actually needed, likely not.
const struct GNUNET_TESTING_Command *
@@ -291,6 +328,7 @@ GNUNET_TESTING_interpreter_lookup_command (
* @param is interpreter to lookup command in
* @param label label of the command to lookup.
* @return the command, if it is found, or NULL.
+ * @deprecated (still in use in a very odd way)
*/
const struct GNUNET_TESTING_Command *
GNUNET_TESTING_interpreter_lookup_command_all (
@@ -298,17 +336,6 @@ GNUNET_TESTING_interpreter_lookup_command_all (
const char *label);
-/**
- * Obtain label of the command being now run.
- *
- * @param is interpreter state.
- * @return the label.
- */
-const char *
-GNUNET_TESTING_interpreter_get_current_label (
- struct GNUNET_TESTING_Interpreter *is);
-
-
/**
* Current command failed, clean up and fail the test case.
*
@@ -319,34 +346,7 @@ GNUNET_TESTING_interpreter_fail (struct
GNUNET_TESTING_Interpreter *is);
/**
- * The asynchronous command of @a ac has failed.
- *
- * @param ac command-specific context
- */
-void
-GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac);
-
-
-/**
- * The asynchronous command of @a ac has finished.
- *
- * @param ac command-specific context
- */
-void
-GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac);
-
-
-/**
- * Create command array terminator.
- *
- * @return a end-command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_end (void);
-
-
-/**
- * Turn asynchronous command into non blocking command by setting
+ * Turn asynchronous command into non-blocking command by setting
* asynchronous_finish to true. Modifies (and then returns) @a cmd simply
* setting the bit. By default, most commands are blocking, and by wrapping
* the command construction in this function a blocking command can be turned
@@ -354,7 +354,7 @@ GNUNET_TESTING_cmd_end (void);
* initiating the asynchronous action. Does nothing if the command is
* fundamentally synchronous.
*
- * @param cmd command to make synchronous.
+ * @param[in,out] cmd command to make non-blocking
* @return a finish-command.
*/
struct GNUNET_TESTING_Command
@@ -440,57 +440,17 @@ GNUNET_TESTING_main (struct GNUNET_TESTING_Command
*commands,
struct GNUNET_TIME_Relative timeout);
-/* ************** Specific interpreter commands ************ */
-
-
-/**
- * Check if the command is running.
- * FIXME: Unused function.
- *
- * @param command 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);
-
-/**
- * Check if a command is finished.
- * FIXME: Unused function
- *
- * @param command 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 (const struct GNUNET_TESTING_Command *command);
+/* ************** Fundamental interpreter commands ************ */
/**
- * Create a "signal" CMD.
- *
- * @param label command label.
- * @param process_label label of a command that has a process trait
- * @param process_index index of the process trait at @a process_label //
FIXME: enum? needed?
- * @param signal signal to send to @a process.
- * @return the command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_signal (const char *label,
- const char *process_label,
- unsigned int process_index,
- int signal);
-
-
-/**
- * Sleep for @a duration.
+ * Create command array terminator.
*
- * @param label command label.
- * @param duration time to sleep
- * @return the command.
+ * @return a end-command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_sleep (const char *label,
- struct GNUNET_TIME_Relative duration);
+GNUNET_TESTING_cmd_end (void);
/**
@@ -540,33 +500,6 @@ struct GNUNET_TESTING_Timer
unsigned int num_retries;
};
-/**
- * Command to execute a script synchronously.
- *
- * @param label Label of the command.
- * @param script The name of the script.
- * @param script_argv The arguments of the script.
-*/
-const struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_exec_bash_script (const char *label,
- const char *script,
- char *const script_argv[],
- int argc,
- GNUNET_ChildCompletedCallback cb);
-
-
-/**
- * Retrieve peer identity from the test system with the unique node id.
- *
- * @param num The unique node id.
- * @param tl_system The test system.
- * @return The peer identity wrapping the public key.
- */
-struct GNUNET_PeerIdentity *
-GNUNET_TESTING_get_peer (unsigned int num,
- const struct GNUNET_TESTING_System *tl_system);
-
-
/**
* Obtain performance data from the interpreter.
*
@@ -580,12 +513,12 @@ GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer
*timers);
/* *** Generic trait logic for implementing traits ********* */
/**
- * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
+ * A `struct GNUNET_TESTING_Trait` can be used to exchange data between cmds.
*
* Therefor the cmd which like to provide data to other cmds has to implement
* the trait function, where an array of traits is defined with the help of the
- * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help
of the
- * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to
make
+ * #GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help
of the
+ * #GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to
make
* use of the macros.
*/
struct GNUNET_TESTING_Trait
@@ -610,17 +543,16 @@ struct GNUNET_TESTING_Trait
/**
- * "end" trait. Because traits are offered into arrays,
- * this type of trait is used to mark the end of such arrays;
- * useful when iterating over those.
+ * "end" of traits array. Because traits are offered into arrays, this type
+ * of trait is used to mark the end of such arrays; useful when iterating over
+ * those.
*/
struct GNUNET_TESTING_Trait
GNUNET_TESTING_trait_end (void);
/**
- * Extract a trait.
- * FIXME: Naming. This is something like "contains trait".
+ * Obtain value of a trait from a command.
*
* @param traits the array of all the traits.
* @param[out] ret where to store the result.
@@ -635,291 +567,18 @@ GNUNET_TESTING_get_trait (const struct
GNUNET_TESTING_Trait *traits,
unsigned int index);
-/* ****** Specific traits supported by this component ******* */
-
-
-typedef void *
-(*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
- const struct GNUNET_PeerIdentity *peer);
-
-/**
- * Struct to store information needed in callbacks.
- *
- */
-struct GNUNET_TESTING_ConnectPeersState
-{
- /**
- * Receive callback
- */
- struct GNUNET_MQ_MessageHandler *handlers;
-
- /**
- * A map with struct GNUNET_MQ_Handle values for each peer this peer
- * is connected to.
- */
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
-
- /**
- * Handle for transport.
- */
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
-
- /**
- * Core handle.
- */
- struct GNUNET_TRANSPORT_CoreHandle *th;
-
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- /**
- * The testing system of this node.
- */
- const struct GNUNET_TESTING_System *tl_system;
-
- // Label of the cmd which started the test system.
- const char *create_label;
-
- /**
- * Number globally identifying the node.
- *
- */
- uint32_t num;
-
- /**
- * Label of the cmd to start a peer.
- *
- */
- const char *start_peer_label;
-
- /**
- * The topology of the test setup.
- */
- struct GNUNET_TESTING_NetjailTopology *topology;
-
- /**
- * Connections to other peers.
- */
- struct GNUNET_TESTING_NodeConnection *node_connections_head;
-
- struct GNUNET_TESTING_Interpreter *is;
-
- /**
- * Number of connections.
- */
- unsigned int con_num;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd.
- */
- unsigned int additional_connects;
-
- /**
- * Number of connections we already have a notification for.
- */
- unsigned int con_num_notified;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd we already have a notification for.
- */
- unsigned int additional_connects_notified;
-
- /**
- * Flag indicating, whether the command is waiting for peers to connect that
are configured to connect.
- */
- unsigned int wait_for_connect;
-};
-
-/**
- * Struct to store information needed in callbacks.
- *
- */
-struct ConnectPeersState
-{
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- GNUNET_TESTING_notify_connect_cb notify_connect;
-
- /**
- * The testing system of this node.
- */
- const struct GNUNET_TESTING_System *tl_system;
-
- // Label of the cmd which started the test system.
- const char *create_label;
-
- /**
- * Number globally identifying the node.
- *
- */
- uint32_t num;
-
- /**
- * Label of the cmd to start a peer.
- *
- */
- const char *start_peer_label;
-
- /**
- * The topology of the test setup.
- */
- struct GNUNET_TESTING_NetjailTopology *topology;
-
- /**
- * Connections to other peers.
- */
- struct GNUNET_TESTING_NodeConnection *node_connections_head;
-
- struct GNUNET_TESTING_Interpreter *is;
-
- /**
- * Number of connections.
- */
- unsigned int con_num;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd.
- */
- unsigned int additional_connects;
-
- /**
- * Number of connections we already have a notification for.
- */
- unsigned int con_num_notified;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd we already have a notification for.
- */
- unsigned int additional_connects_notified;
-
- /**
- * Flag indicating, whether the command is waiting for peers to connect that
are configured to connect.
- */
- unsigned int wait_for_connect;
-};
-
-
-struct GNUNET_TESTING_StartPeerState
-{
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- /**
- * The ip of a node.
- */
- char *node_ip;
-
- /**
- * Receive callback
- */
- struct GNUNET_MQ_MessageHandler *handlers;
-
- /**
- * GNUnet configuration file used to start a peer.
- */
- char *cfgname;
-
- /**
- * Peer's configuration
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
- */
- struct GNUNET_TESTING_Peer *peer;
-
- /**
- * Peer identity
- */
- struct GNUNET_PeerIdentity id;
-
- /**
- * Peer's transport service handle
- */
- struct GNUNET_TRANSPORT_CoreHandle *th;
-
- /**
- * Application handle
- */
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
-
- /**
- * Peer's PEERSTORE Handle
- */
- struct GNUNET_PEERSTORE_Handle *ph;
-
- /**
- * Hello get task
- */
- struct GNUNET_SCHEDULER_Task *rh_task;
-
- /**
- * Peer's transport get hello handle to retrieve peer's HELLO message
- */
- struct GNUNET_PEERSTORE_IterateContext *pic;
-
- /**
- * Hello
- */
- char *hello;
-
- /**
- * Hello size
- */
- size_t hello_size;
-
- /**
- * The label of the command which was started by calling
GNUNET_TESTING_cmd_system_create.
- */
- char *system_label;
-
- /**
- * An unique number to identify the peer
- */
- unsigned int no;
-
- /**
- * A map with struct GNUNET_MQ_Handle values for each peer this peer
- * is connected to.
- */
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
-
- /**
- * Test setup for this peer.
- */
- const struct GNUNET_TESTING_System *tl_system;
-
- /**
- * Callback which is called on neighbour connect events.
- */
- GNUNET_TESTING_notify_connect_cb notify_connect;
-
- /**
- * Flag indicating, if udp broadcast should be switched on.
- */
- enum GNUNET_GenericReturnValue broadcast;
-};
-
/**
* Create headers for a trait with name @a name for
* statically allocated data of type @a type.
*/
#define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
- type **ret); \
+ type **ret); \
struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
+ GNUNET_TESTING_make_trait_ ## name ( \
type * value);
@@ -928,26 +587,26 @@ struct GNUNET_TESTING_StartPeerState
* allocated data of type @a type.
*/
#define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
type * *ret) \
- { \
- if (NULL == cmd->traits) return GNUNET_SYSERR; \
- return cmd->traits (cmd->cls, \
- (const void **) ret, \
+ { \
+ if (NULL == cmd->traits) return GNUNET_SYSERR; \
+ return cmd->traits (cmd->cls, \
+ (const void **) ret, \
GNUNET_S (name), \
- 0); \
- } \
+ 0); \
+ } \
struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
- type * value) \
- { \
+ GNUNET_TESTING_make_trait_ ## name ( \
+ type * value) \
+ { \
struct GNUNET_TESTING_Trait ret = { \
.trait_name = GNUNET_S (name), \
- .ptr = (const void *) value \
- }; \
- return ret; \
+ .ptr = (const void *) value \
+ }; \
+ return ret; \
}
@@ -956,14 +615,14 @@ struct GNUNET_TESTING_StartPeerState
* statically allocated data of type @a type.
*/
#define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
- unsigned int index, \
- type **ret); \
+ unsigned int index, \
+ type **ret); \
struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
- unsigned int index, \
+ GNUNET_TESTING_make_trait_ ## name ( \
+ unsigned int index, \
type *value);
@@ -972,65 +631,49 @@ struct GNUNET_TESTING_StartPeerState
* allocated data of type @a type.
*/
#define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
+ enum GNUNET_GenericReturnValue \
+ GNUNET_TESTING_get_trait_ ## name ( \
const struct GNUNET_TESTING_Command *cmd, \
- unsigned int index, \
+ unsigned int index, \
type * *ret) \
- { \
- if (NULL == cmd->traits) return GNUNET_SYSERR; \
- return cmd->traits (cmd->cls, \
- (const void **) ret, \
+ { \
+ if (NULL == cmd->traits) return GNUNET_SYSERR; \
+ return cmd->traits (cmd->cls, \
+ (const void **) ret, \
GNUNET_S (name), \
- index); \
- } \
+ index); \
+ } \
struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
- unsigned int index, \
- type * value) \
- { \
+ GNUNET_TESTING_make_trait_ ## name ( \
+ unsigned int index, \
+ type * value) \
+ { \
struct GNUNET_TESTING_Trait ret = { \
- .index = index, \
+ .index = index, \
.trait_name = GNUNET_S (name), \
- .ptr = (const void *) value \
- }; \
- return ret; \
+ .ptr = (const void *) value \
+ }; \
+ return ret; \
}
/**
- * Call #op on all simple traits.
+ * Call #op on all simple traits needed by loop logic.
*/
-#define GNUNET_TESTING_SIMPLE_TRAITS(op) \
- op (batch_cmds, struct GNUNET_TESTING_Command *) \
- op (process, struct GNUNET_OS_Process *) \
- op (peer_id, const struct GNUNET_PeerIdentity) \
- op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
- op (hello_size, const size_t) \
- op (hello, const char) \
- op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
- op (connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState) \
- op (state, const struct GNUNET_TESTING_StartPeerState) \
- op (broadcast, const enum GNUNET_GenericReturnValue)
+#define GNUNET_TESTING_LOOP_SIMPLE_TRAITS(op) \
+ op (batch_cmds, struct GNUNET_TESTING_Command *)
+
+
+GNUNET_TESTING_LOOP_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
/**
- * Call #op on all indexed traits.
+ * Call #op on all indexed traits needed by loop logic.
*/
-#define GNUNET_TESTING_INDEXED_TRAITS(op) \
- op (uint32, const uint32_t) \
- op (uint64, const uint64_t) \
- op (int64, const int64_t) \
- op (uint, const unsigned int) \
- op (string, const char) \
- op (cmd, const struct GNUNET_TESTING_Command) \
- op (uuid, const struct GNUNET_Uuid) \
- op (time, const struct GNUNET_TIME_Absolute) \
- op (absolute_time, const struct GNUNET_TIME_Absolute) \
- op (relative_time, const struct GNUNET_TIME_Relative)
-
-GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
-
-GNUNET_TESTING_INDEXED_TRAITS (GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT)
+#define GNUNET_TESTING_LOOP_INDEXED_TRAITS(op) \
+ op (cmd, const struct GNUNET_TESTING_Command)
+
+GNUNET_TESTING_LOOP_INDEXED_TRAITS (GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT)
+
#endif
diff --git a/src/include/gnunet_testing_netjail_lib.h
b/src/include/gnunet_testing_netjail_lib.h
index 9d016b33a..0d58e0f62 100644
--- a/src/include/gnunet_testing_netjail_lib.h
+++ b/src/include/gnunet_testing_netjail_lib.h
@@ -30,7 +30,6 @@
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_plugin.h"
-struct GNUNET_TESTING_AsyncContext;
/**
* Router of a netjail subnet.
@@ -543,4 +542,5 @@ GNUNET_TESTING_cmd_start_peer (const char *label,
GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
+
#endif
diff --git a/src/include/gnunet_testing_ng_lib.h
b/src/include/gnunet_testing_ng_lib.h
index 991eddbe4..7b19a0ab4 100644
--- a/src/include/gnunet_testing_ng_lib.h
+++ b/src/include/gnunet_testing_ng_lib.h
@@ -19,7 +19,7 @@
*/
/**
- * @brief API for writing an interpreter to test GNUnet components
+ * @brief Meta-header for next-generation testing logic
* @author Christian Grothoff <christian@grothoff.org>
* @author Marcello Stanisci
* @author t3sserakt
@@ -29,440 +29,13 @@
#include "gnunet_util_lib.h"
-#include "gnunet_testing_lib.h"
-
-/**
- * Maximum length of label in command
- */
-#define GNUNET_TESTING_CMD_MAX_LABEL_LENGTH 127
-
-/* ********************* Helper functions ********************* */
-
-/**
- * Print failing line number and trigger shutdown. Useful
- * quite any time after the command "run" method has been called.
- */
-#define GNUNET_TESTING_FAIL(is) \
- do \
- { \
- GNUNET_break (0); \
- GNUNET_TESTING_interpreter_fail (is); \
- return; \
- } while (0)
-
-
-/* ******************* Generic interpreter logic ************ */
-
-/**
- * Global state of the interpreter, used by a command
- * to access information about other commands.
- */
-struct GNUNET_TESTING_Interpreter;
-
-/**
- * State each asynchronous command must have in its closure.
- */
-struct GNUNET_TESTING_AsyncContext
-{
-
- /**
- * Interpreter we are part of.
- */
- struct GNUNET_TESTING_Interpreter *is; // Why needed? When available?
-
- /**
- * Function to call when done.
- */
- GNUNET_SCHEDULER_TaskCallback cont;
-
- /**
- * Closure for @e cont.
- */
- void *cont_cls;
-
- /**
- * Indication if the command finished (#GNUNET_OK).
- * #GNUNET_NO if it did not finish,
- * #GNUNET_SYSERR if it failed.
- */
- enum GNUNET_GenericReturnValue finished;
-};
-
-
-/**
- * Signature of a function used to start executing a command
- * of a test.
- *
- * @param cls closure
- * @param is interpreter running the command
- */
-typedef void
-(*GNUNET_TESTING_CommandRunRoutine)(void *cls,
- struct GNUNET_TESTING_Interpreter *is);
-
-
-/**
- * Signature of a function used to clean up resources allocated
- * by a command.
- *
- * @param cls closure
- */
-typedef void
-(*GNUNET_TESTING_CommandCleanupRoutine)(void *cls);
-
-
-/**
- * Signature of a function used to extract traits exposed by a
- * command.
- *
- * @param cls closure
- * @param[out] ret where to return the trait data
- * @param trait name of the trait to return
- * @param index index of the trait (for traits that are indexed)
- * @return #GNUNET_OK on success
- */
-typedef enum GNUNET_GenericReturnValue
-(*GNUNET_TESTING_CommandGetTraits) (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index);
-
-/**
- * Create a new command
- *
- * @param cls the closure
- * @param label the Label. Maximum length is
GNUNET_TESTING_CMD_MAX_LABEL_LENGTH
- * @param run the run routing
- * @param cleanup the cleanup function
- * @param traits the traits function (optional)
- * @param the async context
- * @return the command the function cannot fail
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_command_new (void *cls,
- const char *label,
- GNUNET_TESTING_CommandRunRoutine run,
- GNUNET_TESTING_CommandCleanupRoutine cleanup,
- GNUNET_TESTING_CommandGetTraits traits,
- struct GNUNET_TESTING_AsyncContext *ac);
-
-/**
- * A command to be run by the interpreter.
- */
-struct GNUNET_TESTING_Command
-{
- /**
- * Closure for all commands with command-specific context information.
- */
- void *cls;
-
- /**
- * Label for the command.
- */
- char label[GNUNET_TESTING_CMD_MAX_LABEL_LENGTH + 1];
-
- /**
- * Runs the command. Note that upon return, the interpreter
- * will not automatically run the next command, as the command
- * may continue asynchronously in other scheduler tasks. Thus,
- * the command must ensure to eventually call
- * #GNUNET_TESTING_interpreter_next() or
- * #GNUNET_TESTING_interpreter_fail().
- *
- * If this function creates some asynchronous activity, it should
- * initialize @e finish to a function that can be used to wait for
- * the asynchronous activity to terminate.
- *
- * @param cls closure
- * @param is interpreter state
- */
- GNUNET_TESTING_CommandRunRoutine run;
-
- /**
- * Pointer to the asynchronous context in the command's
- * closure. Used by the
- * #GNUNET_TESTING_async_finish() and
- * #GNUNET_TESTING_async_fail() functions.
- *
- * Must be NULL if a command is synchronous.
- */
- struct GNUNET_TESTING_AsyncContext *ac;
-
- /**
- * Clean up after the command. Run during forced termination
- * (CTRL-C) or test failure or test success.
- *
- * @param cls closure
- */
- GNUNET_TESTING_CommandCleanupRoutine cleanup;
-
- /**
- * Extract information from a command that is useful for other
- * commands. Can be NULL if a command has no traits.
- *
- * @param cls closure
- * @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,
- * #GNUNET_NO if no trait was found
- */
- GNUNET_TESTING_CommandGetTraits traits;
-
- /**
- * When did the execution of this command start?
- */
- struct GNUNET_TIME_Absolute start_time;
-
- /**
- * When did the execution of this command finish?
- */
- struct GNUNET_TIME_Absolute finish_time;
-
- /**
- * When did we start the last run of this command? Delta to @e finish_time
- * gives the latency for the last successful run. Useful in case @e
- * num_tries was positive and the command was run multiple times. In that
- * case, the @e start_time gives the time when we first tried to run the
- * command, so the difference between @e start_time and @e finish_time would
- * be the time all of the @e num_tries took, while the delta to @e
- * last_req_time is the time the last (successful) execution took.
- */
- struct GNUNET_TIME_Absolute last_req_time;
-
- /**
- * In case @e asynchronous_finish is true, how long should we wait for this
- * command to complete? If @e finish did not complete after this amount of
- * time, the interpreter will fail. Should be set generously to ensure
- * tests do not fail on slow systems.
- */
- struct GNUNET_TIME_Relative default_timeout;
-
- /**
- * How often did we try to execute this command? (In case it is a request
- * that is repated.) Note that a command must have some built-in retry
- * mechanism for this value to be useful.
- */
- unsigned int num_tries;
-
- /**
- * If "true", the interpreter should not immediately call
- * @e finish, even if @e finish is non-NULL. Otherwise,
- * #GNUNET_TESTING_cmd_finish() must be used
- * to ensure that a command actually completed.
- */
- bool asynchronous_finish;
-
-};
-
-
-/**
- * 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.
- */
-// FIXME: think harder about whether this is actually needed, likely not.
-const struct GNUNET_TESTING_Command *
-GNUNET_TESTING_interpreter_lookup_future_command (
- struct GNUNET_TESTING_Interpreter *is,
- const char *label);
-
-
-/**
- * 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);
-
-
-/**
- * Lookup command by label.
- * All commands, first into the past, then into the future 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_all (
- struct GNUNET_TESTING_Interpreter *is,
- const char *label);
-
-
-/**
- * Obtain label of the command being now run.
- *
- * @param is interpreter state.
- * @return the label.
- */
-const char *
-GNUNET_TESTING_interpreter_get_current_label (
- struct GNUNET_TESTING_Interpreter *is);
-
-
-/**
- * Current command failed, clean up and fail the test case.
- *
- * @param is interpreter state.
- */
-void
-GNUNET_TESTING_interpreter_fail (struct GNUNET_TESTING_Interpreter *is);
-
-
-/**
- * The asynchronous command of @a ac has failed.
- *
- * @param ac command-specific context
- */
-void
-GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac);
-
-
-/**
- * The asynchronous command of @a ac has finished.
- *
- * @param ac command-specific context
- */
-void
-GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac);
-
-
-/**
- * Create command array terminator.
- *
- * @return a end-command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_end (void);
-
-
-/**
- * Turn asynchronous command into non blocking command by setting
- * asynchronous_finish to true. Modifies (and then returns) @a cmd simply
- * setting the bit. By default, most commands are blocking, and by wrapping
- * the command construction in this function a blocking command can be turned
- * into an asynchronous command where the interpreter continues after
- * initiating the asynchronous action. Does nothing if the command is
- * fundamentally synchronous.
- *
- * @param cmd command to make synchronous.
- * @return a finish-command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_make_unblocking (struct GNUNET_TESTING_Command cmd);
-
-
-/**
- * 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);
-
-
-/**
- * Make the instruction pointer point to @a target_label
- * only if @a counter is greater than zero.
- *
- * @param label command label
- * @param target_label label of the new instruction pointer's destination
after the jump;
- * must be before the current instruction
- * @param counter counts how many times the rewinding is to happen.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_rewind_ip (const char *label,
- const char *target_label,
- unsigned int counter);
-
-
-/**
- * Function called with the final result of the test.
- * FIXME: This may want to use a GNUNET_ErrorCode (namespaced, e.g.
- * GNUNET_EC_TESTING_*)
- *
- * @param cls closure
- * @param rv #GNUNET_OK if the test passed
- */
-typedef void
-(*GNUNET_TESTING_ResultCallback)(void *cls,
- enum GNUNET_GenericReturnValue rv);
-
-
-/**
- * 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 commands the array of command to execute
- * @param timeout how long to wait for each command to execute
- * @param rc function to call with the final result
- * @param rc_cls closure for @a rc
- * @return The interpreter.
- */
-struct GNUNET_TESTING_Interpreter *
-GNUNET_TESTING_run (const struct GNUNET_TESTING_Command *commands,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_TESTING_ResultCallback rc,
- void *rc_cls);
-
-
-/**
- * Start a GNUnet scheduler event loop and
- * run the testsuite. Return 0 upon success.
- * Expected to be called directly from main().
- * FIXME: Why is this commands array here not const?
- *
- * @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 (struct GNUNET_TESTING_Command *commands,
- struct GNUNET_TIME_Relative timeout);
-
-
-/* ************** Specific interpreter commands ************ */
-
-/**
- * Check if the command is running.
- * FIXME: Unused function.
- *
- * @param command 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);
+/* FIXME: legacy test header, to be removed!! */
+#include "gnunet_testing_lib.h"
-
-/**
- * Check if a command is finished.
- * FIXME: Unused function
- *
- * @param command 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 (const struct GNUNET_TESTING_Command *command);
+#include "gnunet_testing_plugin.h"
+#include "gnunet_testing_loop_lib.h"
+#include "gnunet_testing_netjail_lib.h"
/**
@@ -470,14 +43,12 @@ GNUNET_TESTING_finished (const struct
GNUNET_TESTING_Command *command);
*
* @param label command label.
* @param process_label label of a command that has a process trait
- * @param process_index index of the process trait at @a process_label //
FIXME: enum? needed?
* @param signal signal to send to @a process.
* @return the command.
*/
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_signal (const char *label,
const char *process_label,
- unsigned int process_index,
int signal);
@@ -493,56 +64,11 @@ GNUNET_TESTING_cmd_sleep (const char *label,
struct GNUNET_TIME_Relative duration);
-/**
- * Create a "batch" command. Such command takes a end_CMD-terminated array of
- * CMDs and executed them. Once it hits the end CMD, it passes the control to
- * the next top-level CMD, regardless of it being another batch or ordinary
- * CMD.
- *
- * @param label the command label.
- * @param batch array of CMDs to execute.
- * @return the command.
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_batch (const char *label,
- struct GNUNET_TESTING_Command *batch);
-
-
-/**
- * Performance counter.
- */
-struct GNUNET_TESTING_Timer
-{
- /**
- * For which type of commands.
- */
- const char *prefix;
-
- /**
- * Total time spend in all commands of this type.
- */
- struct GNUNET_TIME_Relative total_duration;
-
- /**
- * Total time spend waiting for the *successful* exeuction
- * in all commands of this type.
- */
- struct GNUNET_TIME_Relative success_latency;
-
- /**
- * Number of commands summed up.
- */
- unsigned int num_commands;
-
- /**
- * Number of retries summed up.
- */
- unsigned int num_retries;
-};
-
/**
* Command to execute a script synchronously.
*
+ * FIXME: is this accurate? How is this limited to BASH scripts or even
scripts?
+ *
* @param label Label of the command.
* @param script The name of the script.
* @param script_argv The arguments of the script.
@@ -551,486 +77,39 @@ const struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_exec_bash_script (const char *label,
const char *script,
char *const script_argv[],
+ // FIXME: wtf are these two args here
for!?
int argc,
GNUNET_ChildCompletedCallback cb);
-/**
- * Retrieve peer identity from the test system with the unique node id.
- *
- * @param num The unique node id.
- * @param tl_system The test system.
- * @return The peer identity wrapping the public key.
- */
-struct GNUNET_PeerIdentity *
-GNUNET_TESTING_get_peer (unsigned int num,
- const struct GNUNET_TESTING_System *tl_system);
-
-/**
- * Obtain performance data from the interpreter.
- *
- * @param[in,out] timers what commands (by label) to obtain runtimes for
- * @return the command
- */
-struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_stat (struct GNUNET_TESTING_Timer *timers);
-
-
-/* *** Generic trait logic for implementing traits ********* */
-
-/**
- * A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
- *
- * Therefor the cmd which like to provide data to other cmds has to implement
- * the trait function, where an array of traits is defined with the help of the
- * GNUNET_TESTING_make_trait_ macro. The data can be retrieved with the help
of the
- * GNUNET_TESTING_get_trait_ macro. Traits name and type must be defined to
make
- * use of the macros.
- */
-struct GNUNET_TESTING_Trait
-{
- /**
- * Index number associated with the trait. This gives the
- * possibility to have _multiple_ traits on offer under the
- * same name.
- */
- unsigned int index;
-
- /**
- * Trait type, for example "reserve-pub" or "coin-priv".
- */
- const char *trait_name;
-
- /**
- * Pointer to the piece of data to offer.
- */
- const void *ptr;
-};
-
-
-/**
- * "end" trait. Because traits are offered into arrays,
- * this type of trait is used to mark the end of such arrays;
- * useful when iterating over those.
- */
-struct GNUNET_TESTING_Trait
-GNUNET_TESTING_trait_end (void);
-
-
-/**
- * Extract a trait.
- * FIXME: Naming. This is something like "contains trait".
- *
- * @param traits the array of all the traits.
- * @param[out] ret where to store the result.
- * @param trait type of the trait to extract.
- * @param index index number of the trait to extract.
- * @return #GNUNET_OK when the trait is found.
- */
-enum GNUNET_GenericReturnValue
-GNUNET_TESTING_get_trait (const struct GNUNET_TESTING_Trait *traits,
- const void **ret,
- const char *trait,
- unsigned int index);
-
-
-/* ****** Specific traits supported by this component ******* */
-
-
-typedef void *
-(*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
- const struct GNUNET_PeerIdentity *peer);
-
-/**
- * Struct to store information needed in callbacks.
- *
- */
-struct GNUNET_TESTING_ConnectPeersState
-{
- /**
- * Receive callback
- */
- struct GNUNET_MQ_MessageHandler *handlers;
-
- /**
- * A map with struct GNUNET_MQ_Handle values for each peer this peer
- * is connected to.
- */
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
-
- /**
- * Handle for transport.
- */
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
-
- /**
- * Core handle.
- */
- struct GNUNET_TRANSPORT_CoreHandle *th;
-
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- /**
- * The testing system of this node.
- */
- const struct GNUNET_TESTING_System *tl_system;
-
- // Label of the cmd which started the test system.
- const char *create_label;
-
- /**
- * Number globally identifying the node.
- *
- */
- uint32_t num;
-
- /**
- * Label of the cmd to start a peer.
- *
- */
- const char *start_peer_label;
-
- /**
- * The topology of the test setup.
- */
- struct GNUNET_TESTING_NetjailTopology *topology;
-
- /**
- * Connections to other peers.
- */
- struct GNUNET_TESTING_NodeConnection *node_connections_head;
-
- struct GNUNET_TESTING_Interpreter *is;
-
- /**
- * Number of connections.
- */
- unsigned int con_num;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd.
- */
- unsigned int additional_connects;
-
- /**
- * Number of connections we already have a notification for.
- */
- unsigned int con_num_notified;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd we already have a notification for.
- */
- unsigned int additional_connects_notified;
-
- /**
- * Flag indicating, whether the command is waiting for peers to connect that
are configured to connect.
- */
- unsigned int wait_for_connect;
-};
-
-/**
- * Struct to store information needed in callbacks.
- *
- */
-struct ConnectPeersState
-{
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- GNUNET_TESTING_notify_connect_cb notify_connect;
-
- /**
- * The testing system of this node.
- */
- const struct GNUNET_TESTING_System *tl_system;
-
- // Label of the cmd which started the test system.
- const char *create_label;
-
- /**
- * Number globally identifying the node.
- *
- */
- uint32_t num;
-
- /**
- * Label of the cmd to start a peer.
- *
- */
- const char *start_peer_label;
-
- /**
- * The topology of the test setup.
- */
- struct GNUNET_TESTING_NetjailTopology *topology;
-
- /**
- * Connections to other peers.
- */
- struct GNUNET_TESTING_NodeConnection *node_connections_head;
-
- struct GNUNET_TESTING_Interpreter *is;
-
- /**
- * Number of connections.
- */
- unsigned int con_num;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd.
- */
- unsigned int additional_connects;
-
- /**
- * Number of connections we already have a notification for.
- */
- unsigned int con_num_notified;
-
- /**
- * Number of additional connects this cmd will wait for not triggered by
this cmd we already have a notification for.
- */
- unsigned int additional_connects_notified;
-
- /**
- * Flag indicating, whether the command is waiting for peers to connect that
are configured to connect.
- */
- unsigned int wait_for_connect;
-};
-
-
-struct GNUNET_TESTING_StartPeerState
-{
- /**
- * Context for our asynchronous completion.
- */
- struct GNUNET_TESTING_AsyncContext ac;
-
- /**
- * The ip of a node.
- */
- char *node_ip;
-
- /**
- * Receive callback
- */
- struct GNUNET_MQ_MessageHandler *handlers;
-
- /**
- * GNUnet configuration file used to start a peer.
- */
- char *cfgname;
-
- /**
- * Peer's configuration
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- /**
- * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
- */
- struct GNUNET_TESTING_Peer *peer;
-
- /**
- * Peer identity
- */
- struct GNUNET_PeerIdentity id;
-
- /**
- * Peer's transport service handle
- */
- struct GNUNET_TRANSPORT_CoreHandle *th;
-
- /**
- * Application handle
- */
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
-
- /**
- * Peer's PEERSTORE Handle
- */
- struct GNUNET_PEERSTORE_Handle *ph;
-
- /**
- * Hello get task
- */
- struct GNUNET_SCHEDULER_Task *rh_task;
-
- /**
- * Peer's transport get hello handle to retrieve peer's HELLO message
- */
- struct GNUNET_PEERSTORE_IterateContext *pic;
-
- /**
- * Hello
- */
- char *hello;
-
- /**
- * Hello size
- */
- size_t hello_size;
-
- /**
- * The label of the command which was started by calling
GNUNET_TESTING_cmd_system_create.
- */
- char *system_label;
-
- /**
- * An unique number to identify the peer
- */
- unsigned int no;
-
- /**
- * A map with struct GNUNET_MQ_Handle values for each peer this peer
- * is connected to.
- */
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
-
- /**
- * Test setup for this peer.
- */
- const struct GNUNET_TESTING_System *tl_system;
-
- /**
- * Callback which is called on neighbour connect events.
- */
- GNUNET_TESTING_notify_connect_cb notify_connect;
-
- /**
- * Flag indicating, if udp broadcast should be switched on.
- */
- enum GNUNET_GenericReturnValue broadcast;
-};
-
-
-/**
- * Create headers for a trait with name @a name for
- * statically allocated data of type @a type.
- */
-#define GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
- const struct GNUNET_TESTING_Command *cmd, \
- type **ret); \
- struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
- type * value);
-
-
-/**
- * Create C implementation for a trait with name @a name for statically
- * allocated data of type @a type.
- */
-#define GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
- const struct GNUNET_TESTING_Command *cmd, \
- type * *ret) \
- { \
- if (NULL == cmd->traits) return GNUNET_SYSERR; \
- return cmd->traits (cmd->cls, \
- (const void **) ret, \
- GNUNET_S (name), \
- 0); \
- } \
- struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
- type * value) \
- { \
- struct GNUNET_TESTING_Trait ret = { \
- .trait_name = GNUNET_S (name), \
- .ptr = (const void *) value \
- }; \
- return ret; \
- }
-
-
-/**
- * Create headers for a trait with name @a name for
- * statically allocated data of type @a type.
- */
-#define GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
- const struct GNUNET_TESTING_Command *cmd, \
- unsigned int index, \
- type **ret); \
- struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
- unsigned int index, \
- type *value);
-
-
-/**
- * Create C implementation for a trait with name @a name for statically
- * allocated data of type @a type.
- */
-#define GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TESTING_get_trait_ ## name ( \
- const struct GNUNET_TESTING_Command *cmd, \
- unsigned int index, \
- type * *ret) \
- { \
- if (NULL == cmd->traits) return GNUNET_SYSERR; \
- return cmd->traits (cmd->cls, \
- (const void **) ret, \
- GNUNET_S (name), \
- index); \
- } \
- struct GNUNET_TESTING_Trait \
- GNUNET_TESTING_make_trait_ ## name ( \
- unsigned int index, \
- type * value) \
- { \
- struct GNUNET_TESTING_Trait ret = { \
- .index = index, \
- .trait_name = GNUNET_S (name), \
- .ptr = (const void *) value \
- }; \
- return ret; \
- }
+/* ****** Specific traits needed by this component ******* */
/**
* Call #op on all simple traits.
*/
#define GNUNET_TESTING_SIMPLE_TRAITS(op) \
- op (batch_cmds, struct GNUNET_TESTING_Command *) \
- op (process, struct GNUNET_OS_Process *) \
- op (peer_id, const struct GNUNET_PeerIdentity) \
- op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
- op (hello_size, const size_t) \
- op (hello, const char) \
- op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
- op (connect_peer_state, const struct GNUNET_TESTING_ConnectPeersState) \
- op (state, const struct GNUNET_TESTING_StartPeerState) \
- op (broadcast, const enum GNUNET_GenericReturnValue)
+ op (process, struct GNUNET_OS_Process *)
+
+GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
/**
* Call #op on all indexed traits.
*/
-#define GNUNET_TESTING_INDEXED_TRAITS(op) \
+#define GNUNET_TESTING_INDEXED_TRAITS(op) \
op (uint32, const uint32_t) \
op (uint64, const uint64_t) \
op (int64, const int64_t) \
op (uint, const unsigned int) \
op (string, const char) \
- op (cmd, const struct GNUNET_TESTING_Command) \
op (uuid, const struct GNUNET_Uuid) \
op (time, const struct GNUNET_TIME_Absolute) \
op (absolute_time, const struct GNUNET_TIME_Absolute) \
op (relative_time, const struct GNUNET_TIME_Relative)
-GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
-
GNUNET_TESTING_INDEXED_TRAITS (GNUNET_TESTING_MAKE_DECL_INDEXED_TRAIT)
+
#endif
diff --git a/src/include/gnunet_testing_plugin.h
b/src/include/gnunet_testing_plugin.h
index d6a3560ef..b030bc8a8 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -38,8 +38,6 @@ extern "C"
#endif
#endif
-struct GNUNET_TESTING_Barrier;
-
/**
* Callback function to write messages from the helper process running on a
netjail node to the master process.
@@ -57,6 +55,7 @@ typedef void
typedef void
(*GNUNET_TESTING_cmd_helper_finish_cb) ();
+
/**
* Function to be implemented for each test case plugin which starts the test
case on a netjail node.
*
@@ -76,17 +75,17 @@ typedef void
* @return Returns The struct GNUNET_TESTING_Interpreter of the command loop
running on this netjail node.
*/
typedef struct GNUNET_TESTING_Interpreter *
-(*GNUNET_TESTING_PLUGIN_StartTestCase) (GNUNET_TESTING_cmd_helper_write_cb
- write_message,
- const char *router_ip,
- const char *node_ip,
- const char *n,
- const char *m,
- const char *local_m,
- const char *topology_data,
- unsigned int *read_file,
- GNUNET_TESTING_cmd_helper_finish_cb
- finish_cb);
+(*GNUNET_TESTING_PLUGIN_StartTestCase) (
+ GNUNET_TESTING_cmd_helper_write_cb write_message,
+ const char *router_ip,
+ const char *node_ip,
+ const char *n,
+ const char *m,
+ const char *local_m,
+ const char *topology_data,
+ unsigned int *read_file,
+ GNUNET_TESTING_cmd_helper_finish_cb
+ finish_cb);
/**
* DEPRECATED
@@ -104,15 +103,18 @@ typedef void
* GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_LOCAL_TESTS_PREPARED. This will finish
the blocking command
* GNUNET_TESTING_cmd_local_test_prepared which was execute right after the
command
* GNUNET_TRANSPORT_cmd_connect_peers.
+ * FIXME: do not use ALL CAPS
*/
typedef void
(*GNUNET_TESTING_PLUGIN_ALL_LOCAL_TESTS_PREPARED) ();
+
/**
* This function returns a struct GNUNET_TESTING_BarrierList, which is a list
of all barriers
* this test case will wait for.
*
* @return A struct GNUNET_TESTING_BarrierList.
+ * FIXME: do not use ALL CAPS
*/
typedef struct GNUNET_TESTING_BarrierList*
(*GNUNET_TESTING_PLUGIN_GET_WAITING_FOR_BARRIERS) (void);
diff --git a/src/include/gnunet_transport_testing_ng_lib.h
b/src/include/gnunet_transport_testing_ng_lib.h
index 72ec11eaf..b11fe6373 100644
--- a/src/include/gnunet_transport_testing_ng_lib.h
+++ b/src/include/gnunet_transport_testing_ng_lib.h
@@ -27,7 +27,131 @@
#include "gnunet_util_lib.h"
-#include "gnunet_testing_lib.h"
+#include "gnunet_testing_ng_lib.h"
+
+/**
+ * Application handle; FIXME: what exactly is this?
+ */
+struct GNUNET_TRANSPORT_ApplicationHandle;
+
+/**
+ * FIXME: what is this?
+ */
+struct GNUNET_TESTING_StartPeerState;
+
+
+// FIXME: breaks naming conventions
+typedef void *
+(*GNUNET_TESTING_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_PeerIdentity *peer);
+
+
+
+// FIXME: breaks naming conventions! Needed public?
+struct GNUNET_TESTING_StartPeerState
+{
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ /**
+ * The ip of a node.
+ */
+ char *node_ip;
+
+ /**
+ * Receive callback
+ */
+ struct GNUNET_MQ_MessageHandler *handlers;
+
+ /**
+ * GNUnet configuration file used to start a peer.
+ */
+ char *cfgname;
+
+ /**
+ * Peer's configuration
+ */
+ struct GNUNET_CONFIGURATION_Handle *cfg;
+
+ /**
+ * struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
+ */
+ struct GNUNET_TESTING_Peer *peer;
+
+ /**
+ * Peer identity
+ */
+ struct GNUNET_PeerIdentity id;
+
+ /**
+ * Peer's transport service handle
+ */
+ struct GNUNET_TRANSPORT_CoreHandle *th;
+
+ /**
+ * Application handle
+ */
+ struct GNUNET_TRANSPORT_ApplicationHandle *ah;
+
+ /**
+ * Peer's PEERSTORE Handle
+ */
+ struct GNUNET_PEERSTORE_Handle *ph;
+
+ /**
+ * Hello get task
+ */
+ struct GNUNET_SCHEDULER_Task *rh_task;
+
+ /**
+ * Peer's transport get hello handle to retrieve peer's HELLO message
+ */
+ struct GNUNET_PEERSTORE_IterateContext *pic;
+
+ /**
+ * Hello
+ */
+ char *hello;
+
+ /**
+ * Hello size
+ */
+ size_t hello_size;
+
+ /**
+ * The label of the command which was started by calling
GNUNET_TESTING_cmd_system_create.
+ */
+ char *system_label;
+
+ /**
+ * An unique number to identify the peer
+ */
+ unsigned int no;
+
+ /**
+ * A map with struct GNUNET_MQ_Handle values for each peer this peer
+ * is connected to.
+ */
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
+
+ /**
+ * Test setup for this peer.
+ */
+ const struct GNUNET_TESTING_System *tl_system;
+
+ /**
+ * Callback which is called on neighbour connect events.
+ */
+ GNUNET_TESTING_notify_connect_cb notify_connect;
+
+ /**
+ * Flag indicating, if udp broadcast should be switched on.
+ */
+ enum GNUNET_GenericReturnValue broadcast;
+};
+
/**
@@ -52,30 +176,36 @@ GNUNET_TESTING_cmd_start_peer (const char *label,
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_stop_peer (const char *label,
- const char *start_label);
+ const char *start_label);
/**
- * Create command
+ * Retrieve peer identity from the test system with the unique node id.
*
- * @param label name for command
- * @param start_peer_label Label of the cmd to start a peer.
- * @param create_label Label of the cmd which started the test system.
- * @param num Number globally identifying the node.
- * @param topology The topology for the test setup.
- * @param additional_connects Number of additional connects this cmd will wait
for not triggered by this cmd.
- * @return command.
+ * @param num The unique node id.
+ * @param tl_system The test system.
+ * @return The peer identity wrapping the public key.
*/
-struct GNUNET_TESTING_Command
-GNUNET_CORE_cmd_connect_peers (
- const char *label,
- const char *start_peer_label,
- const char *create_label,
- uint32_t num,
- struct GNUNET_TESTING_NetjailTopology *topology,
- unsigned int additional_connects,
- unsigned int wait_for_connect,
- struct GNUNET_MQ_MessageHandler *handlers);
+struct GNUNET_PeerIdentity *
+GNUNET_TESTING_get_peer (unsigned int num,
+ const struct GNUNET_TESTING_System *tl_system);
+
+
+
+
+/**
+ * Call #op on all simple traits.
+ */
+#define GNUNET_TRANSPORT_TESTING_SIMPLE_TRAITS(op) \
+ op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
+ op (peer_id, const struct GNUNET_PeerIdentity) \
+ op (hello_size, const size_t) \
+ op (hello, const char) \
+ op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
+ op (state, const struct GNUNET_TESTING_StartPeerState) \
+ op (broadcast, const enum GNUNET_GenericReturnValue)
+
+GNUNET_TRANSPORT_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
#endif
diff --git a/src/service/core/Makefile.am b/src/service/core/Makefile.am
index 482befae9..99506666b 100644
--- a/src/service/core/Makefile.am
+++ b/src/service/core/Makefile.am
@@ -41,6 +41,7 @@ libgnunet_test_core_plugin_cmd_just_run_la_LIBADD = \
libgnunetcoretesting.la \
$(top_builddir)/src/service/transport/libgnunettransportapplication.la \
$(top_builddir)/src/service/transport/libgnunettransportcore.la \
+ $(top_builddir)/src/service/transport/libgnunettransporttesting2.la \
$(top_builddir)/src/service/testing/libgnunettesting.la \
$(top_builddir)/src/service/peerstore/libgnunetpeerstore.la \
$(top_builddir)/src/service/statistics/libgnunetstatistics.la \
@@ -57,6 +58,7 @@ libgnunetcoretesting_la_LIBADD = \
$(top_builddir)/src/service/testing/libgnunettesting.la \
$(top_builddir)/src/service/arm/libgnunetarm.la \
$(top_builddir)/src/service/transport/libgnunettransportapplication.la \
+ $(top_builddir)/src/service/transport/libgnunettransporttesting2.la \
$(top_builddir)/src/service/transport/libgnunettransportcore.la \
$(top_builddir)/src/lib/util/libgnunetutil.la
libgnunetcoretesting_la_LDFLAGS = \
diff --git a/src/service/core/core_api_cmd_connecting_peers.c
b/src/service/core/core_api_cmd_connecting_peers.c
index 5a80ee415..97cb8c4a6 100644
--- a/src/service/core/core_api_cmd_connecting_peers.c
+++ b/src/service/core/core_api_cmd_connecting_peers.c
@@ -19,14 +19,14 @@
*/
/**
- * @file testing_api_cmd_start_peer.c
+ * @file core_api_cmd_connecting_peers.c
* @brief cmd to start a peer.
* @author t3sserakt
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "gnunet_testing_ng_lib.h"
-#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_core_testing_lib.h"
+#include "gnunet_transport_testing_ng_lib.h"
#include "gnunet_transport_application_service.h"
#include "gnunet_transport_core_service.h"
@@ -209,15 +209,15 @@ connect_peers_traits (void *cls,
struct GNUNET_TESTING_Command
-GNUNET_CORE_cmd_connect_peers (const char *label,
- const char *start_peer_label,
- const char *create_label,
- uint32_t num,
- struct GNUNET_TESTING_NetjailTopology *
- topology,
- unsigned int additional_connects,
- unsigned int wait_for_connect,
- struct GNUNET_MQ_MessageHandler *handlers)
+GNUNET_CORE_cmd_connect_peers (
+ const char *label,
+ const char *start_peer_label,
+ const char *create_label,
+ uint32_t num,
+ struct GNUNET_TESTING_NetjailTopology *topology,
+ unsigned int additional_connects,
+ unsigned int wait_for_connect,
+ struct GNUNET_MQ_MessageHandler *handlers)
{
struct GNUNET_TESTING_ConnectPeersState *cps;
unsigned int node_additional_connects;
@@ -271,3 +271,8 @@ GNUNET_CORE_cmd_connect_peers (const char *label,
&connect_peers_traits,
NULL);
}
+
+
+// FIXME: likely not ideally placed here, move to its own file
+GNUNET_CORE_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
+
diff --git a/src/service/core/test_core_plugin_cmd_just_run.c
b/src/service/core/test_core_plugin_cmd_just_run.c
index edb458577..3c77c370d 100644
--- a/src/service/core/test_core_plugin_cmd_just_run.c
+++ b/src/service/core/test_core_plugin_cmd_just_run.c
@@ -32,6 +32,7 @@
#include "gnunet_testing_barrier.h"
#include "gnunet_core_service.h"
#include "gnunet_transport_testing_ng_lib.h"
+#include "gnunet_core_testing_lib.h"
/**
* Generic logging shortcut
diff --git a/src/service/dht/gnunet-service-dht.c
b/src/service/dht/gnunet-service-dht.c
index 0689af9aa..fcf83b0bc 100644
--- a/src/service/dht/gnunet-service-dht.c
+++ b/src/service/dht/gnunet-service-dht.c
@@ -24,8 +24,8 @@
* @author Christian Grothoff
* @author Nathan Evans
*/
-#include "gnunet_common.h"
#include "platform.h"
+#include "gnunet_common.h"
#include "gnunet_block_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
diff --git a/src/service/dhtu/testing_dhtu_cmd_send.c
b/src/service/dhtu/testing_dhtu_cmd_send.c
index 45d166b14..88449659c 100644
--- a/src/service/dhtu/testing_dhtu_cmd_send.c
+++ b/src/service/dhtu/testing_dhtu_cmd_send.c
@@ -88,11 +88,6 @@ send_run (void *cls,
{
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
GNUNET_TESTING_async_finish (&ss->ac);
}
@@ -112,8 +107,9 @@ GNUNET_TESTING_DHTU_cmd_send (const char *label)
.cleanup = &send_cleanup,
.traits = &send_traits
};
- strncpy (cmd.label, label, GNUNET_TESTING_CMD_MAX_LABEL_LENGTH);
-
+
+ GNUNET_TESTING_set_label (&cmd.label,
+ label);
return cmd;
}
}
diff --git a/src/service/peerstore/peerstore_api.c
b/src/service/peerstore/peerstore_api.c
index cf29925a4..df0e1e226 100644
--- a/src/service/peerstore/peerstore_api.c
+++ b/src/service/peerstore/peerstore_api.c
@@ -23,7 +23,6 @@
* @author Omar Tarabai
* @author Christian Grothoff
*/
-#include "gnunet_common.h"
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_hello_uri_lib.h"
diff --git a/src/service/testing/Makefile.am b/src/service/testing/Makefile.am
index 9ad48c619..3bad23f95 100644
--- a/src/service/testing/Makefile.am
+++ b/src/service/testing/Makefile.am
@@ -30,8 +30,6 @@ gnunet_cmds_helper_LDADD = $(XLIB) \
$(LTLIBINTL) $(Z_LIBS)
libgnunettesting_la_SOURCES = \
- testing_api_cmd_stop_peer.c \
- testing_api_cmd_start_peer.c \
testing_api_cmd_exec_bash_script.c \
testing_api_cmd_barrier.c \
testing_api_cmd_barrier_reached.c \
diff --git a/src/service/testing/gnunet-cmds-helper.c
b/src/service/testing/gnunet-cmds-helper.c
index 4428d4402..d262955cb 100644
--- a/src/service/testing/gnunet-cmds-helper.c
+++ b/src/service/testing/gnunet-cmds-helper.c
@@ -479,8 +479,8 @@ tokenizer_cb (void *cls,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"cross barrier %s\n",
barrier_name);
- TST_interpreter_finish_attached_cmds (is,
- barrier_name);
+ GNUNET_TESTING_finish_barrier_ (is,
+ barrier_name);
return GNUNET_OK;
}
case GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED:
diff --git a/src/service/testing/testing.h b/src/service/testing/testing.h
index fbd7d0d34..43c8ad45a 100644
--- a/src/service/testing/testing.h
+++ b/src/service/testing/testing.h
@@ -263,37 +263,24 @@ GNUNET_TESTING_cmd_batch_set_current_ (const struct
GNUNET_TESTING_Command *cmd,
* the cmd representing the barrier is finished.
*
* @param barrier The barrier in question.
- * @return GNUNET_YES if we can cross the barrier, GNUNET_NO if not.
+ * @return true if we can cross the barrier, false if not.
*/
-unsigned int
-GNUNET_TESTING_barrier_crossable (struct GNUNET_TESTING_Barrier *barrier);
-
-
-/**
- * Send Message to a netjail node that a barrier can be crossed.
- *
- * @param is The interpreter loop.
- * @param barrier_name The name of the barrier to cross.
- * @param global_node_number The global number of the node to inform.
- */
-void
-TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is,
- const char *barrier_name,
- unsigned int global_node_number);
+bool
+GNUNET_TESTING_barrier_crossable_ (struct GNUNET_TESTING_Barrier *barrier);
/**
- * Finish all "barrier reached" comands attached to this barrier.
+ * Finish all "barrier reached" commands attached to this barrier.
*
* @param barrier The barrier in question.
*/
void
-TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
- const char *barrier_name);
+GNUNET_TESTING_finish_barrier_ (struct GNUNET_TESTING_Interpreter *is,
+ const char *barrier_name);
/**
- * Send Message to master loop that cmds being attached to a barrier.
+ * Send message to master loop that cmds being attached to a barrier.
* FIXME: Unused function
*
* @param is The interpreter loop.
@@ -303,11 +290,11 @@ TST_interpreter_finish_attached_cmds (struct
GNUNET_TESTING_Interpreter *is,
* @param write_message Callback to write messages to the master loop.
*/
void
-GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
- char *barrier_name,
- unsigned int global_node_number,
- unsigned int expected_reaches,
- GNUNET_TESTING_cmd_helper_write_cb
write_message);
+GNUNET_TESTING_send_barrier_attach_ (struct GNUNET_TESTING_Interpreter *is,
+ const char *barrier_name,
+ unsigned int global_node_number,
+ unsigned int expected_reaches,
+ GNUNET_TESTING_cmd_helper_write_cb
write_message);
/**
@@ -334,8 +321,8 @@ GNUNET_TESTING_barrier_get_node (struct
GNUNET_TESTING_Barrier *barrier,
* @return The barrier.
*/
struct GNUNET_TESTING_Barrier *
-TST_interpreter_get_barrier (struct GNUNET_TESTING_Interpreter *is,
- const char *barrier_name);
+GNUNET_TESTING_get_barrier_ (struct GNUNET_TESTING_Interpreter *is,
+ const char *barrier_name);
/**
@@ -345,8 +332,8 @@ TST_interpreter_get_barrier (struct
GNUNET_TESTING_Interpreter *is,
* @param barrier The barrier to add.
*/
void
-TST_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
- struct GNUNET_TESTING_Barrier
*barrier);
+GNUNET_TESTING_add_barrier_ (struct GNUNET_TESTING_Interpreter *is,
+ struct GNUNET_TESTING_Barrier *barrier);
#endif
diff --git a/src/service/testing/testing_api_cmd_barrier.c
b/src/service/testing/testing_api_cmd_barrier.c
index c9c43b178..ee074f35b 100644
--- a/src/service/testing/testing_api_cmd_barrier.c
+++ b/src/service/testing/testing_api_cmd_barrier.c
@@ -35,28 +35,31 @@
*/
#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+
struct BarrierState
{
- /*
- * Our barrier.
+ /**
+ * Our barrier, set to NULL once the barrier is active.
*/
struct GNUNET_TESTING_Barrier *barrier;
- /*
- * Our label.
- */
+ /**
+ * Our label.
+ */
const char *label;
};
+
// FIXME Unused function
void
-GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
- char *barrier_name,
- unsigned int global_node_number,
- unsigned int expected_reaches,
- GNUNET_TESTING_cmd_helper_write_cb
- write_message)
+GNUNET_TESTING_send_barrier_attach_ (
+ struct GNUNET_TESTING_Interpreter *is,
+ const char *barrier_name,
+ unsigned int global_node_number,
+ unsigned int expected_reaches,
+ GNUNET_TESTING_cmd_helper_write_cb write_message)
{
+ // FIXME: avoid useless malloc!
struct CommandBarrierAttached *atm = GNUNET_new (struct
CommandBarrierAttached);
size_t msg_length = sizeof(struct CommandBarrierAttached);
@@ -74,8 +77,8 @@ GNUNET_TESTING_send_barrier_attach (struct
GNUNET_TESTING_Interpreter *is,
}
-unsigned int
-GNUNET_TESTING_barrier_crossable (struct GNUNET_TESTING_Barrier *barrier)
+bool
+GNUNET_TESTING_barrier_crossable_ (struct GNUNET_TESTING_Barrier *barrier)
{
unsigned int expected_reaches = barrier->expected_reaches;
unsigned int reached = barrier->reached;
@@ -91,16 +94,10 @@ GNUNET_TESTING_barrier_crossable (struct
GNUNET_TESTING_Barrier *barrier)
number_to_be_reached,
reached);
- if (((0 < percentage_to_be_reached) &&
- (percentage_reached >= percentage_to_be_reached)) ||
- ((0 < number_to_be_reached) && (reached >= number_to_be_reached)))
- {
- return GNUNET_YES;
- }
- else
- {
- return GNUNET_NO;
- }
+ return ( ( (0 < percentage_to_be_reached) &&
+ (percentage_reached >= percentage_to_be_reached) ) ||
+ ( (0 < number_to_be_reached) &&
+ (reached >= number_to_be_reached) ) );
}
@@ -123,7 +120,6 @@ barrier_traits (void *cls,
GNUNET_TESTING_trait_end ()
};
- /* Always return current command. */
return GNUNET_TESTING_get_trait (traits,
ret,
trait,
@@ -142,6 +138,7 @@ barrier_cleanup (void *cls)
{
struct BarrierState *brs = cls;
+ GNUNET_free (brs->barrier);
GNUNET_free (brs);
}
@@ -158,7 +155,9 @@ barrier_run (void *cls,
{
struct BarrierState *brs = cls;
- TST_interpreter_add_barrier (is, brs->barrier);
+ GNUNET_TESTING_add_barrier_ (is,
+ brs->barrier);
+ brs->barrier = NULL;
}
@@ -169,11 +168,14 @@ GNUNET_TESTING_barrier_get_node (struct
GNUNET_TESTING_Barrier *barrier,
struct GNUNET_HashCode hc;
struct GNUNET_ShortHashCode key;
- GNUNET_CRYPTO_hash (&(node_number), sizeof(node_number), &hc);
+ GNUNET_CRYPTO_hash (&node_number,
+ sizeof(node_number),
+ &hc);
memcpy (&key,
&hc,
sizeof (key));
- return GNUNET_CONTAINER_multishortmap_get (barrier->nodes, &key);
+ return GNUNET_CONTAINER_multishortmap_get (barrier->nodes,
+ &key);
}
@@ -191,8 +193,10 @@ GNUNET_TESTING_cmd_barrier_create (const char *label,
barrier->name = label;
barrier->percentage_to_be_reached = percentage_to_be_reached;
barrier->number_to_be_reached = number_to_be_reached;
- GNUNET_assert ((0 < percentage_to_be_reached && 0 == number_to_be_reached) ||
- (0 == percentage_to_be_reached && 0 < number_to_be_reached));
+ GNUNET_assert ((0 < percentage_to_be_reached &&
+ 0 == number_to_be_reached) ||
+ (0 == percentage_to_be_reached &&
+ 0 < number_to_be_reached));
bs->barrier = barrier;
return GNUNET_TESTING_command_new (bs, label,
&barrier_run,
diff --git a/src/service/testing/testing_api_cmd_barrier_reached.c
b/src/service/testing/testing_api_cmd_barrier_reached.c
index 161240d4d..54a36b91c 100644
--- a/src/service/testing/testing_api_cmd_barrier_reached.c
+++ b/src/service/testing/testing_api_cmd_barrier_reached.c
@@ -99,22 +99,22 @@ barrier_reached_run (void *cls,
struct GNUNET_TESTING_CommandBarrierReached *msg;
size_t name_len;
- barrier = TST_interpreter_get_barrier (is, brs->barrier_name);
+ barrier = GNUNET_TESTING_get_barrier_ (is,
+ brs->barrier_name);
if (NULL == barrier)
{
barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
barrier->name = brs->barrier_name;
- TST_interpreter_add_barrier (is, barrier);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "barrier %s added locally\n",
- brs->barrier_name);
+ GNUNET_TESTING_add_barrier_ (is,
+ barrier);
}
barrier->reached++;
- if (GNUNET_TESTING_barrier_crossable (barrier))
+ if (GNUNET_TESTING_barrier_crossable_ (barrier))
{
GNUNET_assert (NULL != cmd);
cmd->asynchronous_finish = GNUNET_YES;
- TST_interpreter_finish_attached_cmds (is, barrier->name);
+ GNUNET_TESTING_finish_barrier_ (is,
+ barrier->name);
}
else if (GNUNET_NO == brs->asynchronous_finish)
{
diff --git a/src/service/testing/testing_api_cmd_batch.c
b/src/service/testing/testing_api_cmd_batch.c
index 7dc990855..2f1faf288 100644
--- a/src/service/testing/testing_api_cmd_batch.c
+++ b/src/service/testing/testing_api_cmd_batch.c
@@ -41,7 +41,7 @@ struct BatchState
/**
* Our label.
*/
- const char *label;
+ struct GNUNET_TESTING_CommandLabel label;
/**
* Internal command pointer.
@@ -65,14 +65,14 @@ batch_run (void *cls,
if (NULL != bs->batch[bs->batch_ip].run)
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Running batched command: %s\n",
- bs->batch[bs->batch_ip].label);
+ bs->batch[bs->batch_ip].label.value);
/* hit end command, leap to next top-level command. */
if (NULL == bs->batch[bs->batch_ip].run)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Exiting from batch: %s\n",
- bs->label);
+ bs->label.value);
return;
}
bs->batch[bs->batch_ip].start_time
@@ -159,7 +159,8 @@ GNUNET_TESTING_cmd_batch (const char *label,
unsigned int i;
bs = GNUNET_new (struct BatchState);
- bs->label = label;
+ GNUNET_TESTING_set_label (&bs->label,
+ label);
/* Get number of commands. */
for (i = 0; NULL != batch[i].run; i++)
/* noop */
@@ -170,7 +171,8 @@ GNUNET_TESTING_cmd_batch (const char *label,
memcpy (bs->batch,
batch,
sizeof (struct GNUNET_TESTING_Command) * i);
- return GNUNET_TESTING_command_new (bs, label,
+ return GNUNET_TESTING_command_new (bs,
+ label,
&batch_run,
&batch_cleanup,
&batch_traits, NULL);
@@ -216,8 +218,6 @@ GNUNET_TESTING_cmd_batch_set_current_ (const struct
GNUNET_TESTING_Command *cmd,
/* sanity checks */
GNUNET_assert (GNUNET_TESTING_cmd_is_batch_ (cmd));
- for (unsigned int i = 0; i < new_ip; i++)
- GNUNET_assert (NULL != bs->batch[i].label);
/* actual logic */
bs->batch_ip = new_ip;
}
diff --git a/src/service/testing/testing_api_cmd_netjail_start_cmds_helper.c
b/src/service/testing/testing_api_cmd_netjail_start_cmds_helper.c
index df6a81cb4..792d7a8cf 100644
--- a/src/service/testing/testing_api_cmd_netjail_start_cmds_helper.c
+++ b/src/service/testing/testing_api_cmd_netjail_start_cmds_helper.c
@@ -353,9 +353,11 @@ barrier_attached (struct NetJailState *ns, const struct
am = (struct CommandBarrierAttached *) message;
barrier_name = (const char *) &am[1];
- barrier = TST_interpreter_get_barrier (ns->is, barrier_name);
+ barrier = GNUNET_TESTING_get_barrier_ (ns->is,
+ barrier_name);
GNUNET_assert (NULL != barrier);
- node = GNUNET_TESTING_barrier_get_node (barrier, am->node_number);
+ node = GNUNET_TESTING_barrier_get_node (barrier,
+ am->node_number);
if (NULL == node)
{
node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
@@ -374,18 +376,17 @@ barrier_attached (struct NetJailState *ns, const struct
void
-barrier_reached (struct NetJailState *ns, const struct
- GNUNET_MessageHeader *message)
+barrier_reached (struct NetJailState *ns,
+ const struct GNUNET_MessageHeader *message)
{
struct GNUNET_TESTING_Barrier *barrier;
const char *barrier_name;
- struct GNUNET_TESTING_CommandBarrierReached *rm = (struct
-
GNUNET_TESTING_CommandBarrierReached
- *) message;
+ const struct GNUNET_TESTING_CommandBarrierReached *rm;
+ rm = (const struct GNUNET_TESTING_CommandBarrierReached *) message;
barrier_name = (const char *) &rm[1];
-
- barrier = TST_interpreter_get_barrier (ns->is, barrier_name);
+ barrier = GNUNET_TESTING_get_barrier_ (ns->is,
+ barrier_name);
GNUNET_assert (NULL != barrier);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"barrier %s reached %p %u\n",
@@ -397,12 +398,13 @@ barrier_reached (struct NetJailState *ns, const struct
"%u %p\n",
barrier->reached,
barrier);
- if (GNUNET_TESTING_barrier_crossable (barrier))
+ if (GNUNET_TESTING_barrier_crossable_ (barrier))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"%s can be crossed\n",
barrier_name);
- TST_interpreter_finish_attached_cmds (ns->is, barrier->name);
+ GNUNET_TESTING_finish_barrier_ (ns->is,
+ barrier->name);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"barrier %s reached finished\n",
@@ -616,10 +618,15 @@ start_helper (struct NetJailState *ns,
pid,
script_num);
// GNUNET_asprintf (&topology_data, "'%s'", ns->topology_data);
- GNUNET_asprintf (&read_file, "%u", *(ns->read_file));
+ GNUNET_asprintf (&read_file,
+ "%u",
+ *(ns->read_file));
data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
- GNUNET_asprintf (&script_name, "%s%s", data_dir, NETJAIL_EXEC_SCRIPT);
+ GNUNET_asprintf (&script_name,
+ "%s%s",
+ data_dir,
+ NETJAIL_EXEC_SCRIPT);
unsigned int helper_check = GNUNET_OS_check_helper_binary (
script_name,
GNUNET_YES,
@@ -634,6 +641,7 @@ start_helper (struct NetJailState *ns,
"No SUID for %s!\n",
script_name);
GNUNET_TESTING_interpreter_fail (ns->is);
+ // FIXME: why continue here, instead of returning?
}
else if (GNUNET_NO == helper_check)
{
@@ -672,17 +680,21 @@ start_helper (struct NetJailState *ns,
&helper_mst,
&exp_cb,
ns);
- GNUNET_array_append (ns->helper, ns->n_helper, helper);
+ GNUNET_array_append (ns->helper,
+ ns->n_helper,
+ helper);
}
- GNUNET_TESTING_add_netjail_helper (ns->is,
- helper);
+ GNUNET_TESTING_add_netjail_helper_ (ns->is,
+ helper);
plugin_name = topology->plugin;
hkey = GNUNET_new (struct GNUNET_ShortHashCode);
node = NULL;
if (0 == n)
{
- GNUNET_CRYPTO_hash (&m, sizeof(m), &hc);
+ GNUNET_CRYPTO_hash (&m,
+ sizeof(m),
+ &hc);
memcpy (hkey,
&hc,
sizeof (*hkey));
@@ -732,44 +744,37 @@ start_helper (struct NetJailState *ns,
for (pos = barriers->head; NULL != pos; pos = pos->next)
{
- barrier = TST_interpreter_get_barrier (ns->is, pos->barrier_name);
+ barrier = GNUNET_TESTING_get_barrier_ (ns->is,
+ pos->barrier_name);
if (NULL == barrier)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "barrier %s added\n",
- pos->barrier_name);
barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
barrier->name = pos->barrier_name;
barrier->shadow = GNUNET_YES;
- TST_interpreter_add_barrier (ns->is, barrier);
-
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "%u %p\n",
- barrier->reached,
- barrier);
-
- barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
+ GNUNET_TESTING_add_barrier_ (ns->is,
+ barrier);
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "barrier %p %s node %u added \n",
- barrier,
- pos->barrier_name,
- node->node_number);
barrier_node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
barrier_node->node_number = node->node_number;
barrier_node->expected_reaches = pos->expected_reaches;
barrier->expected_reaches = barrier->expected_reaches
+ pos->expected_reaches;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "number_to_be_reached %u\n",
- barrier->number_to_be_reached);
if (GNUNET_YES == barrier->shadow)
barrier->number_to_be_reached++;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "number_to_be_reached %u\n",
+ "Adding barrier %p %s node %u with reach target %u\n",
+ barrier,
+ pos->barrier_name,
+ node->node_number,
barrier->number_to_be_reached);
- GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
+ GNUNET_CRYPTO_hash (&node->node_number,
+ sizeof(node->node_number),
+ &hc);
memcpy (&key, &hc, sizeof (key));
+ if (NULL == barrier->nodes)
+ barrier->nodes
+ = GNUNET_CONTAINER_multishortmap_create (16,
+ GNUNET_NO);
GNUNET_CONTAINER_multishortmap_put (barrier->nodes,
&key,
barrier_node,
@@ -777,9 +782,7 @@ start_helper (struct NetJailState *ns,
}
tbc->plugin = plugin;
-
msg = create_helper_init_msg_ (plugin_name);
-
tbc->shandle = GNUNET_HELPER_send (
helper,
&msg->header,
diff --git a/src/service/testing/testing_api_loop.c
b/src/service/testing/testing_api_loop.c
index 559a61c38..beb9b9060 100644
--- a/src/service/testing/testing_api_loop.c
+++ b/src/service/testing/testing_api_loop.c
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet
- Copyright (C) 2021 GNUnet e.V.
+ Copyright (C) 2021-2023 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
@@ -49,12 +49,6 @@ struct GNUNET_TESTING_Interpreter
*/
struct GNUNET_HELPER_SendHandle *send_handle;
- /**
- * Size of the array helper.
- *
- */
- unsigned int n_helper;
-
/**
* Function to call with the test result.
*/
@@ -75,11 +69,6 @@ struct GNUNET_TESTING_Interpreter
*/
struct GNUNET_CONTAINER_MultiShortmap *barriers;
- /**
- * Number of GNUNET_TESTING_Command in commands.
- */
- unsigned int cmds_n;
-
/**
* Interpreter task (if one is scheduled).
*/
@@ -95,6 +84,16 @@ struct GNUNET_TESTING_Interpreter
*/
struct GNUNET_SCHEDULER_Task *timeout_task;
+ /**
+ * Number of GNUNET_TESTING_Command in @e commands.
+ */
+ unsigned int cmds_n;
+
+ /**
+ * Size of the array @e helper.
+ */
+ unsigned int n_helper;
+
/**
* Instruction pointer. Tells #interpreter_run() which instruction to run
* next. Need (signed) int because it gets -1 when rewinding the
@@ -110,31 +109,26 @@ struct GNUNET_TESTING_Interpreter
/**
* Is the interpreter finishing?
*/
- unsigned int finishing;
-
-};
-
-struct FreeBarrierNodeCbCls
-{
- /**
- * The interpreter.
- */
- struct GNUNET_TESTING_Interpreter *is;
+ bool finishing;
- /**
- * The barrier from which the nodes are freed..
- */
- struct GNUNET_TESTING_Barrier *barrier;
};
+/**
+ * Lookup command by label.
+ *
+ * @param is interpreter to lookup command in
+ * @param label label of the command to lookup.
+ * @param future true to look into the future, false to look into the past
+ * @return the command, if it is found, or NULL.
+ */
static const struct GNUNET_TESTING_Command *
get_command (struct GNUNET_TESTING_Interpreter *is,
const char *label,
- unsigned int future)
+ bool future)
{
- int start_i = GNUNET_NO == future ? is->ip : is->cmds_n - 1;
- int end_i = GNUNET_NO == future ? 0 : is->ip + 1;
+ int start_i = future ? is->cmds_n - 1 : is->ip;
+ int end_i = future ? is->ip + 1 : 0;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"start_i: %u end_i: %u\n",
@@ -146,7 +140,6 @@ get_command (struct GNUNET_TESTING_Interpreter *is,
"Attempt to lookup command for empty label\n");
return NULL;
}
-
for (int i = start_i; i >= end_i; i--)
{
const struct GNUNET_TESTING_Command *cmd = &is->commands[i];
@@ -154,10 +147,10 @@ get_command (struct GNUNET_TESTING_Interpreter *is,
if (NULL != cmd->run)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"label to compare %s\n",
- cmd->label);
+ cmd->label.value);
/* Give precedence to top-level commands. */
if ( (NULL != cmd->run) &&
- (0 == strcmp (cmd->label,
+ (0 == strcmp (cmd->label.value,
label)) )
return cmd;
@@ -181,7 +174,7 @@ get_command (struct GNUNET_TESTING_Interpreter *is,
if (current == icmd)
break; /* do not go past current command */
if ( (NULL != icmd->run) &&
- (0 == strcmp (icmd->label,
+ (0 == strcmp (icmd->label.value,
label)) )
match = icmd;
}
@@ -196,37 +189,25 @@ get_command (struct GNUNET_TESTING_Interpreter *is,
}
-/**
- * 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);
+ return get_command (is,
+ label,
+ true);
}
-/**
- * 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);
+ return get_command (is,
+ label,
+ false);
}
@@ -237,14 +218,93 @@ GNUNET_TESTING_interpreter_lookup_command_all (
{
const struct GNUNET_TESTING_Command *cmd;
- cmd = get_command (is, label, GNUNET_NO);
+ cmd = get_command (is,
+ label,
+ false);
if (NULL == cmd)
- cmd = get_command (is, label, GNUNET_YES);
+ cmd = get_command (is,
+ label,
+ true);
return cmd;
}
-int
+/**
+ * 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()
+ */
+static void
+clear_msg (void *cls,
+ enum GNUNET_GenericReturnValue result)
+{
+ GNUNET_assert (GNUNET_YES == result);
+}
+
+
+/**
+ * Send message to a netjail node that a barrier can be crossed.
+ *
+ * @param is The interpreter loop.
+ * @param barrier_name The name of the barrier to cross.
+ * @param global_node_number The global number of the node to inform.
+ */
+static void
+send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is,
+ const char *barrier_name,
+ unsigned int global_node_number)
+{
+ struct CommandBarrierCrossable *adm;
+ size_t msg_length;
+ size_t name_len;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "send barrier crossable for barrier `%s'\n",
+ barrier_name);
+ name_len = strlen (barrier_name);
+ msg_length = sizeof(struct CommandBarrierCrossable) + name_len + 1;
+ adm = GNUNET_malloc (msg_length);
+ adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE);
+ adm->header.size = htons ((uint16_t) msg_length);
+ memcpy (&adm[1], barrier_name, name_len);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "send message of type %u to locals\n",
+ ntohs (adm->header.type));
+ /**
+ FIXME: This should probably be put into a linked list
+ inside is and cleaned up at some point.
+ */
+ is->send_handle = GNUNET_HELPER_send (
+ (struct GNUNET_HELPER_Handle *) is->helper[global_node_number - 1],
+ &adm->header,
+ GNUNET_NO,
+ &clear_msg,
+ NULL);
+ GNUNET_free (adm);
+}
+
+
+/**
+ * Closure for #free_barrier_node_cb().
+ */
+struct FreeBarrierNodeCbCls
+{
+ /**
+ * The interpreter.
+ */
+ struct GNUNET_TESTING_Interpreter *is;
+
+ /**
+ * The barrier from which the nodes are freed..
+ */
+ struct GNUNET_TESTING_Barrier *barrier;
+};
+
+
+static enum GNUNET_GenericReturnValue
free_barrier_node_cb (void *cls,
const struct GNUNET_ShortHashCode *key,
void *value)
@@ -256,21 +316,41 @@ free_barrier_node_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"free_barrier_node_cb\n");
- if (GNUNET_NO == is->finishing)
+ if (! is->finishing)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "TST_interpreter_send_barrier_crossable\n");
- TST_interpreter_send_barrier_crossable (is,
- barrier->name,
- node->node_number);
+ send_barrier_crossable (is,
+ barrier->name,
+ node->node_number);
}
- GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multishortmap_remove (
- barrier->nodes, key, node));
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multishortmap_remove (
+ barrier->nodes,
+ key,
+ node));
return GNUNET_YES;
}
-static int
+static void
+free_barrier_nodes (struct GNUNET_TESTING_Interpreter *is,
+ struct GNUNET_TESTING_Barrier *barrier)
+{
+ struct FreeBarrierNodeCbCls free_barrier_node_cb_cls = {
+ .barrier = barrier,
+ .is = is
+ };
+
+ if (NULL == barrier->nodes)
+ return;
+ GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes,
+ free_barrier_node_cb,
+ &free_barrier_node_cb_cls);
+ GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes);
+ barrier->nodes = NULL;
+}
+
+
+static enum GNUNET_GenericReturnValue
free_barriers_cb (void *cls,
const struct GNUNET_ShortHashCode *key,
void *value)
@@ -278,20 +358,9 @@ free_barriers_cb (void *cls,
struct GNUNET_TESTING_Interpreter *is = cls;
struct GNUNET_TESTING_Barrier *barrier = value;
struct CommandListEntry *pos;
- struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls;
-
- if (NULL != barrier->nodes)
- {
- free_barrier_node_cb_cls = GNUNET_new (struct FreeBarrierNodeCbCls);
- free_barrier_node_cb_cls->barrier = barrier;
- free_barrier_node_cb_cls->is = is;
- GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes,
- free_barrier_node_cb,
- free_barrier_node_cb_cls);
- GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes);
- barrier->nodes = NULL;
- }
+ free_barrier_nodes (is,
+ barrier);
while (NULL != (pos = barrier->cmds_head))
{
GNUNET_CONTAINER_DLL_remove (barrier->cmds_head,
@@ -304,21 +373,6 @@ free_barriers_cb (void *cls,
}
-/**
- * Deleting all barriers create in the context of this interpreter.
- *
- * @param is The interpreter.
- */
-static void
-interpreter_delete_barriers (struct GNUNET_TESTING_Interpreter *is)
-{
- GNUNET_CONTAINER_multishortmap_iterate (is->barriers,
- free_barriers_cb,
- is);
- GNUNET_CONTAINER_multishortmap_destroy (is->barriers);
-}
-
-
/**
* Finish the test run, return the final result.
*
@@ -331,9 +385,9 @@ finish_test (void *cls)
struct GNUNET_TESTING_Command *cmd;
const char *label;
- is->finishing = GNUNET_YES;
+ is->finishing = true;
is->final_task = NULL;
- label = is->commands[is->ip].label;
+ label = is->commands[is->ip].label.value;
if (NULL == is->commands[is->ip].run)
label = "END";
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -346,11 +400,11 @@ finish_test (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cleaning up cmd %s\n",
- cmd->label);
+ cmd->label.value);
cmd->cleanup (cmd->cls);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Cleaned up cmd %s\n",
- cmd->label);
+ cmd->label.value);
}
if (NULL != is->task)
{
@@ -370,7 +424,10 @@ finish_test (void *cls)
GNUNET_free (is->commands);
is->rc (is->rc_cls,
is->result);
- interpreter_delete_barriers (is);
+ GNUNET_CONTAINER_multishortmap_iterate (is->barriers,
+ free_barriers_cb,
+ is);
+ GNUNET_CONTAINER_multishortmap_destroy (is->barriers);
GNUNET_free (is->helper);
GNUNET_free (is);
}
@@ -432,13 +489,13 @@ GNUNET_TESTING_interpreter_fail (struct
GNUNET_TESTING_Interpreter *is)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed at command `%s'\n",
- cmd->label);
+ cmd->label.value);
while (GNUNET_TESTING_cmd_is_batch_ (cmd))
{
cmd = GNUNET_TESTING_cmd_batch_get_current_ (cmd);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Failed in batch at command `%s'\n",
- cmd->label);
+ cmd->label.value);
}
}
else
@@ -453,6 +510,33 @@ GNUNET_TESTING_interpreter_fail (struct
GNUNET_TESTING_Interpreter *is)
}
+void
+GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac)
+{
+ GNUNET_assert (GNUNET_NO == ac->finished);
+ ac->finished = GNUNET_SYSERR;
+ GNUNET_TESTING_interpreter_fail (ac->is);
+ if (NULL != ac->cont)
+ {
+ ac->cont (ac->cont_cls);
+ ac->cont = NULL;
+ }
+}
+
+
+void
+GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac)
+{
+ GNUNET_assert (GNUNET_NO == ac->finished);
+ ac->finished = GNUNET_OK;
+ if (NULL != ac->cont)
+ {
+ ac->cont (ac->cont_cls);
+ ac->cont = NULL;
+ }
+}
+
+
/**
* Returns the actual running command.
*
@@ -468,16 +552,6 @@ GNUNET_TESTING_interpreter_get_current_command (
}
-const char *
-GNUNET_TESTING_interpreter_get_current_label (
- struct GNUNET_TESTING_Interpreter *is)
-{
- struct GNUNET_TESTING_Command *cmd = &is->commands[is->ip];
-
- return cmd->label;
-}
-
-
/**
* Run the main interpreter loop.
*
@@ -500,7 +574,7 @@ interpreter_run (void *cls)
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Running command `%s'\n",
- cmd->label);
+ cmd->label.value);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"start time of %p expected 0 is `%" PRIu64 "'\n",
cmd,
@@ -508,17 +582,13 @@ interpreter_run (void *cls)
cmd->start_time
= cmd->last_req_time
= GNUNET_TIME_absolute_get ();
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "start time of %p expected something is `%" PRIu64 "'\n",
- cmd,
- cmd->start_time.abs_value_us);
cmd->num_tries = 1;
if (NULL != cmd->ac)
{
cmd->ac->is = is;
cmd->ac->cont = &interpreter_next;
cmd->ac->cont_cls = is;
- cmd->ac->finished = GNUNET_NO;
+ cmd->ac->finished = false;
}
cmd->run (cmd->cls,
is);
@@ -553,25 +623,6 @@ do_timeout (void *cls)
}
-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;
-}
-
-
-enum GNUNET_GenericReturnValue
-GNUNET_TESTING_finished (const 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;
-}
-
-
struct GNUNET_TESTING_Interpreter *
GNUNET_TESTING_run (const struct GNUNET_TESTING_Command *commands,
struct GNUNET_TIME_Relative timeout,
@@ -629,17 +680,28 @@ GNUNET_TESTING_command_new (void *cls,
GNUNET_assert (NULL != run);
if (NULL != label)
- {
- GNUNET_assert (strlen (label) <=
- GNUNET_TESTING_CMD_MAX_LABEL_LENGTH);
- strncpy (cmd.label,
- label,
- GNUNET_TESTING_CMD_MAX_LABEL_LENGTH);
- }
+ GNUNET_TESTING_set_label (&cmd.label,
+ label);
return cmd;
}
+void
+GNUNET_TESTING_set_label (struct GNUNET_TESTING_CommandLabel *label,
+ const char *value)
+{
+ size_t len;
+
+ len = strlen (value);
+ GNUNET_assert (len <=
+ GNUNET_TESTING_CMD_MAX_LABEL_LENGTH);
+ memcpy (label->value,
+ value,
+ len + 1);
+}
+
+
+
struct GNUNET_TESTING_Command
GNUNET_TESTING_cmd_end (void)
{
@@ -712,118 +774,101 @@ loop_run (void *cls)
}
-/**
- * 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()
- */
-static void
-clear_msg (void *cls, int result)
+int
+GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands,
+ struct GNUNET_TIME_Relative timeout)
{
- GNUNET_assert (GNUNET_YES == result);
-}
-
+ struct MainParams mp = {
+ .commands = commands,
+ .timeout = timeout,
+ .rv = EXIT_SUCCESS
+ };
-/**
- * Adding a helper handle to the interpreter.
- *
- * @param is The interpreter.
- * @param helper The helper handle.
- */
-void
-GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is,
- const struct GNUNET_HELPER_Handle *helper)
-{
- GNUNET_array_append (is->helper, is->n_helper, helper);
+ GNUNET_SCHEDULER_run (&loop_run,
+ &mp);
+ return mp.rv;
}
void
-TST_interpreter_send_barrier_crossable (struct GNUNET_TESTING_Interpreter *is,
- const char *barrier_name,
- unsigned int global_node_number)
+GNUNET_TESTING_add_netjail_helper_ (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_HELPER_Handle *helper)
{
- struct CommandBarrierCrossable *adm;
- size_t msg_length;
- size_t name_len;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "send barrier name %s barrier_name\n",
- barrier_name);
- name_len = strlen (barrier_name);
- msg_length = sizeof(struct CommandBarrierCrossable) + name_len + 1;
- adm = GNUNET_malloc (msg_length);
- adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_CROSSABLE);
- adm->header.size = htons ((uint16_t) msg_length);
- memcpy (&adm[1], barrier_name, name_len);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "send message of type %u to locals\n",
- ntohs (adm->header.type));
- /**
- FIXME: This should probably be put into a linked list
- inside is and cleaned up at some point.
- */
- is->send_handle = GNUNET_HELPER_send (
- (struct GNUNET_HELPER_Handle *) is->helper[global_node_number - 1],
- &adm->header,
- GNUNET_NO,
- &clear_msg,
- NULL);
- GNUNET_free (adm);
+ GNUNET_array_append (is->helper,
+ is->n_helper,
+ helper);
}
-/**
- * Getting a barrier from the interpreter.
- *
- * @param is The interpreter.
- * @param barrier_name The name of the barrier.
- * @return The barrier.
- */
struct GNUNET_TESTING_Barrier *
-TST_interpreter_get_barrier (struct GNUNET_TESTING_Interpreter *is,
+GNUNET_TESTING_get_barrier_ (struct GNUNET_TESTING_Interpreter *is,
const char *barrier_name)
{
struct GNUNET_HashCode hc;
struct GNUNET_ShortHashCode create_key;
- struct GNUNET_TESTING_Barrier *barrier;
- GNUNET_CRYPTO_hash (barrier_name, strlen (barrier_name), &hc);
+ GNUNET_CRYPTO_hash (barrier_name,
+ strlen (barrier_name),
+ &hc);
memcpy (&create_key,
&hc,
sizeof (create_key));
- barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key);
- return barrier;
+ return GNUNET_CONTAINER_multishortmap_get (is->barriers,
+ &create_key);
}
/**
- * Finish all "barrier reached" comands attached to this barrier.
+ * Add a barrier to the interpreter.
*
- * @param barrier The barrier in question.
+ * @param is The interpreter.
+ * @param barrier The barrier to add.
*/
void
-TST_interpreter_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
- const char *barrier_name)
+GNUNET_TESTING_add_barrier_ (struct GNUNET_TESTING_Interpreter *is,
+ struct GNUNET_TESTING_Barrier *barrier)
+{
+ struct GNUNET_HashCode hc;
+ struct GNUNET_ShortHashCode create_key;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding barrier %s locally\n",
+ barrier->name);
+ GNUNET_CRYPTO_hash (barrier->name,
+ strlen (barrier->name),
+ &hc);
+ memcpy (&create_key,
+ &hc,
+ sizeof (create_key));
+ GNUNET_CONTAINER_multishortmap_put (is->barriers,
+ &create_key,
+ barrier,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
+}
+
+
+void
+GNUNET_TESTING_finish_barrier_ (struct GNUNET_TESTING_Interpreter *is,
+ const char *barrier_name)
{
struct CommandListEntry *pos;
- struct GNUNET_TESTING_Barrier *barrier = TST_interpreter_get_barrier (is,
-
barrier_name);
+ struct GNUNET_TESTING_Barrier *barrier;
- while (NULL != barrier && NULL != (pos = barrier->cmds_head))
+ barrier = GNUNET_TESTING_get_barrier_ (is,
+ barrier_name);
+ if (NULL == barrier)
+ return;
+ while (NULL != (pos = barrier->cmds_head))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"command label %s\n",
- pos->command->label);
- if (GNUNET_NO == pos->command->ac->finished &&
- GNUNET_NO == pos->command->asynchronous_finish)
+ pos->command->label.value);
+ if ( (GNUNET_NO == pos->command->ac->finished) &&
+ (GNUNET_NO == pos->command->asynchronous_finish) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"command label %s finish\n",
- pos->command->label);
+ pos->command->label.value);
GNUNET_TESTING_async_finish (pos->command->ac);
}
else if (GNUNET_NO == pos->command->ac->finished)
@@ -835,95 +880,13 @@ TST_interpreter_finish_attached_cmds (struct
GNUNET_TESTING_Interpreter *is,
pos);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"command entry label %s removed\n",
- pos->command->label);
+ pos->command->label.value);
GNUNET_free (pos);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"command entry freed\n");
}
- if (NULL != barrier->nodes)
- {
- struct FreeBarrierNodeCbCls free_barrier_node_cb_cls = {
- .barrier = barrier,
- .is = is
- };
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "freeing nodes\n");
- GNUNET_CONTAINER_multishortmap_iterate (barrier->nodes,
- &free_barrier_node_cb,
- &free_barrier_node_cb_cls);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "nodes freed\n");
- GNUNET_CONTAINER_multishortmap_destroy (barrier->nodes);
- barrier->nodes = NULL;
- }
-}
-
-
-/**
- * Add a barrier to the loop.
- *
- * @param is The interpreter.
- * @param barrier The barrier to add.
- */
-void
-TST_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
- struct GNUNET_TESTING_Barrier *barrier)
-{
- struct GNUNET_HashCode hc;
- struct GNUNET_ShortHashCode create_key;
-
- GNUNET_CRYPTO_hash (barrier->name, strlen (barrier->name), &hc);
- memcpy (&create_key,
- &hc,
- sizeof (create_key));
- GNUNET_CONTAINER_multishortmap_put (is->barriers,
- &create_key,
- barrier,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
-}
-
-
-int
-GNUNET_TESTING_main (struct GNUNET_TESTING_Command *commands,
- struct GNUNET_TIME_Relative timeout)
-{
- struct MainParams mp = {
- .commands = commands,
- .timeout = timeout,
- .rv = EXIT_SUCCESS
- };
-
- GNUNET_SCHEDULER_run (&loop_run,
- &mp);
- return mp.rv;
-}
-
-
-void
-GNUNET_TESTING_async_fail (struct GNUNET_TESTING_AsyncContext *ac)
-{
- GNUNET_assert (GNUNET_NO == ac->finished);
- ac->finished = GNUNET_SYSERR;
- GNUNET_TESTING_interpreter_fail (ac->is);
- if (NULL != ac->cont)
- {
- ac->cont (ac->cont_cls);
- ac->cont = NULL;
- }
-}
-
-
-void
-GNUNET_TESTING_async_finish (struct GNUNET_TESTING_AsyncContext *ac)
-{
- GNUNET_assert (GNUNET_NO == ac->finished);
- ac->finished = GNUNET_OK;
- if (NULL != ac->cont)
- {
- ac->cont (ac->cont_cls);
- ac->cont = NULL;
- }
+ free_barrier_nodes (is,
+ barrier);
}
diff --git a/src/service/testing/testing_api_traits.c
b/src/service/testing/testing_api_traits.c
index ee3edbed0..ddd04ac30 100644
--- a/src/service/testing/testing_api_traits.c
+++ b/src/service/testing/testing_api_traits.c
@@ -32,10 +32,16 @@
#include "gnunet_testing_netjail_lib.h"
+/* FIXME: move these into respective sub-libs? */
+
GNUNET_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
GNUNET_TESTING_INDEXED_TRAITS (GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT)
+GNUNET_TESTING_LOOP_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
+
+GNUNET_TESTING_LOOP_INDEXED_TRAITS (GNUNET_TESTING_MAKE_IMPL_INDEXED_TRAIT)
+
GNUNET_TESTING_SIMPLE_NETJAIL_TRAITS (GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
/**
diff --git a/src/service/testing/testing_cmds.h
b/src/service/testing/testing_cmds.h
index 9c261aab5..f4549477e 100644
--- a/src/service/testing/testing_cmds.h
+++ b/src/service/testing/testing_cmds.h
@@ -136,8 +136,8 @@ GNUNET_TESTING_interpreter_get_current_command (
* @param helper The helper handle.
*/
void
-GNUNET_TESTING_add_netjail_helper (struct GNUNET_TESTING_Interpreter *is,
- const struct GNUNET_HELPER_Handle *helper);
+GNUNET_TESTING_add_netjail_helper_ (struct GNUNET_TESTING_Interpreter *is,
+ const struct GNUNET_HELPER_Handle *helper);
#endif
/* end of testing_cmds.h */
diff --git a/src/service/transport/Makefile.am
b/src/service/transport/Makefile.am
index e5a3fe9bd..fd1ce535c 100644
--- a/src/service/transport/Makefile.am
+++ b/src/service/transport/Makefile.am
@@ -30,6 +30,8 @@ lib_LTLIBRARIES = \
libgnunettransporttesting2_la_SOURCES = \
transport_api_traits.c \
+ testing_api_cmd_stop_peer.c \
+ testing_api_cmd_start_peer.c \
transport_api_cmd_connecting_peers.c \
transport_api_cmd_backchannel_check.c \
transport_api_cmd_start_peer.c \
diff --git a/src/service/transport/test_transport_plugin_cmd_nat_upnp.c
b/src/service/transport/test_transport_plugin_cmd_nat_upnp.c
index 9d7c5d856..4163ab68b 100644
--- a/src/service/transport/test_transport_plugin_cmd_nat_upnp.c
+++ b/src/service/transport/test_transport_plugin_cmd_nat_upnp.c
@@ -148,8 +148,8 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
cmd = GNUNET_TESTING_interpreter_lookup_command (is,
"connect-peers");
- GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
- &cps);
+ GNUNET_TESTING_get_trait_connect_peer_state (cmd,
+ &cps);
void *ret = NULL;
cps->notify_connect (is,
diff --git a/src/service/transport/test_transport_plugin_cmd_simple_send.c
b/src/service/transport/test_transport_plugin_cmd_simple_send.c
index c6d75cce4..9f34d4bcc 100644
--- a/src/service/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/service/transport/test_transport_plugin_cmd_simple_send.c
@@ -151,8 +151,8 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
cmd = GNUNET_TESTING_interpreter_lookup_command (is,
"connect-peers");
- GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
- &cps);
+ GNUNET_TESTING_get_trait_connect_peer_state (cmd,
+ &cps);
void *ret = NULL;
cps->notify_connect (is,
diff --git
a/src/service/transport/test_transport_plugin_cmd_simple_send_broadcast.c
b/src/service/transport/test_transport_plugin_cmd_simple_send_broadcast.c
index d2870ab34..a63b6e926 100644
--- a/src/service/transport/test_transport_plugin_cmd_simple_send_broadcast.c
+++ b/src/service/transport/test_transport_plugin_cmd_simple_send_broadcast.c
@@ -154,10 +154,8 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"notify_connect\n");
-
GNUNET_TESTING_get_trait_async_context (&connect_peers,
&ac);
-
if (NULL != ac->is)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -172,7 +170,6 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
{
cmd = GNUNET_TESTING_interpreter_lookup_future_command (is,
"connect-peers");
-
LOG (GNUNET_ERROR_TYPE_DEBUG,
"block state %s\n",
cmd->label);
diff --git a/src/service/transport/test_transport_plugin_cmd_simple_send_dv.c
b/src/service/transport/test_transport_plugin_cmd_simple_send_dv.c
index d35672cd9..695344287 100644
--- a/src/service/transport/test_transport_plugin_cmd_simple_send_dv.c
+++ b/src/service/transport/test_transport_plugin_cmd_simple_send_dv.c
@@ -91,11 +91,10 @@ handle_test (void *cls,
struct GNUNET_TRANSPORT_CoreHandle *ch;
const struct GNUNET_TESTING_StartPeerState *sps;
-
- GNUNET_TRANSPORT_get_trait_state (&start_peer,
+ GNUNET_TESTING_get_trait_state (&start_peer,
&sps);
ch = sps->th;
- GNUNET_TRANSPORT_get_trait_connected_peers_map (&start_peer,
+ GNUNET_TESTING_get_trait_connected_peers_map (&start_peer,
&connected_peers_map);
if (NULL != connected_peers_map)
@@ -211,7 +210,7 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
cmd = GNUNET_TESTING_interpreter_lookup_command_all (is,
"connect-peers");
// FIXME: check return value!
- GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
+ GNUNET_TESTING_get_trait_connect_peer_state (cmd,
&cps);
cps->notify_connect (is,
peer);
diff --git
a/src/service/transport/test_transport_plugin_cmd_simple_send_performance.c
b/src/service/transport/test_transport_plugin_cmd_simple_send_performance.c
index 2baa7b5b4..d44eab9e1 100644
--- a/src/service/transport/test_transport_plugin_cmd_simple_send_performance.c
+++ b/src/service/transport/test_transport_plugin_cmd_simple_send_performance.c
@@ -114,8 +114,8 @@ handle_test (void *cls,
const struct GNUNET_TESTING_StartPeerState *sps;
- GNUNET_TRANSPORT_get_trait_state (&start_peer,
- &sps);
+ GNUNET_TESTING_get_trait_state (&start_peer,
+ &sps);
ch = sps->th;
num = ntohl (message->num);
GNUNET_TESTING_get_trait_async_context (&block_receive,
@@ -254,8 +254,8 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
cmd = GNUNET_TESTING_interpreter_lookup_command (is,
"connect-peers");
- GNUNET_TRANSPORT_get_trait_connect_peer_state (cmd,
- &cps);
+ GNUNET_TESTING_get_trait_connect_peer_state (cmd,
+ &cps);
void *ret = NULL;
cps->notify_connect (is,
diff --git a/src/service/transport/test_transport_plugin_cmd_udp_backchannel.c
b/src/service/transport/test_transport_plugin_cmd_udp_backchannel.c
index 378caf7df..15677eca8 100644
--- a/src/service/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/service/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -146,8 +146,8 @@ notify_connect (struct GNUNET_TESTING_Interpreter *is,
{
const struct ConnectPeersState *cps;
- GNUNET_TRANSPORT_get_trait_connect_peer_state (&connect_peers,
- &cps);
+ GNUNET_TESTING_get_trait_connect_peer_state (&connect_peers,
+ &cps);
void *ret = NULL;
cps->notify_connect (is,
diff --git a/src/service/testing/testing_api_cmd_start_peer.c
b/src/service/transport/testing_api_cmd_start_peer.c
similarity index 99%
rename from src/service/testing/testing_api_cmd_start_peer.c
rename to src/service/transport/testing_api_cmd_start_peer.c
index cd4536131..3932be74b 100644
--- a/src/service/testing/testing_api_cmd_start_peer.c
+++ b/src/service/transport/testing_api_cmd_start_peer.c
@@ -25,9 +25,10 @@
*/
#include "platform.h"
#include "gnunet_util_lib.h"
-#include "testing_cmds.h"
+#include "transport-testing-cmds.h"
#include "gnunet_testing_ng_lib.h"
-#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_transport_testing_ng_lib.h"
+
/**
* Generic logging shortcut
@@ -246,8 +247,6 @@ start_peer_traits (void *cls,
sps->connected_peers_map;
char *hello = sps->hello;
size_t hello_size = sps->hello_size;
-
-
struct GNUNET_TESTING_Trait traits[] = {
GNUNET_TESTING_make_trait_application_handle ((const void *) ah),
GNUNET_TESTING_make_trait_peer_id ((const void *) id),
diff --git a/src/service/testing/testing_api_cmd_stop_peer.c
b/src/service/transport/testing_api_cmd_stop_peer.c
similarity index 98%
rename from src/service/testing/testing_api_cmd_stop_peer.c
rename to src/service/transport/testing_api_cmd_stop_peer.c
index 2cbf978c6..76a63e319 100644
--- a/src/service/testing/testing_api_cmd_stop_peer.c
+++ b/src/service/transport/testing_api_cmd_stop_peer.c
@@ -26,7 +26,7 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
-#include "gnunet_testing_netjail_lib.h"
+#include "gnunet_transport_testing_ng_lib.h"
/**
* Generic logging shortcut
diff --git a/src/service/transport/transport-testing-cmds.h
b/src/service/transport/transport-testing-cmds.h
index 6b6fcf4f1..057f6ea14 100644
--- a/src/service/transport/transport-testing-cmds.h
+++ b/src/service/transport/transport-testing-cmds.h
@@ -26,8 +26,84 @@
*/
#ifndef TRANSPORT_TESTING_CMDS_H
#define TRANSPORT_TESTING_CMDS_H
+
#include "gnunet_testing_ng_lib.h"
-#include "gnunet_testing_plugin.h"
+#include "gnunet_transport_testing_ng_lib.h"
+
+
+/**
+ * Struct to store information needed in callbacks.
+ *
+ */
+// FIXME: breaks naming conventions! Needed public?
+struct ConnectPeersState
+{
+ /**
+ * Context for our asynchronous completion.
+ */
+ struct GNUNET_TESTING_AsyncContext ac;
+
+ GNUNET_TESTING_notify_connect_cb notify_connect;
+
+ /**
+ * The testing system of this node.
+ */
+ const struct GNUNET_TESTING_System *tl_system;
+
+ // Label of the cmd which started the test system.
+ const char *create_label;
+
+ /**
+ * Number globally identifying the node.
+ *
+ */
+ uint32_t num;
+
+ /**
+ * Label of the cmd to start a peer.
+ *
+ */
+ const char *start_peer_label;
+
+ /**
+ * The topology of the test setup.
+ */
+ struct GNUNET_TESTING_NetjailTopology *topology;
+
+ /**
+ * Connections to other peers.
+ */
+ struct GNUNET_TESTING_NodeConnection *node_connections_head;
+
+ struct GNUNET_TESTING_Interpreter *is;
+
+ /**
+ * Number of connections.
+ */
+ unsigned int con_num;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by
this cmd.
+ */
+ unsigned int additional_connects;
+
+ /**
+ * Number of connections we already have a notification for.
+ */
+ unsigned int con_num_notified;
+
+ /**
+ * Number of additional connects this cmd will wait for not triggered by
this cmd we already have a notification for.
+ */
+ unsigned int additional_connects_notified;
+
+ /**
+ * Flag indicating, whether the command is waiting for peers to connect that
are configured to connect.
+ */
+ unsigned int wait_for_connect;
+};
+
+
typedef void *
(*GNUNET_TRANSPORT_notify_connect_cb) (struct GNUNET_TESTING_Interpreter *is,
@@ -183,62 +259,14 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label,
topology);
-/**
- * Create headers for a trait with name @a name for
- * statically allocated data of type @a type.
- */
-#define GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TRANSPORT_get_trait_ ## name ( \
- const struct GNUNET_TESTING_Command *cmd, \
- type **ret); \
- struct GNUNET_TESTING_Trait \
- GNUNET_TRANSPORT_make_trait_ ## name ( \
- type * value);
-
-
-/**
- * Create C implementation for a trait with name @a name for statically
- * allocated data of type @a type.
- */
-#define GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT(name,type) \
- enum GNUNET_GenericReturnValue \
- GNUNET_TRANSPORT_get_trait_ ## name ( \
- const struct GNUNET_TESTING_Command *cmd, \
- type **ret) \
- { \
- if (NULL == cmd->traits) return GNUNET_SYSERR; \
- return cmd->traits (cmd->cls, \
- (const void **) ret, \
- GNUNET_S (name), \
- 0); \
- } \
- struct GNUNET_TESTING_Trait \
- GNUNET_TRANSPORT_make_trait_ ## name ( \
- type * value) \
- { \
- struct GNUNET_TESTING_Trait ret = { \
- .trait_name = GNUNET_S (name), \
- .ptr = (const void *) value \
- }; \
- return ret; \
- }
-
/**
* Call #op on all simple traits.
*/
#define GNUNET_TRANSPORT_SIMPLE_TRAITS(op) \
- op (peer_id, const struct GNUNET_PeerIdentity) \
- op (connected_peers_map, const struct GNUNET_CONTAINER_MultiShortmap) \
- op (hello_size, const size_t) \
- op (hello, const char) \
- op (application_handle, const struct GNUNET_TRANSPORT_ApplicationHandle) \
- op (connect_peer_state, const struct ConnectPeersState) \
- op (state, const struct GNUNET_TESTING_StartPeerState) \
- op (broadcast, const enum GNUNET_GenericReturnValue)
-
-GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_DECL_SIMPLE_TRAIT)
+ op (connect_peer_state, const struct ConnectPeersState)
+
+GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_DECL_SIMPLE_TRAIT)
#endif
diff --git a/src/service/transport/transport_api_cmd_backchannel_check.c
b/src/service/transport/transport_api_cmd_backchannel_check.c
index 388001496..0b57ddabd 100644
--- a/src/service/transport/transport_api_cmd_backchannel_check.c
+++ b/src/service/transport/transport_api_cmd_backchannel_check.c
@@ -417,8 +417,8 @@ backchannel_check_run (void *cls,
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
cs->start_peer_label);
- GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
- &ah);
+ GNUNET_TESTING_get_trait_application_handle (peer1_cmd,
+ &ah);
system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
cs->create_label);
diff --git a/src/service/transport/transport_api_cmd_connecting_peers.c
b/src/service/transport/transport_api_cmd_connecting_peers.c
index e38d5b860..8498efa42 100644
--- a/src/service/transport/transport_api_cmd_connecting_peers.c
+++ b/src/service/transport/transport_api_cmd_connecting_peers.c
@@ -26,9 +26,9 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
-#include "gnunet_testing_netjail_lib.h"
-#include "gnunet_transport_application_service.h"
+#include "gnunet_transport_testing_ng_lib.h"
#include "transport-testing-cmds.h"
+#include "gnunet_transport_application_service.h"
/**
* Generic logging shortcut
@@ -67,8 +67,8 @@ connect_peers_run (void *cls,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Wait for connect.\n");
- GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
- &ah);
+ GNUNET_TESTING_get_trait_application_handle (peer1_cmd,
+ &ah);
}
else
{
@@ -78,8 +78,8 @@ connect_peers_run (void *cls,
&ah);
}
- GNUNET_TRANSPORT_get_trait_broadcast (peer1_cmd,
- &broadcast);
+ GNUNET_TESTING_get_trait_broadcast (peer1_cmd,
+ &broadcast);
system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
cps->create_label);
@@ -249,7 +249,7 @@ connect_peers_traits (void *cls,
{
struct ConnectPeersState *cps = cls;
struct GNUNET_TESTING_Trait traits[] = {
- GNUNET_TRANSPORT_make_trait_connect_peer_state ((const void *) cps),
+ GNUNET_TESTING_make_trait_connect_peer_state ((const void *) cps),
GNUNET_TESTING_trait_end ()
};
return GNUNET_TESTING_get_trait (traits,
@@ -307,3 +307,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
&connect_peers_traits,
NULL);
}
+
+
+// FIXME: likely not ideally placed here, move to its own file
+GNUNET_TRANSPORT_TESTING_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
diff --git a/src/service/transport/transport_api_cmd_send_simple.c
b/src/service/transport/transport_api_cmd_send_simple.c
index 2671727c0..4013a1556 100644
--- a/src/service/transport/transport_api_cmd_send_simple.c
+++ b/src/service/transport/transport_api_cmd_send_simple.c
@@ -122,8 +122,8 @@ send_simple_run (void *cls,
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
sss->start_peer_label);
- GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
- &connected_peers_map);
+ GNUNET_TESTING_get_trait_connected_peers_map (peer1_cmd,
+ &connected_peers_map);
system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
sss->create_label);
diff --git a/src/service/transport/transport_api_cmd_send_simple_performance.c
b/src/service/transport/transport_api_cmd_send_simple_performance.c
index 7ce3b8bf7..d6581c4e1 100644
--- a/src/service/transport/transport_api_cmd_send_simple_performance.c
+++ b/src/service/transport/transport_api_cmd_send_simple_performance.c
@@ -173,8 +173,8 @@ send_simple_run (void *cls,
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
sss->start_peer_label);
- GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
- &connected_peers_map);
+ GNUNET_TESTING_get_trait_connected_peers_map (peer1_cmd,
+ &connected_peers_map);
system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
sss->create_label);
diff --git a/src/service/transport/transport_api_cmd_start_peer.c
b/src/service/transport/transport_api_cmd_start_peer.c
index 54e204a21..642478109 100644
--- a/src/service/transport/transport_api_cmd_start_peer.c
+++ b/src/service/transport/transport_api_cmd_start_peer.c
@@ -420,15 +420,15 @@ start_peer_traits (void *cls,
struct GNUNET_TESTING_Trait traits[] = {
- GNUNET_TRANSPORT_make_trait_application_handle ((const void *) ah),
- GNUNET_TRANSPORT_make_trait_peer_id ((const void *) id),
- GNUNET_TRANSPORT_make_trait_connected_peers_map ((const
+ GNUNET_TESTING_make_trait_application_handle ((const void *) ah),
+ GNUNET_TESTING_make_trait_peer_id ((const void *) id),
+ GNUNET_TESTING_make_trait_connected_peers_map ((const
void *)
connected_peers_map),
- GNUNET_TRANSPORT_make_trait_hello ((const void *) hello),
- GNUNET_TRANSPORT_make_trait_hello_size ((const void *) hello_size),
- GNUNET_TRANSPORT_make_trait_state ((const void *) sps),
- GNUNET_TRANSPORT_make_trait_broadcast ((const void *) &sps->broadcast),
+ GNUNET_TESTING_make_trait_hello ((const void *) hello),
+ GNUNET_TESTING_make_trait_hello_size ((const void *) hello_size),
+ GNUNET_TESTING_make_trait_state ((const void *) sps),
+ GNUNET_TESTING_make_trait_broadcast ((const void *) &sps->broadcast),
GNUNET_TESTING_trait_end ()
};
diff --git a/src/service/transport/transport_api_cmd_stop_peer.c
b/src/service/transport/transport_api_cmd_stop_peer.c
index 795a2f0f3..cd6863711 100644
--- a/src/service/transport/transport_api_cmd_stop_peer.c
+++ b/src/service/transport/transport_api_cmd_stop_peer.c
@@ -63,8 +63,8 @@ stop_peer_run (void *cls,
start_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
stop_ps->start_label);
- GNUNET_TRANSPORT_get_trait_state (start_cmd,
- &sps);
+ GNUNET_TESTING_get_trait_state (start_cmd,
+ &sps);
if (NULL != sps->pic)
{
diff --git a/src/service/transport/transport_api_traits.c
b/src/service/transport/transport_api_traits.c
index 7e66cc3d1..78f306019 100644
--- a/src/service/transport/transport_api_traits.c
+++ b/src/service/transport/transport_api_traits.c
@@ -29,4 +29,4 @@
#include "transport-testing-cmds.h"
#include "gnunet_util_lib.h"
-GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TRANSPORT_MAKE_IMPL_SIMPLE_TRAIT)
+GNUNET_TRANSPORT_SIMPLE_TRAITS (GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT)
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: NEWS: libgnunettesting first major testing NG refactor towards getting dependency structure streamlined,
gnunet <=