From 4fa906387acd7e77d7521300602268927ddd9699 Mon Sep 17 00:00:00 2001 From: xrs Date: Sat, 29 Feb 2020 19:12:19 +0100 Subject: separate testbed management from test logic --- src/cadet/Makefile.am | 3 +- src/cadet/test_cadeT.c | 247 +--------------------------------------- src/cadet/test_cadeT_util.c | 271 ++++++++++++++++++++++++++++++++++++++++++++ src/cadet/test_cadeT_util.h | 38 +++++++ 4 files changed, 317 insertions(+), 242 deletions(-) create mode 100644 src/cadet/test_cadeT_util.c create mode 100644 src/cadet/test_cadeT_util.h diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am index 572bdf4d9..80294a785 100644 --- a/src/cadet/Makefile.am +++ b/src/cadet/Makefile.am @@ -141,7 +141,8 @@ dep_cadet_test_lib = \ $(top_builddir)/src/statistics/libgnunetstatistics.la test_cadet_2_channel_resumption_SOURCES = \ - test_cadeT.c + test_cadeT.c \ + test_cadeT_util.c test_cadeT_util.h test_cadet_2_channel_resumption_LDADD = $(ld_cadet_test_lib) test_cadet_2_forward_SOURCES = \ diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c index d4688273b..58b6db543 100644 --- a/src/cadet/test_cadeT.c +++ b/src/cadet/test_cadeT.c @@ -52,258 +52,23 @@ #include "platform.h" #include "gnunet_testbed_service.h" #include "cadet.h" +#include -#define REQUESTED_PEERS 2 #define CONFIG "test_cadet.conf" #define TESTPROGAM_NAME "test-cadet-channel-resumption" -#define TIMEOUT_IN_SEC 5 -#define PORTNAME "cadet_port" - -/** - * Testbed operation for connecting to the services. - */ -static struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; - -/** - * Testbed operation for requesting peer information. - */ -static struct GNUNET_TESTBED_Operation *testbed_info_req[2]; - -/** - * Port name kown by the two peers. - */ -static struct GNUNET_HashCode hashed_portname; - -/** - * Result of the test. - */ -static int test_result = 0; - -/** - * Counter for gathering peerinformation. - */ -static int peerinfo_cnt = 0; - -/** - * Structure for storing information of testbed peers. - */ -struct TEST_PEERS -{ - /** - * Index of the peer. - */ - int idx; - - /** - * Peer Identity. - */ - struct GNUNET_PeerIdentity id; - - /** - * Handle of TESTBED peer. - */ - struct GNUNET_TESTBED_Peer *testbed_peer; - - /** - * Testbed management is finished and test peer is ready for test logic. - */ - int ready; - - /** - * Channel of initiating peer. - */ - struct GNUNET_CADET_Channel *channel; - - /** - * CADET handle. - */ - struct GNUNET_CADET_Handle *cadet; - -} test_peers[2]; - /****************************** TEST LOGIC ********************************/ -// TBD - -/************************** TESBED MANAGEMENT *****************************/ - -static void -shutdown_task (void *cls) -{ - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); - - for (int i=0; iid = *(pinfo->result.id); - - if (peerinfo_complete()) - { - testbed_to_svc[1] = - GNUNET_TESTBED_service_connect (NULL, test_peers[1].testbed_peer, - "cadet", - &check_test_readyness, NULL, - &setup_listening_peer, - &disconnect_from_peer, NULL); - testbed_to_svc[0] = - GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer, - "cadet", - &check_test_readyness, NULL, - &setup_initiating_peer, - &disconnect_from_peer, NULL); - } + /** + * Do testing here. + */ } -static void -connect_to_peers (void *cls, - struct GNUNET_TESTBED_RunHandle *h, - unsigned int num_peers, - struct GNUNET_TESTBED_Peer **peers, - unsigned int links_succeeded, - unsigned int links_failed) -{ - GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); - - GNUNET_assert (0 == links_failed); - - for (int i=0; i. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/** + * @file cadet/test_cadeT_util.c + * @brief testcase for cadet.c + * @author xrs + */ + +#include + +/** + * Testbed operation for connecting to the services. + */ +static struct GNUNET_TESTBED_Operation *testbed_to_svc[2]; + +/** + * Testbed operation for requesting peer information. + */ +static struct GNUNET_TESTBED_Operation *testbed_info_req[2]; + +/** + * Port name kown by the two peers. + */ +static struct GNUNET_HashCode hashed_portname; + +/** + * Result of the test. + */ +int test_result = 0; + +/** + * Counter for gathering peerinformation. + */ +static int peerinfo_cnt = 0; + +/** + * Structure for storing information of testbed peers. + */ +struct TEST_PEERS +{ + /** + * Index of the peer. + */ + int idx; + + /** + * Peer Identity. + */ + struct GNUNET_PeerIdentity id; + + /** + * Handle of TESTBED peer. + */ + struct GNUNET_TESTBED_Peer *testbed_peer; + + /** + * Testbed management is finished and test peer is ready for test logic. + */ + int ready; + + /** + * Channel of initiating peer. + */ + struct GNUNET_CADET_Channel *channel; + + /** + * CADET handle. + */ + struct GNUNET_CADET_Handle *cadet; + +} test_peers[2]; + +/************************** TESBED MANAGEMENT *****************************/ + +static void +shutdown_task (void *cls) +{ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + + for (int i=0; iid = *(pinfo->result.id); + + if (peerinfo_complete()) + { + testbed_to_svc[1] = + GNUNET_TESTBED_service_connect (NULL, test_peers[1].testbed_peer, + "cadet", + &check_test_readyness, NULL, + &setup_listening_peer, + &disconnect_from_peer, NULL); + testbed_to_svc[0] = + GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer, + "cadet", + &check_test_readyness, NULL, + &setup_initiating_peer, + &disconnect_from_peer, NULL); + } +} + +void +connect_to_peers (void *cls, + struct GNUNET_TESTBED_RunHandle *h, + unsigned int num_peers, + struct GNUNET_TESTBED_Peer **peers, + unsigned int links_succeeded, + unsigned int links_failed) +{ + GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); + + GNUNET_assert (0 == links_failed); + + for (int i=0; i. + + SPDX-License-Identifier: AGPL3.0-or-later + */ +/** + * @file cadet/test_cadeT_util.h + * @brief testcase for cadet.c + * @author xrs + */ + +#include "platform.h" +#include "gnunet_testbed_service.h" +#include "cadet.h" + +#define REQUESTED_PEERS 2 +#define TIMEOUT_IN_SEC 5 +#define PORTNAME "cadet_port" + +int test_result; + +void connect_to_peers (); + +void run_test (); -- cgit v1.2.3