aboutsummaryrefslogtreecommitdiff
path: root/src/multicast
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2014-05-27 11:23:23 +0000
committerGabor X Toth <*@tg-x.net>2014-05-27 11:23:23 +0000
commit72180436df2aff18a417a39059664072e02b09dc (patch)
tree09d0f17a770bee0dea7f8e2abf5eed19ead5625d /src/multicast
parentcfeccc1b56def35ac586ac2c09ac70b523b59ef5 (diff)
downloadgnunet-72180436df2aff18a417a39059664072e02b09dc.tar.gz
gnunet-72180436df2aff18a417a39059664072e02b09dc.zip
multicast: run testing peer
Diffstat (limited to 'src/multicast')
-rw-r--r--src/multicast/Makefile.am7
-rw-r--r--src/multicast/test_multicast.c164
-rw-r--r--src/multicast/test_multicast.conf2
3 files changed, 146 insertions, 27 deletions
diff --git a/src/multicast/Makefile.am b/src/multicast/Makefile.am
index 8ccc7b88a..8d4813e54 100644
--- a/src/multicast/Makefile.am
+++ b/src/multicast/Makefile.am
@@ -66,5 +66,10 @@ endif
66test_multicast_SOURCES = \ 66test_multicast_SOURCES = \
67 test_multicast.c 67 test_multicast.c
68test_multicast_LDADD = \ 68test_multicast_LDADD = \
69 libgnunetmulticast.la \
70 $(top_builddir)/src/testing/libgnunettesting.la \
71 $(top_builddir)/src/util/libgnunetutil.la
72test_multicast_DEPENDENCIES = \
73 libgnunetmulticast.la \
74 $(top_builddir)/src/testing/libgnunettesting.la \
69 $(top_builddir)/src/util/libgnunetutil.la 75 $(top_builddir)/src/util/libgnunetutil.la
70
diff --git a/src/multicast/test_multicast.c b/src/multicast/test_multicast.c
index 244634c64..73606c4b0 100644
--- a/src/multicast/test_multicast.c
+++ b/src/multicast/test_multicast.c
@@ -1,44 +1,156 @@
1/* 1/*
2 This file is part of GNUnet. 2 * This file is part of GNUnet
3 (C) 2009 Christian Grothoff (and other contributing authors) 3 * (C) 2013 Christian Grothoff (and other contributing authors)
4 4 *
5 GNUnet is free software; you can redistribute it and/or modify 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 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 7 * by the Free Software Foundation; either version 3, or (at your
8 option) any later version. 8 * option) any later version.
9 9 *
10 GNUnet is distributed in the hope that it will be useful, but 10 * GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 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., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
14 20
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/** 21/**
21 * @file multicast/test_multicast.c 22 * @file multicast/test_multicast.c
22 * @brief testcase for multicast_api.c 23 * @brief Tests for the Multicast API.
24 * @author Gabor X Toth
23 */ 25 */
26
27#include <inttypes.h>
28
24#include "platform.h" 29#include "platform.h"
30#include "gnunet_crypto_lib.h"
31#include "gnunet_common.h"
25#include "gnunet_util_lib.h" 32#include "gnunet_util_lib.h"
33#include "gnunet_testing_lib.h"
34#include "gnunet_multicast_service.h"
35
36#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
37
38#define DEBUG_SERVICE 0
39
40/**
41 * Return value from 'main'.
42 */
43static int res;
44
45static const struct GNUNET_CONFIGURATION_Handle *cfg;
46
47/**
48 * Handle for task for timeout termination.
49 */
50static GNUNET_SCHEDULER_TaskIdentifier end_badly_task;
26 51
27 52
28static int 53/**
29check () 54 * Clean up all resources used.
55 */
56static void
57cleanup ()
30{ 58{
31 return 0; 59
32} 60}
33 61
34int 62
35main (int argc, char *argv[]) 63/**
64 * Terminate the test case (failure).
65 *
66 * @param cls NULL
67 * @param tc scheduler context
68 */
69static void
70end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
36{ 71{
37 int ret; 72 res = 1;
73 cleanup ();
74 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test FAILED.\n");
75}
38 76
39 ret = check ();
40 77
41 return ret; 78/**
79 * Terminate the test case (success).
80 *
81 * @param cls NULL
82 * @param tc scheduler context
83 */
84static void
85end_normally (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
86{
87 res = 0;
88 cleanup ();
89 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test PASSED.\n");
90}
91
92
93/**
94 * Finish the test case (successfully).
95 */
96static void
97end ()
98{
99 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending tests.\n");
100
101 if (end_badly_task != GNUNET_SCHEDULER_NO_TASK)
102 {
103 GNUNET_SCHEDULER_cancel (end_badly_task);
104 end_badly_task = GNUNET_SCHEDULER_NO_TASK;
105 }
106 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MILLISECONDS,
107 &end_normally, NULL);
108}
109
110
111/**
112 * Main function of the test, run from scheduler.
113 *
114 * @param cls NULL
115 * @param cfg configuration we use (also to connect to Multicast service)
116 * @param peer handle to access more of the peer (not used)
117 */
118static void
119#if DEBUG_SERVICE
120run (void *cls, char *const *args, const char *cfgfile,
121 const struct GNUNET_CONFIGURATION_Handle *c)
122#else
123run (void *cls,
124 const struct GNUNET_CONFIGURATION_Handle *c,
125 struct GNUNET_TESTING_Peer *peer)
126#endif
127{
128 cfg = c;
129 end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
130
131 /* FIXME: add tests */
132
133 end ();
134}
135
136
137int
138main (int argc, char *argv[])
139{
140 res = 1;
141#if DEBUG_SERVICE
142 const struct GNUNET_GETOPT_CommandLineOption opts[] = {
143 GNUNET_GETOPT_OPTION_END
144 };
145 if (GNUNET_OK != GNUNET_PROGRAM_run (argc, argv, "test-multicast",
146 "test-multicast [options]",
147 opts, &run, NULL))
148 return 1;
149#else
150 if (0 != GNUNET_TESTING_peer_run ("test-multicast", "test_multicast.conf", &run, NULL))
151 return 1;
152#endif
153 return res;
42} 154}
43 155
44/* end of test_multicast.c */ 156/* end of test_multicast.c */
diff --git a/src/multicast/test_multicast.conf b/src/multicast/test_multicast.conf
new file mode 100644
index 000000000..4ae899002
--- /dev/null
+++ b/src/multicast/test_multicast.conf
@@ -0,0 +1,2 @@
1[arm]
2DEFAULTSERVICES = cadet multicast