aboutsummaryrefslogtreecommitdiff
path: root/src/ats
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2015-01-16 10:15:42 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2015-01-16 10:15:42 +0000
commitab3bb8c4287493e878d91882c0cbc132b2b391e7 (patch)
treefa2532fcc5cc88394e7569de9d4e88e333daa5b2 /src/ats
parentd345f2161a4c7c925ae541d6d76086afc82a245a (diff)
downloadgnunet-ab3bb8c4287493e878d91882c0cbc132b2b391e7.tar.gz
gnunet-ab3bb8c4287493e878d91882c0cbc132b2b391e7.zip
new testcase to test delayed ATS service startup
Diffstat (limited to 'src/ats')
-rw-r--r--src/ats/Makefile.am22
-rw-r--r--src/ats/test_ats_api_delayed.conf36
-rw-r--r--src/ats/test_ats_api_delayed_service_performance_list_all_addresses.c305
-rw-r--r--src/ats/test_ats_api_delayed_service_scheduling_add_address.c234
-rwxr-xr-xsrc/ats/test_delay18
5 files changed, 615 insertions, 0 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index c6e7c186d..7f91060eb 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -117,7 +117,9 @@ TESTING_TESTS = \
117 test_ats_api_scheduling_destroy_address_twice \ 117 test_ats_api_scheduling_destroy_address_twice \
118 test_ats_api_scheduling_add_session \ 118 test_ats_api_scheduling_add_session \
119 test_ats_api_scheduling_destroy_session \ 119 test_ats_api_scheduling_destroy_session \
120 test_ats_api_delayed_service_scheduling_add_address \
120 test_ats_api_performance_list_all_addresses \ 121 test_ats_api_performance_list_all_addresses \
122 test_ats_api_delayed_service_performance_list_all_addresses \
121 test_ats_api_performance_list_peer_addresses \ 123 test_ats_api_performance_list_peer_addresses \
122 test_ats_api_performance_list_all_addresses_active \ 124 test_ats_api_performance_list_all_addresses_active \
123 test_ats_api_performance_monitor \ 125 test_ats_api_performance_monitor \
@@ -173,6 +175,15 @@ test_ats_api_scheduling_add_address_LDADD = \
173 libgnunetats.la \ 175 libgnunetats.la \
174 $(top_builddir)/src/statistics/libgnunetstatistics.la 176 $(top_builddir)/src/statistics/libgnunetstatistics.la
175 177
178test_ats_api_delayed_service_scheduling_add_address_SOURCES = \
179 test_ats_api_delayed_service_scheduling_add_address.c \
180 test_ats_api_common.c test_ats_api_common.h
181test_ats_api_delayed_service_scheduling_add_address_LDADD = \
182 $(top_builddir)/src/util/libgnunetutil.la \
183 $(top_builddir)/src/testing/libgnunettesting.la \
184 libgnunetats.la \
185 $(top_builddir)/src/statistics/libgnunetstatistics.la
186
176test_ats_api_scheduling_add_address_inbound_SOURCES = \ 187test_ats_api_scheduling_add_address_inbound_SOURCES = \
177 test_ats_api_scheduling_add_address_inbound.c \ 188 test_ats_api_scheduling_add_address_inbound.c \
178 test_ats_api_common.c test_ats_api_common.h 189 test_ats_api_common.c test_ats_api_common.h
@@ -235,6 +246,15 @@ test_ats_api_performance_list_all_addresses_LDADD = \
235 $(top_builddir)/src/hello/libgnunethello.la \ 246 $(top_builddir)/src/hello/libgnunethello.la \
236 libgnunetats.la \ 247 libgnunetats.la \
237 $(top_builddir)/src/statistics/libgnunetstatistics.la 248 $(top_builddir)/src/statistics/libgnunetstatistics.la
249
250test_ats_api_delayed_service_performance_list_all_addresses_SOURCES = \
251 test_ats_api_delayed_service_performance_list_all_addresses.c
252test_ats_api_delayed_service_performance_list_all_addresses_LDADD = \
253 $(top_builddir)/src/util/libgnunetutil.la \
254 $(top_builddir)/src/testing/libgnunettesting.la \
255 $(top_builddir)/src/hello/libgnunethello.la \
256 libgnunetats.la \
257 $(top_builddir)/src/statistics/libgnunetstatistics.la
238 258
239test_ats_api_performance_list_peer_addresses_SOURCES = \ 259test_ats_api_performance_list_peer_addresses_SOURCES = \
240 test_ats_api_performance_list_peer_addresses.c 260 test_ats_api_performance_list_peer_addresses.c
@@ -500,7 +520,9 @@ test_ats_solver_preferences_ril_LDADD = \
500 520
501EXTRA_DIST = \ 521EXTRA_DIST = \
502 ats.h \ 522 ats.h \
523 test_delay \
503 test_ats_api.conf \ 524 test_ats_api.conf \
525 test_ats_api_delayed.conf \
504 test_ats_mlp.conf \ 526 test_ats_mlp.conf \
505 test_ats_solver_default.conf \ 527 test_ats_solver_default.conf \
506 test_ats_solver_proportional.conf \ 528 test_ats_solver_proportional.conf \
diff --git a/src/ats/test_ats_api_delayed.conf b/src/ats/test_ats_api_delayed.conf
new file mode 100644
index 000000000..ab645d802
--- /dev/null
+++ b/src/ats/test_ats_api_delayed.conf
@@ -0,0 +1,36 @@
1@INLINE@ ../../contrib/no_forcestart.conf
2
3[PATHS]
4GNUNET_TEST_HOME = /tmp/test-ats-api-scheduling/
5
6[ats]
7PREFIX = ./test_delay -t 10 --
8# Enable MLP mode (default: NO)
9#MODE = RIL
10MODE = MLP
11# Network specific inbound/outbound quotas
12# UNSPECIFIED
13UNSPECIFIED_QUOTA_IN = 64 KiB
14UNSPECIFIED_QUOTA_OUT = 64 KiB
15# LOOPBACK
16LOOPBACK_QUOTA_IN = unlimited
17LOOPBACK_QUOTA_OUT = unlimited
18# LAN
19LAN_QUOTA_IN = unlimited
20LAN_QUOTA_OUT = unlimited
21# WAN
22WAN_QUOTA_IN = 64 KiB
23WAN_QUOTA_OUT = 64 KiB
24# WLAN
25WLAN_QUOTA_IN = 512
26WLAN_QUOTA_OUT = 512
27
28# ATS extended options
29DUMP_MLP = NO
30DUMP_SOLUTION = NO
31DUMP_OVERWRITE = NO
32DUMP_MIN_PEERS = 0
33DUMP_MIN_ADDRS = 0
34DUMP_OVERWRITE = NO
35ATS_MIN_INTERVAL = 15000
36ATS_EXEC_INTERVAL = 30000
diff --git a/src/ats/test_ats_api_delayed_service_performance_list_all_addresses.c b/src/ats/test_ats_api_delayed_service_performance_list_all_addresses.c
new file mode 100644
index 000000000..69507e71a
--- /dev/null
+++ b/src/ats/test_ats_api_delayed_service_performance_list_all_addresses.c
@@ -0,0 +1,305 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 */
20/**
21 * @file ats/test_ats_api_delayed_service_performance_list_all_addresses.c
22 * @brief test performance API's address listing feature with a delayed service startup
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25 */
26#include "platform.h"
27#include "gnunet_ats_service.h"
28#include "gnunet_testing_lib.h"
29#include "ats.h"
30
31#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
32
33static struct GNUNET_SCHEDULER_Task * die_task;
34
35/**
36 * Statistics handle
37 */
38struct GNUNET_STATISTICS_Handle *stats;
39
40/**
41 * Configuration handle
42 */
43struct GNUNET_CONFIGURATION_Handle *cfg;
44
45/**
46 * ATS scheduling handle
47 */
48static struct GNUNET_ATS_SchedulingHandle *sched_ats;
49
50/**
51 * ATS performance handle
52 */
53static struct GNUNET_ATS_PerformanceHandle *perf_ats;
54
55struct GNUNET_ATS_AddressListHandle* phal;
56
57static int ret;
58
59struct Address
60{
61 char *plugin;
62 size_t plugin_len;
63
64 void *addr;
65 size_t addr_len;
66
67 struct GNUNET_ATS_Information *ats;
68 int ats_count;
69
70 void *session;
71};
72
73struct PeerContext
74{
75 struct GNUNET_PeerIdentity id;
76
77 struct Address *addr;
78};
79
80static struct PeerContext p[2];
81
82static struct Address p0_addresses[2];
83static struct Address p1_addresses[2];
84
85struct GNUNET_HELLO_Address p0_ha[2];
86struct GNUNET_HELLO_Address p1_ha[2];
87struct GNUNET_HELLO_Address *s_ha[2];
88
89static void
90end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
91
92static void
93end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
94
95
96static void
97ats_perf_cb (void *cls,
98 const struct GNUNET_HELLO_Address *address,
99 int address_active,
100 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
101 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
102 const struct GNUNET_ATS_Information *ats,
103 uint32_t ats_count)
104{
105 static int counter = 0;
106
107 if (NULL == address)
108 {
109 phal = 0;
110 if (4 == counter)
111 {
112 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Done!\n");
113 GNUNET_SCHEDULER_add_now (end, NULL);
114 }
115 else
116 {
117 GNUNET_break (0);
118 GNUNET_SCHEDULER_add_now (end_badly, NULL);
119 }
120 return;
121 }
122 counter ++;
123}
124
125
126static int
127stat_cb(void *cls, const char *subsystem,
128 const char *name, uint64_t value,
129 int is_persistent)
130{
131
132 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ATS statistics: `%s' `%s' %llu\n",
133 subsystem,name, value);
134 if (4 == value)
135 {
136 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
137 "All addresses added, connecting to performance\n");
138 if (NULL == (perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL)))
139 {
140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
141 "Failed to connect to performance API\n");
142 GNUNET_SCHEDULER_add_now (end_badly, NULL);
143 }
144 phal = GNUNET_ATS_performance_list_addresses (perf_ats, NULL, GNUNET_YES, &ats_perf_cb, NULL);
145 }
146 return GNUNET_OK;
147}
148
149static void
150address_suggest_cb (void *cls,
151 const struct GNUNET_PeerIdentity *peer,
152 const struct GNUNET_HELLO_Address *address,
153 struct Session *session,
154 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
155 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
156 const struct GNUNET_ATS_Information *atsi,
157 uint32_t ats_count)
158{
159 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not expect suggestion callback!\n");
160 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
161 return;
162}
163
164
165static void
166end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
167{
168 die_task = NULL;
169 end ( NULL, NULL);
170 ret = GNUNET_SYSERR;
171}
172
173static void
174end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
175{
176 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
177 if (die_task != NULL )
178 {
179 GNUNET_SCHEDULER_cancel (die_task);
180 die_task = NULL;
181 }
182
183 if (NULL != sched_ats)
184 {
185 GNUNET_ATS_scheduling_done (sched_ats);
186 sched_ats = NULL;
187 }
188
189 if (phal != NULL )
190 {
191 GNUNET_ATS_performance_list_addresses_cancel (phal);
192 phal = NULL;
193 }
194
195 if (perf_ats != NULL )
196 {
197 GNUNET_ATS_performance_done (perf_ats);
198 perf_ats = NULL;
199 }
200
201 GNUNET_STATISTICS_watch_cancel (stats, "ats", "# addresses", &stat_cb, NULL);
202 if (NULL != stats)
203 {
204 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
205 stats = NULL;
206 }
207
208
209 GNUNET_free_non_null(p0_addresses[0].addr);
210 GNUNET_free_non_null(p0_addresses[1].addr);
211 GNUNET_free_non_null(p1_addresses[0].addr);
212 GNUNET_free_non_null(p1_addresses[1].addr);
213
214 ret = 0;
215}
216
217
218
219static void
220run (void *cls, const struct GNUNET_CONFIGURATION_Handle *mycfg,
221 struct GNUNET_TESTING_Peer *peer)
222{
223 ret = 1;
224 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
225 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL );
226
227 stats = GNUNET_STATISTICS_create ("ats", cfg);
228 GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
229
230 /* set up peer 0 */
231 memset (&p[0].id, '1', sizeof (p[0].id));
232 p0_addresses[0].plugin = "test";
233 p0_addresses[0].session = NULL;
234 p0_addresses[0].addr = GNUNET_strdup ("test_p0_a0");
235 p0_addresses[0].addr_len = strlen (p0_addresses[0].addr) + 1;
236
237 p0_ha[0].address = p0_addresses[0].addr;
238 p0_ha[0].address_length = p0_addresses[0].addr_len;
239 p0_ha[0].peer = p[0].id;
240 p0_ha[0].transport_name = p0_addresses[0].plugin;
241
242 p0_addresses[1].plugin = "test";
243 p0_addresses[1].session = NULL;
244 p0_addresses[1].addr = GNUNET_strdup ("test_p0_a1");
245 p0_addresses[1].addr_len = strlen (p0_addresses[1].addr) + 1;
246
247 p0_ha[1].address = p0_addresses[1].addr;
248 p0_ha[1].address_length = p0_addresses[1].addr_len;
249 p0_ha[1].peer = p[0].id;
250 p0_ha[1].transport_name = p0_addresses[1].plugin;
251
252 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Created peer 0: `%s'\n",
253 GNUNET_i2s (&p[0].id));
254
255 memset (&p[1].id, '2', sizeof (p[1].id));
256 p1_addresses[0].plugin = "test";
257 p1_addresses[0].session = NULL;
258 p1_addresses[0].addr = GNUNET_strdup ("test_p1_a0");
259 p1_addresses[0].addr_len = strlen (p1_addresses[0].addr) + 1;
260
261 p1_ha[0].address = p1_addresses[0].addr;
262 p1_ha[0].address_length = p1_addresses[0].addr_len;
263 p1_ha[0].peer = p[1].id;
264 p1_ha[0].transport_name = p1_addresses[0].plugin;
265
266 p1_addresses[1].plugin = "test";
267 p1_addresses[1].session = NULL;
268 p1_addresses[1].addr = GNUNET_strdup ("test_p1_a1");
269 p1_addresses[1].addr_len = strlen (p1_addresses[1].addr) + 1;
270
271 p1_ha[1].address = p1_addresses[1].addr;
272 p1_ha[1].address_length = p1_addresses[1].addr_len;
273 p1_ha[1].peer = p[1].id;
274 p1_ha[1].transport_name = p1_addresses[1].plugin;
275
276 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Created peer 1: `%s'\n",
277 GNUNET_i2s (&p[1].id));
278
279 /* Add addresses */
280 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL );
281 if (sched_ats == NULL )
282 {
283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
284 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
285 return;
286 }
287
288 GNUNET_ATS_address_add (sched_ats, &p0_ha[0], NULL, NULL, 0);
289 GNUNET_ATS_address_add (sched_ats, &p0_ha[1], NULL, NULL, 0);
290
291 GNUNET_ATS_address_add (sched_ats, &p1_ha[0], NULL, NULL, 0);
292 GNUNET_ATS_address_add (sched_ats, &p1_ha[1], NULL, NULL, 0);
293}
294
295int
296main (int argc, char *argv[])
297{
298 if (0
299 != GNUNET_TESTING_peer_run ("test_ats_api_performance",
300 "test_ats_api_delayed.conf", &run, NULL ))
301 return 1;
302 return ret;
303}
304
305/* end of file test_ats_api_delayed_service_performance_list_all_addresses.c */
diff --git a/src/ats/test_ats_api_delayed_service_scheduling_add_address.c b/src/ats/test_ats_api_delayed_service_scheduling_add_address.c
new file mode 100644
index 000000000..4e45ed918
--- /dev/null
+++ b/src/ats/test_ats_api_delayed_service_scheduling_add_address.c
@@ -0,0 +1,234 @@
1/*
2 This file is part of GNUnet.
3 (C) 2010,2011 Christian Grothoff (and other contributing authors)
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., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20/**
21 * @file ats/test_ats_api_delayed_service_scheduling_add_address.c
22 * @brief test case to ensure messages are transmitted to ATS service when
23 * service startup is delayed
24 * @author Christian Grothoff
25 * @author Matthias Wachs
26 */
27#include "platform.h"
28#include "gnunet_ats_service.h"
29#include "gnunet_testing_lib.h"
30#include "ats.h"
31#include "test_ats_api_common.h"
32
33/**
34 * Timeout task
35 */
36static struct GNUNET_SCHEDULER_Task * die_task;
37
38/**
39 * Statistics handle
40 */
41struct GNUNET_STATISTICS_Handle *stats;
42
43/**
44 * Scheduling handle
45 */
46static struct GNUNET_ATS_SchedulingHandle *sched_ats;
47
48/**
49 * Return value
50 */
51static int ret;
52
53/**
54 * Test address
55 */
56static struct Test_Address test_addr;
57
58/**
59 * Test peer
60 */
61static struct PeerContext p;
62
63/**
64 * HELLO address
65 */
66struct GNUNET_HELLO_Address test_hello_address;
67
68/**
69 * Session
70 */
71static void *test_session;
72
73/**
74 * Test ats info
75 */
76struct GNUNET_ATS_Information test_ats_info[2];
77
78/**
79 * Test ats count
80 */
81uint32_t test_ats_count;
82
83
84static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
85
86static int
87stat_cb(void *cls, const char *subsystem,
88 const char *name, uint64_t value,
89 int is_persistent)
90{
91
92 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "ATS statistics: `%s' `%s' %llu\n",
93 subsystem,name, value);
94 if (1 == value)
95 {
96 GNUNET_SCHEDULER_add_now (&end, NULL);
97 }
98 return GNUNET_OK;
99}
100
101
102static void
103end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
104{
105 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
106
107 if (die_task != NULL)
108 {
109 GNUNET_SCHEDULER_cancel (die_task);
110 die_task = NULL;
111 }
112
113 if (NULL != sched_ats)
114 {
115 GNUNET_ATS_scheduling_done (sched_ats);
116 sched_ats = NULL;
117 }
118
119 GNUNET_STATISTICS_watch_cancel (stats, "ats", "# addresses", &stat_cb, NULL);
120 if (NULL != stats)
121 {
122 GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
123 stats = NULL;
124 }
125
126 free_test_address (&test_addr);
127
128 ret = 0;
129}
130
131static void
132end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
133{
134 die_task = NULL;
135 end ( NULL, NULL);
136 ret = GNUNET_SYSERR;
137}
138
139static void
140address_suggest_cb (void *cls,
141 const struct GNUNET_PeerIdentity *peer,
142 const struct GNUNET_HELLO_Address *address,
143 struct Session *session,
144 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
145 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
146 const struct GNUNET_ATS_Information *atsi,
147 uint32_t ats_count)
148{
149 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not expect suggestion callback!\n");
150 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
151 return;
152}
153
154
155static void
156got_initial_value (void *cls, int success)
157{
158 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
159
160 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got initial value\n");
161
162 /* Connect to ATS scheduling */
163 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
164 if (sched_ats == NULL)
165 {
166 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
167 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
168 return;
169 }
170
171 /* Set up peer */
172 memset (&p.id, '1', sizeof (p.id));
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
174 GNUNET_i2s_full(&p.id));
175
176 /* Prepare ATS Information */
177 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
178 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
179 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
180 test_ats_info[1].value = htonl(1);
181 test_ats_count = 2;
182
183 /* Adding address without session */
184 test_session = NULL;
185 create_test_address (&test_addr, "test", test_session, "test", strlen ("test") + 1);
186 test_hello_address.peer = p.id;
187 test_hello_address.transport_name = test_addr.plugin;
188 test_hello_address.address = test_addr.addr;
189 test_hello_address.address_length = test_addr.addr_len;
190
191 /* Adding address */
192 GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
193
194}
195
196
197static int
198dummy_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
199 int is_persistent)
200{
201 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got dummy stat %s%s:%s = %llu\n",
202 is_persistent ? "!" : " ", subsystem, name, value);
203 return GNUNET_OK;
204}
205
206
207static void
208run (void *cls,
209 const struct GNUNET_CONFIGURATION_Handle *cfg,
210 struct GNUNET_TESTING_Peer *peer)
211{
212 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
213 stats = GNUNET_STATISTICS_create ("ats", cfg);
214 GNUNET_STATISTICS_watch (stats, "ats", "# addresses", &stat_cb, NULL);
215
216 GNUNET_STATISTICS_get (stats, "ats", "# addresses", TIMEOUT,
217 &got_initial_value, &dummy_stat,
218 GNUNET_CONFIGURATION_dup (cfg));
219
220}
221
222
223int
224main (int argc, char *argv[])
225{
226 ret = 0;
227 if (0 != GNUNET_TESTING_peer_run ("test-ats-api",
228 "test_ats_api_delayed.conf",
229 &run, NULL))
230 return 1;
231 return ret;
232}
233
234/* end of file test_ats_api_delayed_service_scheduling_add_address.c */
diff --git a/src/ats/test_delay b/src/ats/test_delay
new file mode 100755
index 000000000..31c7777c4
--- /dev/null
+++ b/src/ats/test_delay
@@ -0,0 +1,18 @@
1#!/bin/sh
2
3TEMP=$(getopt -o t: -- "$@")
4
5if [ $? != 0 ] ; then
6 exit 1
7fi
8
9eval set -- "$TEMP"
10
11while true ; do
12 case "$1" in
13 (-t) sleep "$2" ; shift 2 ;;
14 (--) shift ; break ;;
15 (*) echo "Error parsing getopt output" ; exit 1 ;;
16 esac
17done
18exec "$@"