aboutsummaryrefslogtreecommitdiff
path: root/src/multicast
diff options
context:
space:
mode:
authorxrs <xrs@mail36.net>2016-09-07 17:45:15 +0000
committerxrs <xrs@mail36.net>2016-09-07 17:45:15 +0000
commit939d0142629866734169ed7b2741aac7edd32cfc (patch)
tree2f96a570638f2f28325083e6106c252994918f1c /src/multicast
parent020a9ae87f52e1e8020fd39016b546994c523eef (diff)
downloadgnunet-939d0142629866734169ed7b2741aac7edd32cfc.tar.gz
gnunet-939d0142629866734169ed7b2741aac7edd32cfc.zip
Add new testcase for multipeer scenario.
Diffstat (limited to 'src/multicast')
-rw-r--r--src/multicast/Makefile.am11
-rw-r--r--src/multicast/test_multicast.c2
-rw-r--r--src/multicast/test_multicast.conf4
-rw-r--r--src/multicast/test_multicast_multipeer.c172
4 files changed, 187 insertions, 2 deletions
diff --git a/src/multicast/Makefile.am b/src/multicast/Makefile.am
index fd1df191d..64c0bfe1d 100644
--- a/src/multicast/Makefile.am
+++ b/src/multicast/Makefile.am
@@ -52,7 +52,8 @@ gnunet_service_multicast_LDADD = \
52 52
53 53
54check_PROGRAMS = \ 54check_PROGRAMS = \
55 test_multicast 55 test_multicast \
56 test_multicast_multipeer
56 57
57if ENABLE_TEST_RUN 58if ENABLE_TEST_RUN
58AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH; 59AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;
@@ -66,3 +67,11 @@ test_multicast_LDADD = \
66 $(top_builddir)/src/testing/libgnunettesting.la \ 67 $(top_builddir)/src/testing/libgnunettesting.la \
67 $(top_builddir)/src/util/libgnunetutil.la \ 68 $(top_builddir)/src/util/libgnunetutil.la \
68 $(top_builddir)/src/core/libgnunetcore.la 69 $(top_builddir)/src/core/libgnunetcore.la
70
71test_multicast_multipeer_SOURCE = \
72 test_multicast_multipeer.c
73test_multicast_multipeer_LDADD = \
74 libgnunetmulticast.la \
75 $(top_builddir)/src/testbed/libgnunettestbed.la \
76 $(top_builddir)/src/util/libgnunetutil.la \
77 $(top_builddir)/src/core/libgnunetcore.la
diff --git a/src/multicast/test_multicast.c b/src/multicast/test_multicast.c
index 613a8c593..11f42ff82 100644
--- a/src/multicast/test_multicast.c
+++ b/src/multicast/test_multicast.c
@@ -441,7 +441,7 @@ origin_recv_request (void *cls,
441 441
442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 442 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
443 "Test #%u: verify message content, take first 3 bytes: %.3s\n", 443 "Test #%u: verify message content, take first 3 bytes: %.3s\n",
444 test, &req[1]); 444 test, (char *)&req[1]);
445 GNUNET_assert (0 == memcmp (&req[1], "abc", 3)); 445 GNUNET_assert (0 == memcmp (&req[1], "abc", 3));
446 446
447 // Test 7 starts here 447 // Test 7 starts here
diff --git a/src/multicast/test_multicast.conf b/src/multicast/test_multicast.conf
index e69de29bb..675776bbc 100644
--- a/src/multicast/test_multicast.conf
+++ b/src/multicast/test_multicast.conf
@@ -0,0 +1,4 @@
1[arm]
2GLOBAL_POSTFIX=-L ERROR
3
4#PREFIX = sakura -t test-multicast -e cgdb --args
diff --git a/src/multicast/test_multicast_multipeer.c b/src/multicast/test_multicast_multipeer.c
new file mode 100644
index 000000000..4d958b1a4
--- /dev/null
+++ b/src/multicast/test_multicast_multipeer.c
@@ -0,0 +1,172 @@
1/*
2 * This file is part of GNUnet
3 * Copyright (C) 2013 GNUnet e.V.
4 *
5 * GNUnet is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 3, or (at your
8 * option) any later version.
9 *
10 * GNUnet is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with GNUnet; see the file COPYING. If not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21/**
22 * @file multicast/test_multicast_multipeers.c
23 * @brief Tests for the Multicast API with multiple peers.
24 * @author xrs
25 */
26
27#include <inttypes.h>
28
29#include "platform.h"
30#include "gnunet_crypto_lib.h"
31#include "gnunet_common.h"
32#include "gnunet_util_lib.h"
33#include "gnunet_testbed_service.h"
34#include "gnunet_core_service.h"
35#include "gnunet_multicast_service.h"
36
37#define NUM_PEERS 2
38
39static struct GNUNET_TESTBED_Operation *multicast_peer0;
40static struct GNUNET_TESTBED_Operation *multicast_peer1;
41
42static struct GNUNET_SCHEDULER_Task * shutdown_tid;
43
44
45/**
46 * Global result for testcase.
47 */
48static int result;
49
50
51/**
52 * Function run on CTRL-C or shutdown (i.e. success/timeout/etc.).
53 * Cleans up.
54 */
55static void
56shutdown_task (void *cls)
57{
58 shutdown_tid = NULL;
59 //if (NULL != dht_op)
60 //{
61 // GNUNET_TESTBED_operation_done (dht_op);
62 //dht_op = NULL;
63 //dht_handle = NULL;
64 //}
65 result = GNUNET_OK;
66 GNUNET_SCHEDULER_shutdown (); /* Also kills the testbed */
67}
68
69
70static void
71service_close_peer0 (void *cls, void *op_result) {
72 /* Disconnect from service */
73}
74
75/**
76 * Function run when service multicast has started and is providing us
77 * with a configuration file.
78 */
79static void *
80service_conf_peer0 (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
81{
82 /* Use the provided configuration to connect to service */
83 return NULL;
84}
85
86/**
87 * Test logic of peer "0" being origin starts here.
88 *
89 * @param cls closure, for the example: NULL
90 * @param op should be equal to "dht_op"
91 * @param ca_result result of the connect operation, the
92 * connection to the DHT service
93 * @param emsg error message, if testbed somehow failed to
94 * connect to the DHT.
95 */
96static void
97service_connect_peer0 (void *cls,
98 struct GNUNET_TESTBED_Operation *op,
99 void *ca_result,
100 const char *emsg)
101{
102 /* Connection to service successful. Here we'd usually do something with
103 * the service. */
104}
105
106/**
107 * Main function inovked from TESTBED once all of the
108 * peers are up and running. This one then connects
109 * just to the multicast service of peer 0 and 1.
110 * Peer 0 is going to be origin.
111 * Peer 1 is going to be one member.
112 * Origin will start a multicast group and the member will try to join it.
113 * After that we execute some multicast test.
114 *
115 * @param cls closure
116 * @param h the run handle
117 * @param peers started peers for the test
118 * @param num_peers size of the 'peers' array
119 * @param links_succeeded number of links between peers that were created
120 * @param links_failed number of links testbed was unable to establish
121 */
122static void
123test_master (void *cls,
124 struct GNUNET_TESTBED_RunHandle *h,
125 unsigned int num_peers,
126 struct GNUNET_TESTBED_Peer **peers,
127 unsigned int links_succeeded,
128 unsigned int links_failed)
129{
130 /* Testbed is ready with peers running and connected in a pre-defined overlay
131 topology (FIXME) */
132
133 /* connect to a peers service */
134 multicast_peer0 = GNUNET_TESTBED_service_connect
135 (NULL, /* Closure for operation */
136 peers[0], /* The peer whose service to connect to */
137 "multicast", /* The name of the service */
138 service_connect_peer0, /* callback to call after a handle to service
139 is opened */
140 NULL, /* closure for the above callback */
141 service_conf_peer0, /* callback to call with peer's configuration;
142 this should open the needed service connection */
143 service_close_peer0, /* callback to be called when closing the
144 opened service connection */
145 NULL); /* closure for the above two callbacks */
146 shutdown_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
147 &shutdown_task, NULL);
148}
149
150
151int
152main (int argc, char *argv[])
153{
154 int ret;
155
156 result = GNUNET_SYSERR;
157 ret = GNUNET_TESTBED_test_run
158 ("test-multicast-multipeer", /* test case name */
159 "test_multicast.conf", /* template configuration */
160 NUM_PEERS, /* number of peers to start */
161 0LL, /* Event mask - set to 0 for no event notifications */
162 NULL, /* Controller event callback */
163 NULL, /* Closure for controller event callback */
164 &test_master, /* continuation callback to be called when testbed setup is
165 complete */
166 NULL); /* Closure for the test_master callback */
167 if ( (GNUNET_OK != ret) || (GNUNET_OK != result) )
168 return 1;
169 return 0;
170}
171
172/* end of test_multicast_multipeer.c */