aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-10-28 16:23:43 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-10-28 16:23:43 +0000
commit8b0f0bb5946244012e5c98ea00ee723c98812196 (patch)
treed38032df8a4c0fcc4c57598d7b79f79f9ebe82cd /src
parentdf3f64517c0a16f2f1ef5a9d7d20ed9a8caddea1 (diff)
downloadgnunet-8b0f0bb5946244012e5c98ea00ee723c98812196.tar.gz
gnunet-8b0f0bb5946244012e5c98ea00ee723c98812196.zip
removing unused tests and clean up makefile
Diffstat (limited to 'src')
-rw-r--r--src/ats/Makefile.am132
-rw-r--r--src/ats/test_ats_api_performance_feedback.c240
-rw-r--r--src/ats/test_ats_api_scheduling_block_and_reset.c391
-rw-r--r--src/ats/test_ats_api_scheduling_check_min_bw_alt.c423
-rw-r--r--src/ats/test_ats_api_scheduling_destroy_inbound_connection.c223
-rw-r--r--src/ats/test_ats_api_scheduling_min_bw.c185
-rw-r--r--src/ats/test_ats_api_scheduling_update_address.c238
-rw-r--r--src/ats/test_ats_change_preference.c399
-rw-r--r--src/ats/test_ats_mlp.c330
-rw-r--r--src/ats/test_ats_mlp_update.c312
-rw-r--r--src/ats/test_ats_normalization_update_quality.c241
-rw-r--r--src/ats/test_ats_simplistic.c380
-rw-r--r--src/ats/test_ats_simplistic_change_preference.c418
-rw-r--r--src/ats/test_ats_simplistic_switch_networks.c371
14 files changed, 2 insertions, 4281 deletions
diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am
index 6bf13b0e2..47cc31338 100644
--- a/src/ats/Makefile.am
+++ b/src/ats/Makefile.am
@@ -20,9 +20,6 @@ endif
20if HAVE_LIBGLPK 20if HAVE_LIBGLPK
21 GN_LIBGLPK = -lglpk 21 GN_LIBGLPK = -lglpk
22 GN_MLP_LIB = libgnunet_plugin_ats_mlp.la 22 GN_MLP_LIB = libgnunet_plugin_ats_mlp.la
23 GN_MLP_TEST = test_ats_mlp
24 GN_MLP_TEST_UPDATE = test_ats_mlp_update
25 GN_MLP_TEST_AVG = test_ats_mlp_averaging
26 GN_MLP_PERF = perf_ats_mlp 23 GN_MLP_PERF = perf_ats_mlp
27 GN_MLP_ADD_ADDRESS = test_ats_solver_add_address_mlp 24 GN_MLP_ADD_ADDRESS = test_ats_solver_add_address_mlp
28 GN_MLP_ADD_REQUEST_ADDRESS = test_ats_solver_add_address_and_request_mlp 25 GN_MLP_ADD_REQUEST_ADDRESS = test_ats_solver_add_address_and_request_mlp
@@ -125,7 +122,7 @@ TESTING_TESTS = \
125 test_ats_solver_request_and_add_address_proportional \ 122 test_ats_solver_request_and_add_address_proportional \
126 test_ats_solver_request_and_delete_address_proportional \ 123 test_ats_solver_request_and_delete_address_proportional \
127 test_ats_solver_alternative_after_delete_address_proportional \ 124 test_ats_solver_alternative_after_delete_address_proportional \
128 $(GN_MLP_ADD_REQUEST_ADDRESS) \ 125 $(GN_MLP_ADD_ADDRESS) \
129 $(GN_MLP_ADD_REQUEST_ADDRESS) \ 126 $(GN_MLP_ADD_REQUEST_ADDRESS) \
130 $(GN_MLP_REQUEST_ADD_ADDRESS) \ 127 $(GN_MLP_REQUEST_ADD_ADDRESS) \
131 $(GN_MLP_REQUEST_DELETE_ADDRESS) \ 128 $(GN_MLP_REQUEST_DELETE_ADDRESS) \
@@ -135,25 +132,10 @@ TESTING_TESTS = \
135 test_ats_solver_request_and_add_address_ril \ 132 test_ats_solver_request_and_add_address_ril \
136 test_ats_solver_request_and_delete_address_ril \ 133 test_ats_solver_request_and_delete_address_ril \
137 test_ats_solver_alternative_after_delete_address_ril 134 test_ats_solver_alternative_after_delete_address_ril
138
139# test_ats_api_scheduling_min_bw
140# test_ats_api_scheduling_check_min_bw_alt
141# test_ats_api_scheduling_update_address
142# test_ats_api_scheduling_destroy_inbound_connection
143# test_ats_api_scheduling_block_and_reset
144# test_ats_normalization_update_quality
145# test_ats_change_preference
146# test_ats_simplistic
147# test_ats_simplistic_switch_networks
148# test_ats_simplistic_change_preference
149# test_ats_api_performance_address_info
150# test_ats_api_performance_feedback
151endif 135endif
152 136
153check_PROGRAMS = \ 137check_PROGRAMS = \
154 $(TESTING_TESTS) 138 $(TESTING_TESTS)
155# $(GN_MLP_TEST) $(GN_MLP_PERF) $(GN_MLP_TEST_UPDATE)
156# $(GN_MLP_TEST_AVG)
157 139
158if ENABLE_TEST_RUN 140if ENABLE_TEST_RUN
159TESTS = $(check_PROGRAMS) 141TESTS = $(check_PROGRAMS)
@@ -442,108 +424,6 @@ test_ats_solver_alternative_after_delete_address_ril_LDADD = \
442 $(top_builddir)/src/ats/libgnunetats.la \ 424 $(top_builddir)/src/ats/libgnunetats.la \
443 $(top_builddir)/src/statistics/libgnunetstatistics.la 425 $(top_builddir)/src/statistics/libgnunetstatistics.la
444 426
445
446#test_ats_api_scheduling_min_bw_SOURCES = \
447# test_ats_api_scheduling_min_bw.c test_ats_api_common.c
448#test_ats_api_scheduling_min_bw_LDADD = \
449# $(top_builddir)/src/util/libgnunetutil.la \
450# $(top_builddir)/src/testing/libgnunettesting.la \
451# $(top_builddir)/src/ats/libgnunetats.la
452#
453#test_ats_api_scheduling_check_min_bw_alt_SOURCES = \
454# test_ats_api_scheduling_check_min_bw_alt.c test_ats_api_common.c
455#test_ats_api_scheduling_check_min_bw_alt_LDADD = \
456# $(top_builddir)/src/util/libgnunetutil.la \
457# $(top_builddir)/src/testing/libgnunettesting.la \
458# $(top_builddir)/src/ats/libgnunetats.la
459
460
461#test_ats_api_scheduling_update_address_SOURCES = \
462# test_ats_api_scheduling_update_address.c test_ats_api_common.c
463#test_ats_api_scheduling_update_address_LDADD = \
464# $(top_builddir)/src/util/libgnunetutil.la \
465# $(top_builddir)/src/testing/libgnunettesting.la \
466# $(top_builddir)/src/ats/libgnunetats.la
467
468#test_ats_api_scheduling_destroy_inbound_connection_SOURCES = \
469# test_ats_api_scheduling_destroy_inbound_connection.c test_ats_api_common.c
470#test_ats_api_scheduling_destroy_inbound_connection_LDADD = \
471# $(top_builddir)/src/util/libgnunetutil.la \
472# $(top_builddir)/src/testing/libgnunettesting.la \
473# $(top_builddir)/src/ats/libgnunetats.la
474
475#test_ats_api_scheduling_block_and_reset_SOURCES = \
476# test_ats_api_scheduling_block_and_reset.c test_ats_api_common.c
477#test_ats_api_scheduling_block_and_reset_LDADD = \
478# $(top_builddir)/src/util/libgnunetutil.la \
479# $(top_builddir)/src/testing/libgnunettesting.la \
480# $(top_builddir)/src/ats/libgnunetats.la
481
482#test_ats_api_performance_feedback_SOURCES = \
483# test_ats_api_performance_feedback.c
484#test_ats_api_performance_feedback_LDADD = \
485# $(top_builddir)/src/util/libgnunetutil.la \
486# $(top_builddir)/src/testing/libgnunettesting.la \
487# $(top_builddir)/src/hello/libgnunethello.la \
488# $(top_builddir)/src/ats/libgnunetats.la
489
490
491
492#test_ats_api_performance_address_info_SOURCES = \
493# test_ats_api_performance_address_info.c
494#test_ats_api_performance_address_info_LDADD = \
495# $(top_builddir)/src/util/libgnunetutil.la \
496# $(top_builddir)/src/testing/libgnunettesting.la \
497# $(top_builddir)/src/hello/libgnunethello.la \
498# $(top_builddir)/src/ats/libgnunetats.la
499
500
501#test_ats_simplistic_SOURCES = \
502# test_ats_simplistic.c test_ats_api_common.c
503#test_ats_simplistic_LDADD = \
504# $(top_builddir)/src/util/libgnunetutil.la \
505# $(top_builddir)/src/testing/libgnunettesting.la \
506# $(top_builddir)/src/hello/libgnunethello.la \
507# $(top_builddir)/src/ats/libgnunetats.la
508
509#test_ats_simplistic_switch_networks_SOURCES = \
510# test_ats_simplistic_switch_networks.c test_ats_api_common.c
511#test_ats_simplistic_switch_networks_LDADD = \
512# $(top_builddir)/src/util/libgnunetutil.la \
513# $(top_builddir)/src/testing/libgnunettesting.la \
514# $(top_builddir)/src/ats/libgnunetats.la
515
516#test_ats_simplistic_change_preference_SOURCES = \
517# test_ats_simplistic_change_preference.c test_ats_api_common.c
518#test_ats_simplistic_change_preference_LDADD = \
519# $(top_builddir)/src/util/libgnunetutil.la \
520# $(top_builddir)/src/testing/libgnunettesting.la \
521# $(top_builddir)/src/ats/libgnunetats.la
522
523#test_ats_change_preference_SOURCES = \
524# test_ats_change_preference.c test_ats_api_common.c
525#test_ats_change_preference_LDADD = \
526# $(top_builddir)/src/util/libgnunetutil.la \
527# $(top_builddir)/src/testing/libgnunettesting.la \
528# $(top_builddir)/src/ats/libgnunetats.la
529
530
531#test_ats_mlp_SOURCES = \
532# $(GN_MLP_SRC) test_ats_mlp.c test_ats_api_common.c gnunet-service-ats_normalization.c
533#test_ats_mlp_LDADD = \
534# $(GN_LIBGLPK) \
535# $(top_builddir)/src/util/libgnunetutil.la \
536# $(top_builddir)/src/statistics/libgnunetstatistics.la \
537# $(top_builddir)/src/ats/libgnunetats.la
538
539#test_ats_mlp_update_SOURCES = \
540# $(GN_MLP_SRC) test_ats_mlp_update.c test_ats_api_common.c gnunet-service-ats_normalization.c
541#test_ats_mlp_update_LDADD = \
542# $(GN_LIBGLPK) \
543# $(top_builddir)/src/util/libgnunetutil.la \
544# $(top_builddir)/src/statistics/libgnunetstatistics.la \
545# $(top_builddir)/src/ats/libgnunetats.la
546
547#perf_ats_mlp_SOURCES = \ 427#perf_ats_mlp_SOURCES = \
548# $(GN_MLP_SRC) perf_ats_mlp.c test_ats_api_common.c gnunet-service-ats_normalization.c 428# $(GN_MLP_SRC) perf_ats_mlp.c test_ats_api_common.c gnunet-service-ats_normalization.c
549#perf_ats_mlp_LDADD = \ 429#perf_ats_mlp_LDADD = \
@@ -552,15 +432,7 @@ test_ats_solver_alternative_after_delete_address_ril_LDADD = \
552# $(top_builddir)/src/statistics/libgnunetstatistics.la \ 432# $(top_builddir)/src/statistics/libgnunetstatistics.la \
553# $(top_builddir)/src/ats/libgnunetats.la 433# $(top_builddir)/src/ats/libgnunetats.la
554 434
555#test_ats_normalization_update_quality_SOURCES = \ 435
556# test_ats_normalization_update_quality.c test_ats_api_common.c
557#test_ats_normalization_update_quality_LDADD = \
558# $(GN_LIBGLPK) \
559# $(top_builddir)/src/util/libgnunetutil.la \
560# $(top_builddir)/src/statistics/libgnunetstatistics.la \
561# $(top_builddir)/src/testing/libgnunettesting.la \
562# $(top_builddir)/src/ats/libgnunetats.la
563#endif
564EXTRA_DIST = \ 436EXTRA_DIST = \
565 ats.h \ 437 ats.h \
566 test_ats_api.conf \ 438 test_ats_api.conf \
diff --git a/src/ats/test_ats_api_performance_feedback.c b/src/ats/test_ats_api_performance_feedback.c
deleted file mode 100644
index f946e674a..000000000
--- a/src/ats/test_ats_api_performance_feedback.c
+++ /dev/null
@@ -1,240 +0,0 @@
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_performance_feedback
22 * @brief Test performance API:
23 * Test for address feedback API
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
32#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
33#define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
34
35#define ATS_COUNT 2
36
37static GNUNET_SCHEDULER_TaskIdentifier die_task;
38static GNUNET_SCHEDULER_TaskIdentifier stage_task;
39
40struct GNUNET_CONFIGURATION_Handle *cfg;
41
42static struct GNUNET_ATS_SchedulingHandle *sh;
43
44static struct GNUNET_ATS_PerformanceHandle *ph;
45
46static struct GNUNET_HELLO_Address addr[2];
47
48static struct GNUNET_ATS_Information atsi[ATS_COUNT];
49
50static int ret;
51
52static int res_suggest_cb_p0;
53static int res_suggest_cb_p1;
54
55static int res_addrinfo_cb_p0;
56static int res_addrinfo_cb_p1;
57
58/**
59 * Stage 0: Init, request address and wait for peer0 suggest cb
60 * Stage 1: Got peer0 suggest cb, expect monitoring cb
61 * Stage 2: Got peer0 monitoring cb, update address and expect monitor cb
62 * Stage 3: Got 2nd peer0 monitoring cb, shutdown
63 */
64
65static int stage;
66
67
68static void cleanup_addresses ()
69{
70 GNUNET_ATS_address_destroyed (sh, &addr[0], NULL);
71 GNUNET_ATS_address_destroyed (sh, &addr[1], NULL);
72}
73
74static void
75end_now (int res)
76{
77 if (GNUNET_SCHEDULER_NO_TASK != stage_task)
78 {
79 GNUNET_SCHEDULER_cancel (stage_task);
80 stage_task = GNUNET_SCHEDULER_NO_TASK;
81 }
82 if (GNUNET_SCHEDULER_NO_TASK != die_task)
83 {
84 GNUNET_SCHEDULER_cancel (die_task);
85 die_task = GNUNET_SCHEDULER_NO_TASK;
86 }
87 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown\n");
88
89 cleanup_addresses ();
90
91 if (NULL != ph)
92 {
93 GNUNET_ATS_performance_done (ph);
94 ph = NULL;
95 }
96
97 if (NULL != sh)
98 {
99 GNUNET_ATS_scheduling_done (sh);
100 sh = NULL;
101 }
102 ret = res;
103}
104
105#if 0
106static void
107end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
108{
109 die_task = GNUNET_SCHEDULER_NO_TASK;
110 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Error!\n");
111 if (GNUNET_NO == res_addrinfo_cb_p0)
112 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get address information for requested peer0!\n");
113 if (GNUNET_NO == res_addrinfo_cb_p1)
114 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get address information for requested peer1!\n");
115 if (GNUNET_NO == res_suggest_cb_p0)
116 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not get suggestion for not peer!\n");
117 if (GNUNET_YES == res_suggest_cb_p1)
118 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Got suggestion for not requested peer!\n");
119 end_now (1);
120}
121#endif
122
123static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
124{
125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Success\n");
126 end_now (0);
127}
128
129static void
130addrinfo_cb (void *cls,
131 const struct GNUNET_HELLO_Address *address,
132 int address_active,
133 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
134 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
135 const struct GNUNET_ATS_Information *ats,
136 uint32_t ats_count)
137{
138 //static int shutdown = GNUNET_NO;
139 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
140 "ATS has information about address for peer `%s'\n", GNUNET_i2s (&address->peer));
141
142 if (0 == memcmp (&addr[0].peer, &address->peer, sizeof (address->peer)))
143 res_addrinfo_cb_p0 = GNUNET_YES;
144 if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
145 res_addrinfo_cb_p1 = GNUNET_YES;
146}
147
148void ats_suggest_cb (void *cls,
149 const struct GNUNET_HELLO_Address * address,
150 struct Session * session,
151 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
152 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
153 const struct GNUNET_ATS_Information *ats,
154 uint32_t ats_count)
155{
156 static int feedbacks = 0;
157
158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
159 "ATS is suggesting address for peer `%s'\n", GNUNET_i2s (&address->peer));
160
161 if (feedbacks >= 2)
162 return;
163 feedbacks++;
164
165 if (0 == memcmp (&addr[0].peer, &address->peer, sizeof (address->peer)))
166 {
167 res_suggest_cb_p0 = GNUNET_YES;
168 stage = 1;
169 GNUNET_ATS_address_update (sh, &addr[1], NULL, atsi, ATS_COUNT);
170 GNUNET_ATS_performance_give_feedback (ph, &addr[0].peer,
171 GNUNET_TIME_UNIT_SECONDS, GNUNET_ATS_PREFERENCE_BANDWIDTH,
172 (double) 1000, GNUNET_ATS_PREFERENCE_END);
173 }
174 if (0 == memcmp (&addr[1].peer, &address->peer, sizeof (address->peer)))
175 {
176 GNUNET_ATS_performance_give_feedback (ph, &addr[1].peer,
177 GNUNET_TIME_UNIT_SECONDS, GNUNET_ATS_PREFERENCE_BANDWIDTH,
178 GNUNET_ATS_PREFERENCE_END);
179 res_suggest_cb_p1 = GNUNET_YES;
180 }
181}
182
183
184static void next (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
185{
186 memset (&addr[0].peer,'\0', sizeof (addr[0].peer));
187 addr[0].transport_name = "test0";
188 addr[0].address = "test_addr0";
189 addr[0].address_length = strlen ("test_addr0") + 1;
190
191 atsi[0].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
192 atsi[0].value = htonl(100);
193
194 atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
195 atsi[1].value = htonl(5);
196
197 GNUNET_ATS_address_add (sh, &addr[0], NULL, atsi, ATS_COUNT);
198 GNUNET_ATS_suggest_address (sh, &addr[0].peer);
199
200 memset (&addr[1].peer,'\1', sizeof (addr[1].peer));
201 addr[1].transport_name = "test1";
202 addr[1].address = "test_addr1";
203 addr[1].address_length = strlen ("test_addr1") + 1;
204
205 GNUNET_ATS_address_add (sh, &addr[1], NULL, atsi, ATS_COUNT);
206 GNUNET_ATS_suggest_address (sh, &addr[1].peer);
207 GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &end, NULL);
208}
209
210static void
211run (void *cls,
212 const struct GNUNET_CONFIGURATION_Handle *mycfg,
213 struct GNUNET_TESTING_Peer *peer)
214{
215 ret = 1;
216 stage = 0;
217 cfg = (struct GNUNET_CONFIGURATION_Handle *) mycfg;
218// die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
219
220 ph = GNUNET_ATS_performance_init (cfg, &addrinfo_cb, NULL);
221 GNUNET_assert (NULL != ph);
222
223 sh = GNUNET_ATS_scheduling_init (cfg, &ats_suggest_cb, NULL);
224 GNUNET_assert (NULL != sh);
225
226 GNUNET_SCHEDULER_add_delayed (SHUTDOWN_CORRECT, &next, NULL);
227}
228
229
230int
231main (int argc, char *argv[])
232{
233 if (0 != GNUNET_TESTING_peer_run ("test_ats_api_performance_monitor",
234 "test_ats_api.conf",
235 &run, NULL))
236 return 1;
237 return ret;
238}
239
240/* end of file test_ats_api_performance_feedback.c */
diff --git a/src/ats/test_ats_api_scheduling_block_and_reset.c b/src/ats/test_ats_api_scheduling_block_and_reset.c
deleted file mode 100644
index c4dd8b4bb..000000000
--- a/src/ats/test_ats_api_scheduling_block_and_reset.c
+++ /dev/null
@@ -1,391 +0,0 @@
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_scheduling_reset_backoff.c
22 * @brief test case for blocking suggests and blocking reset API
23 * measure duration of initial suggest, measure blocking duration,
24 * reset block, measure suggest, compare time
25 * @author Christian Grothoff
26 * @author Matthias Wachs
27 */
28#include "platform.h"
29#include "gnunet_ats_service.h"
30#include "gnunet_testing_lib.h"
31#include "ats.h"
32#include "test_ats_api_common.h"
33
34#define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 10)
35
36static GNUNET_SCHEDULER_TaskIdentifier die_task;
37
38static GNUNET_SCHEDULER_TaskIdentifier wait_task;
39
40/**
41 * Scheduling handle
42 */
43static struct GNUNET_ATS_SchedulingHandle *sched_ats;
44
45/**
46 * Return value
47 */
48static int ret;
49
50/**
51 * Test address
52 */
53static struct Test_Address test_addr;
54
55/**
56 * Test peer
57 */
58static struct PeerContext p;
59
60/**
61 * HELLO address
62 */
63struct GNUNET_HELLO_Address test_hello_address;
64
65/**
66 * Session
67 */
68static void *test_session;
69
70/**
71 * Test ats info
72 */
73struct GNUNET_ATS_Information test_ats_info[2];
74
75/**
76 * Test ats count
77 */
78uint32_t test_ats_count;
79
80
81struct GNUNET_TIME_Absolute initial_start;
82
83struct GNUNET_TIME_Relative initial_duration;
84
85/**
86 * Blocking start
87 */
88struct GNUNET_TIME_Absolute block_start;
89
90struct GNUNET_TIME_Relative block_duration;
91
92struct GNUNET_TIME_Absolute reset_block_start;
93
94struct GNUNET_TIME_Relative reset_block_duration;
95
96static void
97end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
98{
99 die_task = GNUNET_SCHEDULER_NO_TASK;
100 if (wait_task != GNUNET_SCHEDULER_NO_TASK)
101 {
102 GNUNET_SCHEDULER_cancel (wait_task);
103 wait_task = GNUNET_SCHEDULER_NO_TASK;
104 }
105 if (sched_ats != NULL)
106 GNUNET_ATS_scheduling_done (sched_ats);
107 free_test_address (&test_addr);
108 ret = GNUNET_SYSERR;
109}
110
111
112static void
113end ()
114{
115 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
116 if (die_task != GNUNET_SCHEDULER_NO_TASK)
117 {
118 GNUNET_SCHEDULER_cancel (die_task);
119 die_task = GNUNET_SCHEDULER_NO_TASK;
120 }
121 if (wait_task != GNUNET_SCHEDULER_NO_TASK)
122 {
123 GNUNET_SCHEDULER_cancel (wait_task);
124 wait_task = GNUNET_SCHEDULER_NO_TASK;
125 }
126 GNUNET_ATS_scheduling_done (sched_ats);
127 sched_ats = NULL;
128 free_test_address (&test_addr);
129}
130
131static void
132request_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
133{
134 wait_task = GNUNET_SCHEDULER_NO_TASK;
135 GNUNET_ATS_suggest_address (sched_ats, &p.id);
136 wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &request_task, NULL);
137}
138
139static void
140address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
141 struct Session *session,
142 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
143 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
144 const struct GNUNET_ATS_Information *atsi,
145 uint32_t ats_count)
146{
147 static int stage = 0;
148
149 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u\n", stage);
150 if (3 == stage)
151 {
152 /* Suggestion after resetting block interval */
153 reset_block_duration = GNUNET_TIME_absolute_get_difference (reset_block_start,
154 GNUNET_TIME_absolute_get());
155 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
156 "Address suggestion after resetting blocking took about %s!\n",
157 GNUNET_STRINGS_relative_time_to_string (reset_block_duration,
158 GNUNET_YES));
159 if ((block_duration.rel_value_us <= (initial_duration.rel_value_us * 3)) ||
160 (initial_duration.rel_value_us <= (block_duration.rel_value_us * 3)))
161 {
162 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
163 "Address suggestion after resetting blocking took about the same as initial suggestion (%s)\n",
164 GNUNET_STRINGS_relative_time_to_string (initial_duration,
165 GNUNET_YES));
166 ret = 0;
167 }
168 else
169 {
170 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
171 "Address suggestion after resetting blocking has too big difference to initial suggestion (%s)\n",
172 GNUNET_STRINGS_relative_time_to_string (initial_duration,
173 GNUNET_YES));
174 ret = 1;
175 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
176 GNUNET_SCHEDULER_add_now (&end, NULL);
177 return;
178 }
179
180 if (((initial_duration.rel_value_us * 3) <= block_duration.rel_value_us) &&
181 ((reset_block_duration.rel_value_us * 3) <= block_duration.rel_value_us))
182 {
183 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
184 "Address suggestion after resetting blocking and initial suggestion (%llu us) much faster than with blocking (%llu us)\n",
185 (unsigned long long) initial_duration.rel_value_us,
186 (unsigned long long) block_duration.rel_value_us);
187 ret = 0;
188 }
189 else
190 {
191 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
192 "Address suggestion after resetting blocking and initial suggestion (%llu us) not faster than with blocking (%llu us)\n",
193 (unsigned long long) initial_duration.rel_value_us,
194 (unsigned long long) block_duration.rel_value_us);
195 ret = 1;
196 }
197
198
199 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
200 GNUNET_SCHEDULER_add_now (&end, NULL);
201
202 }
203 if (2 == stage)
204 {
205 /* Suggestion after block*/
206 block_duration = GNUNET_TIME_absolute_get_difference(block_start, GNUNET_TIME_absolute_get());
207 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
208 "Address suggestion was blocked for about %s!\n",
209 GNUNET_STRINGS_relative_time_to_string (block_duration,
210 GNUNET_YES));
211
212 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
213 {
214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
215 "Stage %u: Callback with correct address `%s'\n", stage,
216 GNUNET_i2s (&address->peer));
217 ret = 0;
218 }
219 else
220 {
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
222 "Stage %u: Callback with invalid address `%s'\n", stage,
223 GNUNET_i2s (&address->peer));
224 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
225 GNUNET_SCHEDULER_add_now (&end, NULL);
226 ret = 1;
227 }
228
229 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
230 {
231 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
232 "Stage %u: Callback with incorrect ats info \n");
233 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
234 GNUNET_SCHEDULER_add_now (&end, NULL);
235 ret = 1;
236 }
237 stage ++;
238
239 /* Reset block interval */
240 GNUNET_ATS_reset_backoff (sched_ats, &address->peer);
241 reset_block_start = GNUNET_TIME_absolute_get();
242 GNUNET_ATS_suggest_address (sched_ats, &p.id);
243 }
244 if (1 == stage)
245 {
246 /* Initial suggestion */
247 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
248 {
249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
250 "Stage %u: Callback with correct address `%s'\n",
251 stage,
252 GNUNET_i2s (&address->peer));
253 ret = 0;
254 }
255 else
256 {
257 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
258 "Stage %u: Callback with invalid address `%s'\n",
259 stage,
260 GNUNET_i2s (&address->peer));
261 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
262 GNUNET_SCHEDULER_add_now (&end, NULL);
263 ret = 1;
264 }
265
266 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
267 {
268 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
269 "Stage %u: Callback with incorrect ats info\n",
270 stage);
271 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
272 GNUNET_SCHEDULER_add_now (&end, NULL);
273 ret = 1;
274 }
275 stage++;
276 initial_duration = GNUNET_TIME_absolute_get_difference(initial_start, GNUNET_TIME_absolute_get());
277 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
278 "Stage %u: Initial suggestion took about %s\n",
279 stage,
280 GNUNET_STRINGS_relative_time_to_string (block_duration,
281 GNUNET_YES));
282
283 block_start = GNUNET_TIME_absolute_get();
284 wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &request_task, NULL);
285 }
286 if (0 == stage)
287 {
288 /* Startup suggestion */
289 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
290 {
291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
292 "Stage %u: Callback with correct address `%s'\n",
293 stage,
294 GNUNET_i2s (&address->peer));
295 ret = 0;
296 }
297 else
298 {
299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
300 "Stage %u: Callback with invalid address `%s'\n",
301 stage,
302 GNUNET_i2s (&address->peer));
303 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
304 GNUNET_SCHEDULER_add_now (&end, NULL);
305 ret = 1;
306 }
307
308 if (GNUNET_OK != compare_ats (atsi, ats_count, test_ats_info, test_ats_count))
309 {
310 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
311 "Stage %u: Callback with incorrect ats info\n",
312 stage);
313 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
314 GNUNET_SCHEDULER_add_now (&end, NULL);
315 ret = 1;
316 }
317 stage ++;
318
319 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
320
321 initial_start = GNUNET_TIME_absolute_get();
322 GNUNET_ATS_suggest_address (sched_ats, &p.id);
323 }
324}
325
326
327static void
328run (void *cls,
329 const struct GNUNET_CONFIGURATION_Handle *cfg,
330 struct GNUNET_TESTING_Peer *peer)
331{
332
333 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
334
335 /* Connect to ATS scheduling */
336 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
337 if (sched_ats == NULL)
338 {
339 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
340 "Could not connect to ATS scheduling!\n");
341 ret = 1;
342 end ();
343 return;
344 }
345
346 /* Set up peer */
347 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey))
348 {
349 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
350 "Could not setup peer!\n");
351 ret = GNUNET_SYSERR;
352 end ();
353 return;
354 }
355 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id)));
356
357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
358 "Created peer `%s'\n",
359 GNUNET_i2s_full(&p.id));
360
361 /* Prepare ATS Information */
362 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
363 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
364 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
365 test_ats_info[1].value = htonl(1);
366 test_ats_count = 2;
367
368 /* Adding address without session */
369 test_session = &test_addr;
370 create_test_address (&test_addr, "test", test_session, "test", strlen ("test") + 1);
371 test_hello_address.peer = p.id;
372 test_hello_address.transport_name = test_addr.plugin;
373 test_hello_address.address = test_addr.addr;
374 test_hello_address.address_length = test_addr.addr_len;
375 GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
376
377 initial_start = GNUNET_TIME_absolute_get();
378 GNUNET_ATS_suggest_address (sched_ats, &p.id);
379}
380
381
382int
383main (int argc, char *argv[])
384{
385 if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_add_address",
386 "test_ats_api.conf",
387 &run, NULL))
388 return 1;
389 return ret;
390}
391/* end of file test_ats_api_scheduling_reset_backoff.c */
diff --git a/src/ats/test_ats_api_scheduling_check_min_bw_alt.c b/src/ats/test_ats_api_scheduling_check_min_bw_alt.c
deleted file mode 100644
index c42feaa2f..000000000
--- a/src/ats/test_ats_api_scheduling_check_min_bw_alt.c
+++ /dev/null
@@ -1,423 +0,0 @@
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_mlp.c
22 * @brief test for the MLP solver
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25
26 */
27/**
28 * @file ats/test_ats_api_scheduling_check_min_bw_alt.c
29 * @brief alternative suggestion on network change if no bw is available
30 * @author Christian Grothoff
31 * @author Matthias Wachs
32 */
33#include "platform.h"
34#include "gnunet_ats_service.h"
35#include "gnunet_testing_lib.h"
36#include "ats.h"
37#include "test_ats_api_common.h"
38
39#define DEBUG_ATS_INFO GNUNET_NO
40
41static GNUNET_SCHEDULER_TaskIdentifier die_task;
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[2];
57
58/**
59 * Test peer
60 */
61static struct PeerContext p[2];
62
63
64/**
65 * HELLO address
66 */
67struct GNUNET_HELLO_Address test_hello_address[2];
68
69/**
70 * Session
71 */
72static void *test_session[2];
73
74/**
75 * Test ats info
76 */
77struct GNUNET_ATS_Information test_ats_info[2][2];
78
79/**
80 * Test ats count
81 */
82uint32_t test_ats_count;
83
84/**
85 * Configured WAN out quota
86 */
87unsigned long long wan_quota_out;
88
89/**
90 * Configured WAN in quota
91 */
92unsigned long long wan_quota_in;
93
94
95static void
96end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
97{
98 die_task = GNUNET_SCHEDULER_NO_TASK;
99
100 if (NULL != sched_ats)
101 {
102 GNUNET_ATS_scheduling_done (sched_ats);
103 sched_ats = NULL;
104 }
105 free_test_address (&test_addr[0]);
106 free_test_address (&test_addr[1]);
107 ret = GNUNET_SYSERR;
108}
109
110
111static void
112end ()
113{
114 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
115 if (die_task != GNUNET_SCHEDULER_NO_TASK)
116 {
117 GNUNET_SCHEDULER_cancel (die_task);
118 die_task = GNUNET_SCHEDULER_NO_TASK;
119 }
120 if (NULL != sched_ats)
121 {
122 GNUNET_ATS_scheduling_done (sched_ats);
123 sched_ats = NULL;
124 }
125 free_test_address (&test_addr[0]);
126 free_test_address (&test_addr[1]);
127}
128
129
130static void
131address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
132 struct Session *session,
133 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
134 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
135 const struct GNUNET_ATS_Information *atsi,
136 uint32_t ats_count)
137{
138 static int stage = 0;
139 unsigned int bw_in = ntohl(bandwidth_in.value__);
140 unsigned int bw_out = ntohl(bandwidth_out.value__);
141
142 if (0 == stage)
143 {
144 /* Initial suggestion for 1st address */
145 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0]))
146 {
147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n",
148 stage, GNUNET_i2s (&address->peer));
149 ret = 0;
150 }
151 else
152 {
153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n",
154 stage, GNUNET_i2s (&address->peer));
155 ret = 1;
156 }
157
158 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info[0], test_ats_count))
159 {
160 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n");
161 ret = 1;
162 }
163
164 if (bw_in > wan_quota_in)
165 {
166 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Suggested WAN inbound quota %u bigger than allowed quota %llu \n",
167 stage, bw_in, wan_quota_in);
168 ret = 1;
169 }
170 else
171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Suggested WAN inbound quota %u, allowed quota %llu \n",
172 stage, bw_in, wan_quota_in);
173
174 if (bw_out > wan_quota_out)
175 {
176 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Suggested WAN outbound quota %u bigger than allowed quota %llu \n",
177 stage, bw_out, wan_quota_out);
178 ret = 1;
179 }
180 else
181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Suggested WAN outbound quota %u, allowed quota %llu \n",
182 stage, bw_out, wan_quota_out);
183
184 if (1 == ret)
185 {
186 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
187 GNUNET_SCHEDULER_add_now (&end, NULL);
188 return;
189 }
190
191 p[0].bw_out_assigned = bw_out;
192 p[0].bw_in_assigned = bw_in;
193 stage ++;
194
195 /* Add a 2nd address to give ATS an suggestion alternative */
196 /* Prepare ATS Information */
197 test_ats_info[1][0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
198 test_ats_info[1][0].value = htonl(GNUNET_ATS_NET_LAN);
199 test_ats_info[1][1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
200 test_ats_info[1][1].value = htonl(1);
201 test_ats_count = 2;
202
203 /* Adding address with session */
204 test_session[1] = &test_addr[1];
205 create_test_address (&test_addr[1], "test1", test_session[1], "test1", strlen ("test1") + 1);
206 test_hello_address[1].peer = p[0].id;
207 test_hello_address[1].transport_name = test_addr[1].plugin;
208 test_hello_address[1].address = test_addr[1].addr;
209 test_hello_address[1].address_length = test_addr[1].addr_len;
210 GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1],
211 test_ats_info[1], test_ats_count);
212
213
214 /* Changing 1st address to network with now bw available (WLAN) */
215 test_ats_info[0][0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
216 test_ats_info[0][0].value = htonl(GNUNET_ATS_NET_WLAN);
217 test_ats_info[0][1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
218 test_ats_info[0][1].value = htonl(1);
219 test_ats_count = 2;
220
221 GNUNET_ATS_address_update (sched_ats, &test_hello_address[0], test_session[0],
222 test_ats_info[0], test_ats_count);
223 return;
224 }
225 if (1 == stage)
226 {
227 /* Bandwidth update to (in/out) 0/0 for 1st address */
228 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0]))
229 {
230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n",
231 stage, GNUNET_i2s (&address->peer));
232 ret = 0;
233 }
234 else
235 {
236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n",
237 stage, GNUNET_i2s (&address->peer));
238 ret = 1;
239 }
240
241 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info[0], test_ats_count))
242 {
243 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n");
244 ret = 1;
245 }
246
247 if ((bw_in != 0) || (bw_out != 0))
248 {
249 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: ATS did not set bandwidth to 0 but instead to %u/%u \n",
250 stage, bw_in, wan_quota_in);
251 ret = 1;
252 }
253
254 if (1 == ret)
255 {
256 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
257 GNUNET_SCHEDULER_add_now (&end, NULL);
258 return;
259 }
260 p[0].bw_out_assigned = bw_out;
261 p[0].bw_in_assigned = bw_in;
262 stage ++;
263 return;
264 }
265 if (2 == stage)
266 {
267 /* Expecting suggestion of alternative 2nd address*/
268 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[1], test_session[1]))
269 {
270 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n",
271 stage, GNUNET_i2s (&address->peer));
272 ret = 0;
273 }
274 else
275 {
276 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n",
277 stage, GNUNET_i2s (&address->peer));
278 ret = 1;
279 }
280
281 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info[1], test_ats_count))
282 {
283 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n",
284 stage);
285 ret = 1;
286 }
287
288 if ((bw_in == 0) || (bw_out == 0))
289 {
290 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: ATS did not set bandwidth correctly \n",
291 stage);
292 ret = 1;
293 }
294
295 if (1 == ret)
296 {
297 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
298 GNUNET_SCHEDULER_add_now (&end, NULL);
299 return;
300 }
301
302 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
303 GNUNET_SCHEDULER_add_now (&end, NULL);
304 ret = 0;
305 return;
306 }
307}
308
309static void
310run (void *cls,
311 const struct GNUNET_CONFIGURATION_Handle *cfg,
312 struct GNUNET_TESTING_Peer *peer)
313{
314 char *quota_str;
315
316 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", &quota_str))
317 {
318 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
319 ret = 1;
320 return;
321 }
322 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_out))
323 {
324 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
325 ret = 1;
326 GNUNET_free (quota_str);
327 return;
328 }
329 GNUNET_free (quota_str);
330 quota_str = NULL;
331
332 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", &quota_str))
333 {
334 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
335 ret = 1;
336 return;
337 }
338 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_in))
339 {
340 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
341 GNUNET_free (quota_str);
342 ret = 1;
343 return;
344 }
345 GNUNET_free (quota_str);
346 quota_str = NULL;
347 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n", wan_quota_in);
348 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota: %llu\n", wan_quota_out);
349
350
351 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
352
353 /* Connect to ATS scheduling */
354 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
355 if (sched_ats == NULL)
356 {
357 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
358 ret = 1;
359 end ();
360 return;
361 }
362
363 /* Set up peer 0 */
364 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey))
365 {
366 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
367 ret = GNUNET_SYSERR;
368 end ();
369 return;
370 }
371
372 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
373
374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
375 GNUNET_i2s(&p[0].id));
376
377 /* Set up peer 1*/
378 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].id.hashPubKey))
379 {
380 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
381 ret = GNUNET_SYSERR;
382 end ();
383 return;
384 }
385
386 GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
387
388 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
389 GNUNET_i2s(&p[1].id));
390
391 /* Prepare ATS Information */
392 test_ats_info[0][0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
393 test_ats_info[0][0].value = htonl(GNUNET_ATS_NET_WAN);
394 test_ats_info[0][1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
395 test_ats_info[0][1].value = htonl(1);
396 test_ats_count = 2;
397
398 /* Adding address with session */
399 test_session[0] = &test_addr[0];
400 create_test_address (&test_addr[0], "test0", test_session[0], "test0", strlen ("test0") + 1);
401 test_hello_address[0].peer = p[0].id;
402 test_hello_address[0].transport_name = test_addr[0].plugin;
403 test_hello_address[0].address = test_addr[0].addr;
404 test_hello_address[0].address_length = test_addr[0].addr_len;
405 GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0],
406 test_ats_info[0], test_ats_count);
407
408 GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
409}
410
411
412int
413main (int argc, char *argv[])
414{
415 if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_check_min_bw_alt",
416 "test_ats_api.conf",
417 &run, NULL))
418 return 1;
419 return ret;
420}
421
422
423/* end of file test_ats_api_scheduling_check_min_bw_alt.c */
diff --git a/src/ats/test_ats_api_scheduling_destroy_inbound_connection.c b/src/ats/test_ats_api_scheduling_destroy_inbound_connection.c
deleted file mode 100644
index 90a8d070f..000000000
--- a/src/ats/test_ats_api_scheduling_destroy_inbound_connection.c
+++ /dev/null
@@ -1,223 +0,0 @@
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_scheduling_destroy_inbound_connection.c
22 * @brief test destroying sessions for inbound connections: first add an address with a session,
23 * request the address and compare, delete the session, request and
24 * compare again, delete whole address, request and wait for timeout,
25 * shutdown
26 * @author Christian Grothoff
27 * @author Matthias Wachs
28 *
29 */
30#include "platform.h"
31#include "gnunet_ats_service.h"
32#include "gnunet_testing_lib.h"
33#include "ats.h"
34#include "test_ats_api_common.h"
35
36static GNUNET_SCHEDULER_TaskIdentifier die_task;
37
38static GNUNET_SCHEDULER_TaskIdentifier wait_task;
39
40#define SUGGESTION_WAIT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
41
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
85end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
86{
87 die_task = GNUNET_SCHEDULER_NO_TASK;
88 if (wait_task != GNUNET_SCHEDULER_NO_TASK)
89 {
90 GNUNET_SCHEDULER_cancel (wait_task);
91 wait_task = GNUNET_SCHEDULER_NO_TASK;
92 }
93 if (sched_ats != NULL)
94 GNUNET_ATS_scheduling_done (sched_ats);
95 free_test_address (&test_addr);
96 ret = GNUNET_SYSERR;
97}
98
99
100static void
101end ()
102{
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
104 wait_task = GNUNET_SCHEDULER_NO_TASK;
105 if (die_task != GNUNET_SCHEDULER_NO_TASK)
106 {
107 GNUNET_SCHEDULER_cancel (die_task);
108 die_task = GNUNET_SCHEDULER_NO_TASK;
109 }
110 free_test_address (&test_addr);
111 GNUNET_ATS_scheduling_done (sched_ats);
112 sched_ats = NULL;
113}
114
115
116static void
117address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
118 struct Session *session,
119 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
120 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
121 const struct GNUNET_ATS_Information *atsi,
122 uint32_t ats_count)
123{
124 static int stage = 0;
125
126 if (0 == stage)
127 {
128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Received suggestion for peer `%s'\n",
129 GNUNET_i2s(&address->peer));
130
131 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
132 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session))
133 {
134 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n",
135 GNUNET_i2s (&address->peer));
136 }
137 else
138 {
139 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n",
140 GNUNET_i2s (&address->peer));
141 GNUNET_SCHEDULER_add_now (&end, NULL);
142 ret = 1;
143 return;
144 }
145 stage ++;
146 ret = 0;
147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying address for `%s'\n",
148 GNUNET_i2s (&address->peer));
149 /* Destroying session for address */
150 test_session = NULL;
151 GNUNET_ATS_address_destroyed (sched_ats, &test_hello_address, test_addr.session);
152 /* Request address */
153 GNUNET_ATS_suggest_address (sched_ats, &p.id);
154
155 /* Wait for timeout */
156 wait_task = GNUNET_SCHEDULER_add_delayed (SUGGESTION_WAIT_TIMEOUT, &end, NULL);
157 return;
158 }
159 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Unexpected address suggestion\n", stage);
160 ret = 1;
161}
162
163
164static void
165run (void *cls,
166 const struct GNUNET_CONFIGURATION_Handle *cfg,
167 struct GNUNET_TESTING_Peer *peer)
168{
169 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
170
171 /* Connect to ATS scheduling */
172 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
173 if (sched_ats == NULL)
174 {
175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
176 ret = 1;
177 end ();
178 return;
179 }
180
181 /* Set up peer */
182 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey))
183 {
184 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
185 ret = GNUNET_SYSERR;
186 end ();
187 return;
188 }
189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
190 GNUNET_i2s_full(&p.id));
191
192 /* Prepare ATS Information */
193 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
194 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
195 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
196 test_ats_info[1].value = htonl(1);
197 test_ats_count = 2;
198
199 /* Adding address with session */
200 create_test_address (&test_addr, "test", &test_addr, NULL, 0);
201 test_session = &test_addr;
202 test_hello_address.peer = p.id;
203 test_hello_address.transport_name = test_addr.plugin;
204 test_hello_address.address = test_addr.addr;
205 test_hello_address.address_length = test_addr.addr_len;
206 GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_addr.session, test_ats_info, test_ats_count);
207
208 /* Request address */
209 GNUNET_ATS_suggest_address (sched_ats, &p.id);
210}
211
212
213int
214main (int argc, char *argv[])
215{
216 if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_add_address",
217 "test_ats_api.conf",
218 &run, NULL))
219 return 1;
220 return ret;
221}
222
223/* end of file test_ats_api_scheduling_destroy_inbound_connection.c */
diff --git a/src/ats/test_ats_api_scheduling_min_bw.c b/src/ats/test_ats_api_scheduling_min_bw.c
deleted file mode 100644
index 4da07628c..000000000
--- a/src/ats/test_ats_api_scheduling_min_bw.c
+++ /dev/null
@@ -1,185 +0,0 @@
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_scheduling_min_bw.c
22 * @brief add in address for a network where quota is below min bw: no suggest expected
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#include "test_ats_api_common.h"
31
32#define WAIT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
33
34static GNUNET_SCHEDULER_TaskIdentifier die_task;
35static GNUNET_SCHEDULER_TaskIdentifier wait_task;
36
37/**
38 * Scheduling handle
39 */
40static struct GNUNET_ATS_SchedulingHandle *sched_ats;
41
42/**
43 * Return value
44 */
45static int ret;
46
47/**
48 * Test address
49 */
50static struct Test_Address test_addr;
51
52/**
53 * Test peer
54 */
55static struct PeerContext p;
56
57/**
58 * HELLO address
59 */
60struct GNUNET_HELLO_Address test_hello_address;
61
62/**
63 * Session
64 */
65static void *test_session;
66
67/**
68 * Test ats info
69 */
70struct GNUNET_ATS_Information test_ats_info[2];
71
72/**
73 * Test ats count
74 */
75uint32_t test_ats_count;
76
77
78static void
79end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
80{
81 die_task = GNUNET_SCHEDULER_NO_TASK;
82
83 if (sched_ats != NULL)
84 GNUNET_ATS_scheduling_done (sched_ats);
85 free_test_address (&test_addr);
86 ret = GNUNET_SYSERR;
87}
88
89
90static void
91end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
92{
93 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
94 if (die_task != GNUNET_SCHEDULER_NO_TASK)
95 {
96 GNUNET_SCHEDULER_cancel (die_task);
97 die_task = GNUNET_SCHEDULER_NO_TASK;
98 }
99 if (NULL != sched_ats)
100 GNUNET_ATS_scheduling_done (sched_ats);
101 sched_ats = NULL;
102 free_test_address (&test_addr);
103}
104
105static void
106address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
107 struct Session *session,
108 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
109 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
110 const struct GNUNET_ATS_Information *atsi,
111 uint32_t ats_count)
112{
113 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Did not expect suggestion!\n");
114 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
115 GNUNET_SCHEDULER_add_now (&end, NULL);
116 ret = 1;
117}
118
119static void
120run (void *cls,
121 const struct GNUNET_CONFIGURATION_Handle *cfg,
122 struct GNUNET_TESTING_Peer *peer)
123{
124
125 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
126
127 /* Connect to ATS scheduling */
128 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
129 if (sched_ats == NULL)
130 {
131 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
132 ret = 1;
133 GNUNET_SCHEDULER_add_now (&end , NULL);
134 return;
135 }
136
137 /* Set up peer */
138 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey))
139 {
140 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
141 ret = GNUNET_SYSERR;
142 GNUNET_SCHEDULER_add_now (&end , NULL);
143 return;
144 }
145
146 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id)));
147
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
149 GNUNET_i2s_full(&p.id));
150
151 /* Prepare ATS Information */
152 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
153 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WLAN); /* WLAN quota is below min bw */
154 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
155 test_ats_info[1].value = htonl(1);
156 test_ats_count = 2;
157
158 /* Adding address without session */
159 test_session = NULL;
160 create_test_address (&test_addr, "test", test_session, "test", strlen ("test") + 1);
161 test_hello_address.peer = p.id;
162 test_hello_address.transport_name = test_addr.plugin;
163 test_hello_address.address = test_addr.addr;
164 test_hello_address.address_length = test_addr.addr_len;
165 GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
166
167 GNUNET_ATS_suggest_address (sched_ats, &p.id);
168
169 ret = 0;
170 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Waiting for wait period for no suggest...\n");
171 wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &end, NULL);
172}
173
174
175int
176main (int argc, char *argv[])
177{
178 if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_add_address",
179 "test_ats_api.conf",
180 &run, NULL))
181 return 1;
182 return ret;
183}
184
185/* end of file test_ats_api_scheduling_min_bw.c */
diff --git a/src/ats/test_ats_api_scheduling_update_address.c b/src/ats/test_ats_api_scheduling_update_address.c
deleted file mode 100644
index 03f7ecfab..000000000
--- a/src/ats/test_ats_api_scheduling_update_address.c
+++ /dev/null
@@ -1,238 +0,0 @@
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_scheduling_update_address.c
22 * @brief test updating an address: add address, get and compare it, update it
23 * get it again and compre
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
33static GNUNET_SCHEDULER_TaskIdentifier die_task;
34
35/**
36 * Scheduling handle
37 */
38static struct GNUNET_ATS_SchedulingHandle *sched_ats;
39
40/**
41 * Return value
42 */
43static int ret;
44
45/**
46 * Test address
47 */
48static struct Test_Address test_addr;
49
50/**
51 * Test peer
52 */
53static struct PeerContext p;
54
55/**
56 * HELLO test address
57 */
58
59struct GNUNET_HELLO_Address test_hello_address;
60
61/**
62 * Test session
63 */
64static void *test_session;
65
66/**
67 * Test ats info
68 */
69struct GNUNET_ATS_Information test_ats_info[3];
70
71/**
72 * Test ats count
73 */
74uint32_t test_ats_count;
75
76
77static void
78end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
79{
80 die_task = GNUNET_SCHEDULER_NO_TASK;
81
82 if (sched_ats != NULL)
83 GNUNET_ATS_scheduling_done (sched_ats);
84 free_test_address (&test_addr);
85 ret = GNUNET_SYSERR;
86}
87
88
89static void
90end ()
91{
92 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
93 if (die_task != GNUNET_SCHEDULER_NO_TASK)
94 {
95 GNUNET_SCHEDULER_cancel (die_task);
96 die_task = GNUNET_SCHEDULER_NO_TASK;
97 }
98 GNUNET_ATS_scheduling_done (sched_ats);
99 sched_ats = NULL;
100 free_test_address (&test_addr);
101}
102
103
104static void
105address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
106 struct Session *session,
107 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
108 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
109 const struct GNUNET_ATS_Information *atsi,
110 uint32_t ats_count)
111{
112 static int stage = 0;
113 if (0 == stage)
114 {
115 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
116 if (GNUNET_OK == compare_addresses(address, session, &test_hello_address, test_session))
117 {
118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback for correct address `%s'\n",
119 GNUNET_i2s (&address->peer));
120 ret = 0;
121 }
122 else
123 {
124 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect address `%s'\n",
125 GNUNET_i2s (&address->peer));
126 ret = 1;
127 GNUNET_SCHEDULER_add_now (&end, NULL);
128 return;
129 }
130
131 if ((ats_count != test_ats_count) ||
132 (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)))
133 {
134 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n");
135 ret = 1;
136 GNUNET_SCHEDULER_add_now (&end, NULL);
137 return;
138 }
139
140 /* Update address */
141 /* Prepare ATS Information */
142 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
143 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
144 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
145 test_ats_info[1].value = htonl(5);
146 test_ats_info[2].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
147 test_ats_info[2].value = htonl(30);
148 test_ats_count = 3;
149
150 GNUNET_ATS_address_update (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
151
152 /* Request address */
153 GNUNET_ATS_suggest_address (sched_ats, &p.id);
154 stage ++;
155 }
156 else if (1 == stage)
157 {
158 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
159 if (GNUNET_OK == compare_addresses(address, session, &test_hello_address, test_session))
160 {
161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with correct address `%s'\n",
162 GNUNET_i2s (&address->peer));
163 ret = 0;
164 }
165 else
166 {
167 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect address `%s'\n",
168 GNUNET_i2s (&address->peer));
169 ret = 1;
170 }
171
172 if ((ats_count != test_ats_count) ||
173 (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)))
174 {
175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect ats info \n");
176 ret = 1;
177 GNUNET_SCHEDULER_add_now (&end, NULL);
178 return;
179 }
180
181 GNUNET_SCHEDULER_add_now (&end, NULL);
182 }
183}
184
185static void
186run (void *cls,
187 const struct GNUNET_CONFIGURATION_Handle *cfg,
188 struct GNUNET_TESTING_Peer *peer)
189{
190 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
191
192 /* Connect to ATS scheduling */
193 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
194 if (sched_ats == NULL)
195 {
196 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
197 ret = 1;
198 end ();
199 return;
200 }
201
202 /* Set up peer */
203 memset (&p.id, '1', sizeof (p.id));
204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
205 GNUNET_i2s_full(&p.id));
206
207 /* Prepare ATS Information */
208 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
209 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
210 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
211 test_ats_info[1].value = htonl(10);
212 test_ats_count = 2;
213
214 /* Adding address without session */
215 test_session = &test_addr;
216 create_test_address (&test_addr, "test", &test_addr, "test", strlen ("test") + 1);
217 test_hello_address.peer = p.id;
218 test_hello_address.transport_name = test_addr.plugin;
219 test_hello_address.address = test_addr.addr;
220 test_hello_address.address_length = test_addr.addr_len;
221 GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
222
223 /* Request address */
224 GNUNET_ATS_suggest_address (sched_ats, &p.id);
225}
226
227
228int
229main (int argc, char *argv[])
230{
231 if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_update_address",
232 "test_ats_api.conf",
233 &run, NULL))
234 return 1;
235 return ret;
236}
237
238/* end of file test_ats_api_scheduling_update_address.c */
diff --git a/src/ats/test_ats_change_preference.c b/src/ats/test_ats_change_preference.c
deleted file mode 100644
index f6b91d36d..000000000
--- a/src/ats/test_ats_change_preference.c
+++ /dev/null
@@ -1,399 +0,0 @@
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_mlp.c
22 * @brief test for the MLP solver
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25
26 */
27/**
28 * @file ats/test_ats_change_preferences.c
29 * @brief test for ats proportional solver preference aging:
30 * Add 2 addresses and set high preference for one. Expect higher bw for this
31 * address, wait. Preferences should age and so bw assigned should decrease.
32 * @author Christian Grothoff
33 * @author Matthias Wachs
34 */
35#include "platform.h"
36#include "gnunet_ats_service.h"
37#include "gnunet_testing_lib.h"
38#include "ats.h"
39#include "test_ats_api_common.h"
40
41#define DEBUG_ATS_INFO GNUNET_NO
42
43static GNUNET_SCHEDULER_TaskIdentifier die_task;
44
45/**
46 * Scheduling handle
47 */
48static struct GNUNET_ATS_SchedulingHandle *sched_ats;
49
50/**
51 * Performance handle
52 */
53static struct GNUNET_ATS_PerformanceHandle *perf_ats;
54
55/**
56 * Return value
57 */
58static int ret;
59
60/**
61 * Test address
62 */
63static struct Test_Address test_addr[2];
64
65/**
66 * Test peer
67 */
68static struct PeerContext p[2];
69
70
71/**
72 * HELLO address
73 */
74struct GNUNET_HELLO_Address test_hello_address[2];
75
76/**
77 * Session
78 */
79static void *test_session[2];
80
81/**
82 * Test ats info
83 */
84struct GNUNET_ATS_Information test_ats_info[2];
85
86/**
87 * Test ats count
88 */
89uint32_t test_ats_count;
90
91/**
92 * Configured WAN out quota
93 */
94unsigned long long wan_quota_out;
95
96/**
97 * Configured WAN in quota
98 */
99unsigned long long wan_quota_in;
100
101
102static void
103end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
104{
105 die_task = GNUNET_SCHEDULER_NO_TASK;
106 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error! Shutting down\n");
107 if (sched_ats != NULL)
108 {
109 GNUNET_ATS_scheduling_done (sched_ats);
110 sched_ats = NULL;
111 }
112 if (perf_ats != NULL)
113 {
114 GNUNET_ATS_performance_done (perf_ats);
115 perf_ats = NULL;
116 }
117 free_test_address (&test_addr[0]);
118 ret = GNUNET_SYSERR;
119}
120
121
122static void
123end ()
124{
125 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
126 if (die_task != GNUNET_SCHEDULER_NO_TASK)
127 {
128 GNUNET_SCHEDULER_cancel (die_task);
129 die_task = GNUNET_SCHEDULER_NO_TASK;
130 }
131
132 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
133 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
134
135 if (NULL != sched_ats)
136 GNUNET_ATS_scheduling_done (sched_ats);
137 if (NULL != perf_ats)
138 GNUNET_ATS_performance_done (perf_ats);
139 sched_ats = NULL;
140 perf_ats = NULL;
141 free_test_address (&test_addr[0]);
142 free_test_address (&test_addr[1]);
143}
144
145
146static void
147address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
148 struct Session *session,
149 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
150 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
151 const struct GNUNET_ATS_Information *atsi,
152 uint32_t ats_count)
153{
154 static int stage = 0;
155 static int sug_p0 = GNUNET_NO;
156 static int sug_p1 = GNUNET_NO;
157
158 static uint32_t p0_last_bandwidth_out;
159 static uint32_t p0_last_bandwidth_in;
160
161 static uint32_t p1_last_bandwidth_out;
162 static uint32_t p1_last_bandwidth_in;
163
164 uint32_t cur_bandwidth_out = ntohl (bandwidth_out.value__);
165 uint32_t cur_bandwidth_in = ntohl (bandwidth_in.value__);
166
167 if (0 == stage)
168 {
169 /* Callback for initial suggestion */
170 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
171 {
172 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
173 stage,
174 GNUNET_i2s (&address->peer),
175 ntohl (bandwidth_in.value__),
176 ntohl (bandwidth_out.value__));
177 sug_p0 = GNUNET_YES;
178 p0_last_bandwidth_out = ntohl(bandwidth_out.value__);
179 p0_last_bandwidth_in = ntohl(bandwidth_in.value__);
180 }
181 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
182 {
183 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
184 stage,
185 GNUNET_i2s (&address->peer),
186 ntohl (bandwidth_in.value__),
187 ntohl (bandwidth_out.value__));
188 sug_p1 = GNUNET_YES;
189 p1_last_bandwidth_out = ntohl(bandwidth_out.value__);
190 p1_last_bandwidth_in = ntohl(bandwidth_in.value__);
191 }
192 if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
193 {
194 /* Changing preference for peer 0 */
195 stage ++;
196 GNUNET_ATS_performance_change_preference (perf_ats, &p[0].id, GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
197 sug_p0 = GNUNET_NO;
198 sug_p1 = GNUNET_NO;
199 return;
200 }
201
202 }
203 if (1 == stage)
204 {
205 /* Callback due to preference change */
206 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
207 {
208 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
209 stage,
210 GNUNET_i2s (&address->peer),
211 ntohl (bandwidth_in.value__),
212 ntohl (bandwidth_out.value__));
213 sug_p0 = GNUNET_YES;
214
215 /* Peer 0 should get more bandwidth */
216 if (cur_bandwidth_out <= p0_last_bandwidth_out)
217 GNUNET_break (0);
218 if (cur_bandwidth_in <= p0_last_bandwidth_in)
219 GNUNET_break (0);
220 p0_last_bandwidth_out = ntohl(bandwidth_out.value__);
221 p0_last_bandwidth_in = ntohl(bandwidth_in.value__);
222 }
223 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
224 {
225 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
226 stage,
227 GNUNET_i2s (&address->peer),
228 ntohl (bandwidth_in.value__),
229 ntohl (bandwidth_out.value__));
230 sug_p1 = GNUNET_YES;
231
232 /* Peer 1 should get less bandwidth */
233 if (cur_bandwidth_out >= p1_last_bandwidth_out)
234 {
235 GNUNET_break (0);
236 goto error;
237 }
238 if (cur_bandwidth_in >= p1_last_bandwidth_in)
239 {
240 GNUNET_break (0);
241 goto error;
242 }
243 p1_last_bandwidth_out = ntohl(bandwidth_out.value__);
244 p1_last_bandwidth_in = ntohl(bandwidth_in.value__);
245 }
246 if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
247 {
248 /* Done ! */
249 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Done!\n");
250 stage ++;
251 ret = 0;
252 GNUNET_SCHEDULER_add_now (&end,NULL);
253 return;
254 }
255 }
256 return;
257
258error:
259 /* Error ! */
260 ret = 1;
261 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Error!\n");
262 GNUNET_SCHEDULER_add_now (&end,NULL);
263}
264
265static void
266run (void *cls,
267 const struct GNUNET_CONFIGURATION_Handle *cfg,
268 struct GNUNET_TESTING_Peer *peer)
269{
270 char *quota_str;
271
272 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", &quota_str))
273 {
274 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
275 ret = 1;
276 return;
277 }
278 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_out))
279 {
280 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
281 ret = 1;
282 GNUNET_free (quota_str);
283 return;
284 }
285 GNUNET_free (quota_str);
286 quota_str = NULL;
287
288 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", &quota_str))
289 {
290 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
291 ret = 1;
292 return;
293 }
294 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_in))
295 {
296 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
297 GNUNET_free (quota_str);
298 ret = 1;
299 return;
300 }
301 GNUNET_free (quota_str);
302 quota_str = NULL;
303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n", wan_quota_in);
304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota: %llu\n", wan_quota_out);
305
306
307 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
308
309 /* Connect to ATS scheduling */
310 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
311 if (sched_ats == NULL)
312 {
313 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
314 ret = 1;
315 end ();
316 return;
317 }
318
319 /* Connect to ATS performance */
320 perf_ats = GNUNET_ATS_performance_init(cfg, NULL, NULL);
321 if (sched_ats == NULL)
322 {
323 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
324 ret = 1;
325 end ();
326 return;
327 }
328
329
330 /* Set up peer 0 */
331 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey))
332 {
333 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
334 ret = GNUNET_SYSERR;
335 end ();
336 return;
337 }
338
339 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
340
341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
342 GNUNET_i2s(&p[0].id));
343
344 /* Set up peer 1*/
345 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].id.hashPubKey))
346 {
347 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
348 ret = GNUNET_SYSERR;
349 end ();
350 return;
351 }
352
353 GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
354
355 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
356 GNUNET_i2s(&p[1].id));
357
358 /* Prepare ATS Information */
359 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
360 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
361 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
362 test_ats_info[1].value = htonl(1);
363 test_ats_count = 2;
364
365 /* Peer 0: Adding address with session */
366 test_session[0] = &test_addr[0];
367 create_test_address (&test_addr[0], "test0", test_session[0], "test0", strlen ("test0") + 1);
368 test_hello_address[0].peer = p[0].id;
369 test_hello_address[0].transport_name = test_addr[0].plugin;
370 test_hello_address[0].address = test_addr[0].addr;
371 test_hello_address[0].address_length = test_addr[0].addr_len;
372 GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0], test_ats_info, test_ats_count);
373
374 /* Peer 1: Adding address with session */
375 test_session[1] = &test_addr[1];
376 create_test_address (&test_addr[1], "test1", test_session[1], "test1", strlen ("test1") + 1);
377 test_hello_address[1].peer = p[1].id;
378 test_hello_address[1].transport_name = test_addr[1].plugin;
379 test_hello_address[1].address = test_addr[1].addr;
380 test_hello_address[1].address_length = test_addr[1].addr_len;
381 GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count);
382
383 GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
384 GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
385}
386
387
388int
389main (int argc, char *argv[])
390{
391 if (0 != GNUNET_TESTING_peer_run ("test_ats_change_preferences",
392 "test_ats_api.conf",
393 &run, NULL))
394 return 1;
395 return ret;
396}
397
398
399/* end of file test_ats_change_preferences.c */
diff --git a/src/ats/test_ats_mlp.c b/src/ats/test_ats_mlp.c
deleted file mode 100644
index be5e39fcf..000000000
--- a/src/ats/test_ats_mlp.c
+++ /dev/null
@@ -1,330 +0,0 @@
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_mlp.c
22 * @brief basic test for the MLP solver
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25
26 */
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_statistics_service.h"
30#include "gnunet_ats_service.h"
31#include "gnunet-service-ats-solver_mlp.h"
32#include "gnunet-service-ats_normalization.h"
33#include "gnunet_ats_service.h"
34#include "test_ats_api_common.h"
35
36/**
37 * Return value
38 */
39static int ret;
40
41/**
42 * MLP solver handle
43 */
44struct GAS_MLP_Handle *mlp;
45
46
47/**
48 * Statistics handle
49 */
50struct GNUNET_STATISTICS_Handle * stats;
51
52/**
53 * Hashmap containing addresses
54 */
55struct GNUNET_CONTAINER_MultiHashMap * addresses;
56
57/**
58 * Peer
59 */
60struct GNUNET_PeerIdentity p[2];
61
62/**
63 * ATS Address
64 */
65struct ATS_Address *address[3];
66
67/**
68 * Timeout task
69 */
70GNUNET_SCHEDULER_TaskIdentifier timeout_task;
71
72
73int addr_it (void *cls,
74 const struct GNUNET_HashCode * key,
75 void *value)
76{
77 struct ATS_Address *address = (struct ATS_Address *) value;
78 GAS_mlp_address_delete (mlp, address, GNUNET_NO);
79 GNUNET_CONTAINER_multihashmap_remove (addresses, key, value);
80 GNUNET_free (address);
81 return GNUNET_OK;
82}
83
84
85static void
86end_now (int res)
87{
88 if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
89 {
90 GNUNET_SCHEDULER_cancel (timeout_task);
91 timeout_task = GNUNET_SCHEDULER_NO_TASK;
92 }
93 if (NULL != stats)
94 {
95 GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
96 stats = NULL;
97 }
98 if (NULL != addresses)
99 {
100 GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it, NULL);
101 GNUNET_CONTAINER_multihashmap_destroy (addresses);
102 addresses = NULL ;
103 }
104 if (NULL != mlp)
105 {
106 GAS_mlp_done (mlp);
107 mlp = NULL;
108 }
109 GAS_normalization_stop ();
110 ret = res;
111}
112
113static void
114end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
115{
116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Test ending with success\n"));
117 end_now (0);
118}
119
120static void
121end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
122{
123 GNUNET_break (0);
124 timeout_task = GNUNET_SCHEDULER_NO_TASK;
125 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test ending with timeout\n"));
126 end_now (1);
127}
128
129
130const double *
131get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
132{
133 return GAS_normalization_get_preferences (id);
134}
135
136const double *
137get_property_cb (void *cls, const struct ATS_Address *address)
138{
139 return GAS_normalization_get_properties ((struct ATS_Address *) address);
140}
141
142static void
143normalized_property_changed_cb (void *cls,
144 struct ATS_Address *peer,
145 uint32_t type,
146 double prop_rel)
147{
148 /* TODO */
149}
150
151
152static void
153bandwidth_changed_cb (void *cls, struct ATS_Address *address)
154{
155 static int cb_p0 = GNUNET_NO;
156 static int cb_p1 = GNUNET_NO;
157
158 unsigned long long in = ntohl(address->assigned_bw_in.value__);
159 unsigned long long out = ntohl(address->assigned_bw_out.value__);
160
161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP suggests for peer `%s' address `%s':`%s' in %llu out %llu \n",
162 GNUNET_i2s(&address->peer),
163 address->plugin,
164 address->addr,
165 in, out);
166
167 if ((in > 0) && (out > 0) &&
168 (0 == memcmp(&p[0], &address->peer, sizeof (address->peer))))
169 cb_p0 ++;
170
171 if ((in > 0) && (out > 0) &&
172 (0 == memcmp(&p[1], &address->peer, sizeof (address->peer))))
173 cb_p1 ++;
174
175 if ((1 == cb_p0) && (1 == cb_p1))
176 GNUNET_SCHEDULER_add_now (&end_correctly, NULL);
177 else if ((1 < cb_p0) || (1 < cb_p1))
178 {
179 GNUNET_break (0);
180 GNUNET_SCHEDULER_add_now (&end_badly, NULL);
181 }
182}
183
184
185static void
186check (void *cls, char *const *args, const char *cfgfile,
187 const struct GNUNET_CONFIGURATION_Handle *cfg)
188{
189 int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
190 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
191 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
192
193#if !HAVE_LIBGLPK
194 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
195 ret = 1;
196 return;
197#endif
198
199 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
200
201 stats = GNUNET_STATISTICS_create("ats", cfg);
202 if (NULL == stats)
203 {
204 GNUNET_break (0);
205 end_now (1);
206 return;
207 }
208
209 /* Load quotas */
210 if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg, quotas_out, quotas_in,
211 GNUNET_ATS_NetworkTypeCount))
212 {
213 GNUNET_break (0);
214 end_now (1);
215 return;
216 }
217 GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL);
218 /* Setup address hashmap */
219 addresses = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
220
221 /* Init MLP solver */
222 mlp = GAS_mlp_init (cfg, stats, addresses,
223 quotas, quotas_out, quotas_in,
224 GNUNET_ATS_NetworkTypeCount,
225 &bandwidth_changed_cb, NULL,
226 &get_preferences_cb, NULL,
227 &get_property_cb, NULL);
228 if (NULL == mlp)
229 {
230 GNUNET_break (0);
231 end_now (1);
232 return;
233 }
234 mlp->mlp_auto_solve = GNUNET_NO;
235
236 /* Create peer 0 */
237 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].hashPubKey))
238 {
239 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
240 end_now (1);
241 return;
242 }
243
244 /* Create peer 1 */
245 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].hashPubKey))
246 {
247 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
248 end_now (1);
249 return;
250 }
251
252 /* Create address 0 */
253 address[0] = create_address (&p[0], "test_plugin0", "test_addr0", strlen("test_addr0")+1, 0);
254 if (NULL == address[0])
255 {
256 GNUNET_break (0);
257 end_now (1);
258 return;
259 }
260 GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[0],
261 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
262 /* Adding address 0 */
263 GAS_mlp_address_add (mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED);
264
265 /* Create address 1 */
266 address[1] = create_address (&p[0], "test_plugin1", "test_addr1", strlen("test_addr1")+1, 0);
267 if (NULL == address[1])
268 {
269 GNUNET_break (0);
270 end_now (1);
271 return;
272 }
273 GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[1],
274 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
275 /* Adding address 1*/
276 GAS_mlp_address_add (mlp, address[1], GNUNET_ATS_NET_UNSPECIFIED);
277
278
279 /* Create address 3 */
280 address[2] = create_address (&p[1], "test_plugin2", "test_addr2", strlen("test_addr2")+1, 0);
281 if (NULL == address[2])
282 {
283 GNUNET_break (0);
284 end_now (1);
285 return;
286 }
287 GNUNET_CONTAINER_multihashmap_put (addresses, &p[1].hashPubKey, address[2],
288 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
289 /* Adding address 3*/
290 GAS_mlp_address_add (mlp, address[2], GNUNET_ATS_NET_UNSPECIFIED);
291
292
293 /* Updating address 0*/
294 GAS_mlp_address_change_network(mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED, GNUNET_ATS_NET_WAN);
295
296 /* Retrieving preferred address for peer and wait for callback */
297 GAS_mlp_get_preferred_address (mlp, &p[0]);
298 GAS_mlp_get_preferred_address (mlp, &p[1]);
299
300 mlp->write_mip_mps = GNUNET_NO;
301 mlp->write_mip_sol = GNUNET_NO;
302
303 GAS_mlp_solve_problem (mlp);
304}
305
306
307int
308main (int argc, char *argv[])
309{
310
311 static char *const argv2[] = { "test_ats_mlp",
312 "-c",
313 "test_ats_mlp.conf",
314 "-L", "WARNING",
315 NULL
316 };
317
318 static struct GNUNET_GETOPT_CommandLineOption options[] = {
319 GNUNET_GETOPT_OPTION_END
320 };
321
322 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
323 "test_ats_mlp", "nohelp", options,
324 &check, NULL);
325
326
327 return ret;
328}
329
330/* end of file test_ats_api_bandwidth_consumption.c */
diff --git a/src/ats/test_ats_mlp_update.c b/src/ats/test_ats_mlp_update.c
deleted file mode 100644
index 8e5a1d6eb..000000000
--- a/src/ats/test_ats_mlp_update.c
+++ /dev/null
@@ -1,312 +0,0 @@
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_mlp_updating.c
22 * @brief basic test for updating ATS in MLP solver
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25
26 */
27#include "platform.h"
28#include "gnunet_util_lib.h"
29#include "gnunet_statistics_service.h"
30#include "gnunet_ats_service.h"
31#include "gnunet-service-ats-solver_mlp.h"
32#include "gnunet-service-ats_normalization.h"
33#include "test_ats_api_common.h"
34
35/**
36 * Return value
37 */
38static int ret;
39
40/**
41 * ATS Information
42 */
43struct GNUNET_ATS_Information ats[4];
44
45struct GNUNET_ATS_Information ats_prev[4];
46
47/**
48 * MLP solver handle
49 */
50struct GAS_MLP_Handle *mlp;
51
52
53/**
54 * Statistics handle
55 */
56struct GNUNET_STATISTICS_Handle * stats;
57
58/**
59 * Hashmap containing addresses
60 */
61struct GNUNET_CONTAINER_MultiHashMap * addresses;
62
63/**
64 * Peer
65 */
66struct GNUNET_PeerIdentity p[2];
67
68/**
69 * ATS Address
70 */
71struct ATS_Address *address[3];
72
73/**
74 * Timeout task
75 */
76GNUNET_SCHEDULER_TaskIdentifier timeout_task;
77
78
79int addr_it (void *cls,
80 const struct GNUNET_HashCode * key,
81 void *value)
82{
83 struct ATS_Address *address = (struct ATS_Address *) value;
84 GAS_mlp_address_delete (mlp, address, GNUNET_NO);
85 GNUNET_CONTAINER_multihashmap_remove (addresses, key, value);
86 GNUNET_free (address);
87 return GNUNET_OK;
88}
89
90
91static void
92end_now (int res)
93{
94 if (GNUNET_SCHEDULER_NO_TASK != timeout_task)
95 {
96 GNUNET_SCHEDULER_cancel (timeout_task);
97 timeout_task = GNUNET_SCHEDULER_NO_TASK;
98 }
99 if (NULL != stats)
100 {
101 GNUNET_STATISTICS_destroy(stats, GNUNET_NO);
102 stats = NULL;
103 }
104 if (NULL != addresses)
105 {
106 GNUNET_CONTAINER_multihashmap_iterate (addresses, &addr_it, NULL);
107 GNUNET_CONTAINER_multihashmap_destroy (addresses);
108 addresses = NULL ;
109 }
110 if (NULL != mlp)
111 {
112 GAS_mlp_done (mlp);
113 mlp = NULL;
114 }
115 GAS_normalization_stop ();
116
117 ret = res;
118}
119
120static void
121end_correctly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
122{
123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Test ending with success\n"));
124 end_now (0);
125}
126
127static void
128end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
129{
130 GNUNET_break (0);
131 timeout_task = GNUNET_SCHEDULER_NO_TASK;
132 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Test ending with timeout\n"));
133 end_now (1);
134}
135
136static const double *
137get_preferences_cb (void *cls, const struct GNUNET_PeerIdentity *id)
138{
139 return GAS_normalization_get_preferences (id);
140}
141
142const double *
143get_property_cb (void *cls, const struct ATS_Address *address)
144{
145 return GAS_normalization_get_properties ((struct ATS_Address *) address);
146}
147
148static void
149normalized_property_changed_cb (void *cls,
150 struct ATS_Address *peer,
151 uint32_t type,
152 double prop_rel)
153{
154 /* TODO */
155}
156
157
158static void
159bandwidth_changed_cb (void *cls, struct ATS_Address *address)
160{
161 static int cb_p0 = GNUNET_NO;
162
163 unsigned long long in = ntohl(address->assigned_bw_in.value__);
164 unsigned long long out = ntohl(address->assigned_bw_out.value__);
165
166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "MLP suggests for peer `%s' address `%s':`%s' in %llu out %llu \n",
167 GNUNET_i2s(&address->peer),
168 address->plugin,
169 address->addr,
170 in, out);
171
172 if ((in > 0) && (out > 0) &&
173 (0 == memcmp(&p[0], &address->peer, sizeof (address->peer))))
174 cb_p0 ++;
175
176 if (1 == cb_p0)
177 GNUNET_SCHEDULER_add_now (&end_correctly, NULL);
178}
179
180
181static void
182check (void *cls, char *const *args, const char *cfgfile,
183 const struct GNUNET_CONFIGURATION_Handle *cfg)
184{
185 int quotas[GNUNET_ATS_NetworkTypeCount] = GNUNET_ATS_NetworkType;
186 unsigned long long quotas_in[GNUNET_ATS_NetworkTypeCount];
187 unsigned long long quotas_out[GNUNET_ATS_NetworkTypeCount];
188
189#if !HAVE_LIBGLPK
190 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "GLPK not installed!");
191 ret = 1;
192 return;
193#endif
194
195 timeout_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
196
197 stats = GNUNET_STATISTICS_create("ats", cfg);
198 if (NULL == stats)
199 {
200 GNUNET_break (0);
201 end_now (1);
202 return;
203 }
204
205 /* Load quotas */
206 if (GNUNET_ATS_NetworkTypeCount != load_quotas (cfg, quotas_out, quotas_in,
207 GNUNET_ATS_NetworkTypeCount))
208 {
209 GNUNET_break (0);
210 end_now (1);
211 return;
212 }
213 GAS_normalization_start (NULL, NULL, &normalized_property_changed_cb, NULL);
214
215 /* Setup address hashmap */
216 addresses = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
217
218 /* Init MLP solver */
219 mlp = GAS_mlp_init (cfg, stats, addresses,
220 quotas, quotas_out, quotas_in,
221 GNUNET_ATS_NetworkTypeCount,
222 &bandwidth_changed_cb, NULL,
223 &get_preferences_cb, NULL,
224 &get_property_cb, NULL);
225 if (NULL == mlp)
226 {
227 GNUNET_break (0);
228 end_now (1);
229 return;
230 }
231 mlp->mlp_auto_solve = GNUNET_NO;
232
233 /* Create peer 0 */
234 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].hashPubKey))
235 {
236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
237 end_now (1);
238 return;
239 }
240
241 /* Create address 0 */
242 address[0] = create_address (&p[0], "test_plugin0", "test_addr0", strlen("test_addr0")+1, 0);
243 if (NULL == address[0])
244 {
245 GNUNET_break (0);
246 end_now (1);
247 return;
248 }
249 GNUNET_CONTAINER_multihashmap_put (addresses, &p[0].hashPubKey, address[0],
250 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
251 /* Adding address 0 */
252 GAS_mlp_address_add (mlp, address[0], GNUNET_ATS_NET_UNSPECIFIED);
253
254 /* Retrieving preferred address for peer and wait for callback */
255 GAS_mlp_get_preferred_address (mlp, &p[0]);
256
257 /* Solve problem to build matrix */
258 GAS_mlp_solve_problem (mlp);
259
260 address[0]->atsi = ats;
261 address[0]->atsi_count = 4;
262 /* Updating address 0*/
263 ats[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
264 ats[0].value = htonl (GNUNET_ATS_NET_WAN);
265 ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
266 ats[1].value = htonl (10);
267 ats[2].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
268 ats[2].value = htonl (1);
269 ats[3].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
270 ats[3].value = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
271
272 ats_prev[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
273 ats_prev[0].value = htonl (GNUNET_ATS_NET_UNSPECIFIED);
274 ats_prev[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
275 ats_prev[1].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
276 ats_prev[2].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
277 ats_prev[2].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
278 ats_prev[3].type = htonl (GNUNET_ATS_ARRAY_TERMINATOR);
279 ats_prev[3].value = htonl (GNUNET_ATS_VALUE_UNDEFINED);
280
281 GAS_mlp_address_property_changed(mlp, address[0], GNUNET_ATS_QUALITY_NET_DELAY, 10, 1.1);
282 GAS_mlp_address_property_changed(mlp, address[0], GNUNET_ATS_QUALITY_NET_DISTANCE, 1, 1.0);
283
284 /* Solve problem to build matrix */
285 GAS_mlp_solve_problem (mlp);
286}
287
288
289int
290main (int argc, char *argv[])
291{
292
293 static char *const argv2[] = { "test_ats_mlp_updating",
294 "-c",
295 "test_ats_mlp.conf",
296 "-L", "WARNING",
297 NULL
298 };
299
300 static struct GNUNET_GETOPT_CommandLineOption options[] = {
301 GNUNET_GETOPT_OPTION_END
302 };
303
304 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
305 "test_ats_mlp_updating", "nohelp", options,
306 &check, NULL);
307
308
309 return ret;
310}
311
312/* end of file test_ats_mlp_updating.c */
diff --git a/src/ats/test_ats_normalization_update_quality.c b/src/ats/test_ats_normalization_update_quality.c
deleted file mode 100644
index 483994b37..000000000
--- a/src/ats/test_ats_normalization_update_quality.c
+++ /dev/null
@@ -1,241 +0,0 @@
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_normalization_update_quality.c
22 * @brief test updating an address
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#include "test_ats_api_common.h"
31
32static GNUNET_SCHEDULER_TaskIdentifier die_task;
33
34/**
35 * Scheduling handle
36 */
37static struct GNUNET_ATS_SchedulingHandle *sched_ats;
38
39/**
40 * Return value
41 */
42static int ret;
43
44/**
45 * Test address
46 */
47static struct Test_Address test_addr[3];
48
49/**
50 * Test peer
51 */
52static struct PeerContext p[2];
53
54/**
55 * HELLO test address
56 */
57
58struct GNUNET_HELLO_Address test_hello_address[3];
59
60/**
61 * Test ats info
62 */
63struct GNUNET_ATS_Information test_ats_info[3];
64
65/**
66 * Test ats count
67 */
68uint32_t test_ats_count;
69
70
71static void
72end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
73{
74 die_task = GNUNET_SCHEDULER_NO_TASK;
75
76 if (sched_ats != NULL)
77 GNUNET_ATS_scheduling_done (sched_ats);
78 free_test_address (&test_addr[0]);
79 free_test_address (&test_addr[1]);
80 free_test_address (&test_addr[2]);
81 ret = 0;
82}
83
84
85static void
86end ()
87{
88 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
89 if (die_task != GNUNET_SCHEDULER_NO_TASK)
90 {
91 GNUNET_SCHEDULER_cancel (die_task);
92 die_task = GNUNET_SCHEDULER_NO_TASK;
93 }
94 GNUNET_ATS_scheduling_done (sched_ats);
95 sched_ats = NULL;
96 free_test_address (&test_addr[0]);
97 free_test_address (&test_addr[1]);
98 free_test_address (&test_addr[2]);
99}
100
101
102static void
103address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
104 struct Session *session,
105 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
106 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
107 const struct GNUNET_ATS_Information *atsi,
108 uint32_t ats_count)
109{
110 static int stage = 0;
111 if (0 == stage)
112 {
113 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
114
115 /* Update address */
116 /* Prepare ATS Information */
117
118 test_ats_info[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
119 test_ats_info[0].value = htonl(20);
120 test_ats_count = 1;
121
122 GNUNET_ATS_address_update (sched_ats, &test_hello_address[0], NULL, test_ats_info, test_ats_count);
123
124 test_ats_info[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
125 test_ats_info[0].value = htonl(20);
126 test_ats_count = 1;
127
128 GNUNET_ATS_address_update (sched_ats, &test_hello_address[0], NULL, test_ats_info, test_ats_count);
129
130
131 /* Request address */
132 stage ++;
133 }
134}
135
136static void
137run (void *cls,
138 const struct GNUNET_CONFIGURATION_Handle *cfg,
139 struct GNUNET_TESTING_Peer *peer)
140{
141 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
142
143 /* Connect to ATS scheduling */
144 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
145 if (sched_ats == NULL)
146 {
147 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
148 ret = 1;
149 end ();
150 return;
151 }
152
153 /* Set up peer */
154 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey))
155 {
156 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
157 ret = GNUNET_SYSERR;
158 end ();
159 return;
160 }
161
162 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
163
164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
165 GNUNET_i2s_full(&p[0].id));
166
167 /* Set up peer */
168 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].id.hashPubKey))
169 {
170 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
171 ret = GNUNET_SYSERR;
172 end ();
173 return;
174 }
175
176 GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
177
178 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
179 GNUNET_i2s_full(&p[1].id));
180
181
182
183 /* Adding address for peer 0 */
184 create_test_address (&test_addr[0], "test", &test_addr, "test_p0_a0", strlen ("test_p0_a0") + 1);
185 /* Prepare ATS Information */
186 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
187 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
188 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
189 test_ats_info[1].value = htonl(30);
190 test_ats_count = 2;
191
192 test_hello_address[0].peer = p[0].id;
193 test_hello_address[0].transport_name = test_addr[0].plugin;
194 test_hello_address[0].address = test_addr[0].addr;
195 test_hello_address[0].address_length = test_addr[0].addr_len;
196 GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], NULL, test_ats_info, test_ats_count);
197
198 /* Adding address for peer 1 */
199 create_test_address (&test_addr[1], "test", &test_addr, "test_p1_a0", strlen ("test_p1_a0") + 1);
200 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
201 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
202 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
203 test_ats_info[1].value = htonl(10);
204 test_ats_count = 2;
205
206 test_hello_address[1].peer = p[1].id;
207 test_hello_address[1].transport_name = test_addr[1].plugin;
208 test_hello_address[1].address = test_addr[1].addr;
209 test_hello_address[1].address_length = test_addr[1].addr_len;
210 GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], NULL, test_ats_info, test_ats_count);
211
212 /* Adding 2nd address for peer 1 */
213 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
214 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
215 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
216 test_ats_info[1].value = htonl(20);
217 test_ats_count = 2;
218
219 create_test_address (&test_addr[2], "test", &test_addr, "test_p1_a1", strlen ("test_p1_a1") + 1);
220 test_hello_address[2].peer = p[1].id;
221 test_hello_address[2].transport_name = test_addr[2].plugin;
222 test_hello_address[2].address = test_addr[2].addr;
223 test_hello_address[2].address_length = test_addr[2].addr_len;
224 GNUNET_ATS_address_add (sched_ats, &test_hello_address[2], NULL, test_ats_info, test_ats_count);
225
226 /* Request address */
227 GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
228}
229
230
231int
232main (int argc, char *argv[])
233{
234 if (0 != GNUNET_TESTING_peer_run ("test_ats_normalization_update_quality",
235 "test_ats_api.conf",
236 &run, NULL))
237 return 1;
238 return ret;
239}
240
241/* end of file test_ats_normalization_update_quality.c*/
diff --git a/src/ats/test_ats_simplistic.c b/src/ats/test_ats_simplistic.c
deleted file mode 100644
index b11ae4efe..000000000
--- a/src/ats/test_ats_simplistic.c
+++ /dev/null
@@ -1,380 +0,0 @@
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_mlp.c
22 * @brief test for the MLP solver
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25
26 */
27/**
28 * @file ats/test_ats_api_scheduling_add_address.c
29 * @brief test for ats simplistic solver
30 * @author Christian Grothoff
31 * @author Matthias Wachs
32 */
33#include "platform.h"
34#include "gnunet_ats_service.h"
35#include "gnunet_testing_lib.h"
36#include "ats.h"
37#include "test_ats_api_common.h"
38
39#define DEBUG_ATS_INFO GNUNET_NO
40
41static GNUNET_SCHEDULER_TaskIdentifier die_task;
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[2];
57
58/**
59 * Test peer
60 */
61static struct PeerContext p[2];
62
63
64/**
65 * HELLO address
66 */
67struct GNUNET_HELLO_Address test_hello_address[2];
68
69/**
70 * Session
71 */
72static void *test_session[2];
73
74/**
75 * Test ats info
76 */
77struct GNUNET_ATS_Information test_ats_info[2];
78
79/**
80 * Test ats count
81 */
82uint32_t test_ats_count;
83
84/**
85 * Configured WAN out quota
86 */
87unsigned long long wan_quota_out;
88
89/**
90 * Configured WAN in quota
91 */
92unsigned long long wan_quota_in;
93
94
95static void
96end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
97{
98 die_task = GNUNET_SCHEDULER_NO_TASK;
99
100 if (sched_ats != NULL)
101 GNUNET_ATS_scheduling_done (sched_ats);
102 free_test_address (&test_addr[0]);
103 ret = GNUNET_SYSERR;
104}
105
106
107static void
108end ()
109{
110 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
111 if (die_task != GNUNET_SCHEDULER_NO_TASK)
112 {
113 GNUNET_SCHEDULER_cancel (die_task);
114 die_task = GNUNET_SCHEDULER_NO_TASK;
115 }
116 GNUNET_ATS_scheduling_done (sched_ats);
117 sched_ats = NULL;
118 free_test_address (&test_addr[0]);
119}
120
121
122static void
123address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
124 struct Session *session,
125 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
126 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
127 const struct GNUNET_ATS_Information *atsi,
128 uint32_t ats_count)
129{
130 static int stage = 0;
131 unsigned int bw_in = ntohl(bandwidth_in.value__);
132 unsigned int bw_out = ntohl(bandwidth_out.value__);
133 if (0 == stage)
134 {
135 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0]))
136 {
137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with correct address `%s'\n",
138 GNUNET_i2s (&address->peer));
139 ret = 0;
140 }
141 else
142 {
143 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 0: Callback with invalid address `%s'\n",
144 GNUNET_i2s (&address->peer));
145 ret = 1;
146 }
147
148 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
149 {
150 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 0: Callback with incorrect ats info \n");
151 ret = 1;
152 }
153
154 if (bw_in > wan_quota_in)
155 {
156 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n",
157 bw_in, wan_quota_in);
158 ret = 1;
159 }
160 else
161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n",
162 bw_in, wan_quota_in);
163
164 if (bw_out > wan_quota_out)
165 {
166 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n",
167 bw_out, wan_quota_out);
168 ret = 1;
169 }
170 else
171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n",
172 bw_out, wan_quota_out);
173
174 if (1 == ret)
175 {
176 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
177 GNUNET_SCHEDULER_add_now (&end, NULL);
178 return;
179 }
180 p[0].bw_out_assigned = bw_out;
181 p[0].bw_in_assigned = bw_in;
182 stage ++;
183
184 /* Add a 2nd address */
185 /* Prepare ATS Information */
186 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
187 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
188 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
189 test_ats_info[1].value = htonl(1);
190 test_ats_count = 2;
191
192 /* Adding address with session */
193 test_session[1] = &test_addr[1];
194 create_test_address (&test_addr[1], "test1", test_session[1], "test1", strlen ("test1") + 1);
195 test_hello_address[1].peer = p[1].id;
196 test_hello_address[1].transport_name = test_addr[1].plugin;
197 test_hello_address[1].address = test_addr[1].addr;
198 test_hello_address[1].address_length = test_addr[1].addr_len;
199 GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count);
200 }
201 if (1 == stage)
202 {
203 /* Expecting callback for address[0] with updated quota and no callback for address[1]*/
204 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0]))
205 {
206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with correct address `%s'\n",
207 GNUNET_i2s (&address->peer));
208 ret = 0;
209 }
210 else
211 {
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage 1: Callback with invalid address `%s'\n",
213 GNUNET_i2s (&address->peer));
214 ret = 1;
215 }
216
217 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
218 {
219 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage 1: Callback with incorrect ats info \n");
220 ret = 1;
221 }
222
223 if (bw_in > wan_quota_in)
224 {
225 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n",
226 bw_in, wan_quota_in);
227 ret = 1;
228 }
229 else if (p[0].bw_in_assigned > bw_in)
230 {
231 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than last quota %llu \n",
232 bw_in, p[0].bw_in_assigned);
233 ret = 1;
234 }
235 else
236 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n",
237 bw_in, wan_quota_in);
238
239 if (bw_out > wan_quota_out)
240 {
241 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n",
242 bw_out, wan_quota_out);
243 ret = 1;
244 }
245 else if (p[0].bw_out_assigned > bw_out)
246 {
247 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than last quota %llu \n",
248 bw_out, p[0].bw_out_assigned);
249 ret = 1;
250 }
251 else
252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n",
253 bw_out, wan_quota_out);
254
255 if (1 == ret)
256 {
257 GNUNET_SCHEDULER_add_now (&end, NULL);
258 return;
259 }
260 stage ++;
261 GNUNET_SCHEDULER_add_now (&end, NULL);
262 return;
263 }
264
265}
266
267static void
268run (void *cls,
269 const struct GNUNET_CONFIGURATION_Handle *cfg,
270 struct GNUNET_TESTING_Peer *peer)
271{
272 char *quota_str;
273
274 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", &quota_str))
275 {
276 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
277 ret = 1;
278 return;
279 }
280 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_out))
281 {
282 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
283 ret = 1;
284 GNUNET_free (quota_str);
285 return;
286 }
287 GNUNET_free (quota_str);
288 quota_str = NULL;
289
290 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", &quota_str))
291 {
292 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
293 ret = 1;
294 return;
295 }
296 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_in))
297 {
298 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
299 GNUNET_free (quota_str);
300 ret = 1;
301 return;
302 }
303 GNUNET_free (quota_str);
304 quota_str = NULL;
305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n", wan_quota_in);
306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota: %llu\n", wan_quota_out);
307
308
309 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
310
311 /* Connect to ATS scheduling */
312 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
313 if (sched_ats == NULL)
314 {
315 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
316 ret = 1;
317 end ();
318 return;
319 }
320
321 /* Set up peer 0 */
322 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey))
323 {
324 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
325 ret = GNUNET_SYSERR;
326 end ();
327 return;
328 }
329
330 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
331
332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
333 GNUNET_i2s(&p[0].id));
334
335 /* Set up peer 1*/
336 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].id.hashPubKey))
337 {
338 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
339 ret = GNUNET_SYSERR;
340 end ();
341 return;
342 }
343
344 GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
345
346 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
347 GNUNET_i2s(&p[1].id));
348
349 /* Prepare ATS Information */
350 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
351 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
352 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
353 test_ats_info[1].value = htonl(1);
354 test_ats_count = 2;
355
356 /* Adding address with session */
357 test_session[0] = &test_addr[0];
358 create_test_address (&test_addr[0], "test0", test_session[0], "test0", strlen ("test0") + 1);
359 test_hello_address[0].peer = p[0].id;
360 test_hello_address[0].transport_name = test_addr[0].plugin;
361 test_hello_address[0].address = test_addr[0].addr;
362 test_hello_address[0].address_length = test_addr[0].addr_len;
363 GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0], test_ats_info, test_ats_count);
364
365 GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
366}
367
368
369int
370main (int argc, char *argv[])
371{
372 if (0 != GNUNET_TESTING_peer_run ("test_ats_simplististic",
373 "test_ats_api.conf",
374 &run, NULL))
375 return 1;
376 return ret;
377}
378
379
380/* end of file test_ats_api_bandwidth_consumption.c */
diff --git a/src/ats/test_ats_simplistic_change_preference.c b/src/ats/test_ats_simplistic_change_preference.c
deleted file mode 100644
index d5dbe9f9a..000000000
--- a/src/ats/test_ats_simplistic_change_preference.c
+++ /dev/null
@@ -1,418 +0,0 @@
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_mlp.c
22 * @brief test for the MLP solver
23 * @author Christian Grothoff
24 * @author Matthias Wachs
25
26 */
27/**
28 * @file ats/test_ats_simplistic_change_preference.c
29 * @brief test for changing preferences in ats proportional solver
30 * @author Christian Grothoff
31 * @author Matthias Wachs
32 */
33#include "platform.h"
34#include "gnunet_ats_service.h"
35#include "gnunet_testing_lib.h"
36#include "ats.h"
37#include "test_ats_api_common.h"
38
39#define DEBUG_ATS_INFO GNUNET_NO
40
41#define SLEEP GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
42
43static GNUNET_SCHEDULER_TaskIdentifier die_task;
44
45/**
46 * Scheduling handle
47 */
48static struct GNUNET_ATS_SchedulingHandle *sched_ats;
49
50/**
51 * Scheduling handle
52 */
53static struct GNUNET_ATS_PerformanceHandle *perf_ats;
54
55
56/**
57 * Return value
58 */
59static int ret;
60
61/**
62 * Test address
63 */
64static struct Test_Address test_addr[2];
65
66/**
67 * Test peer
68 */
69static struct PeerContext p[2];
70
71
72/**
73 * HELLO address
74 */
75struct GNUNET_HELLO_Address test_hello_address[2];
76
77/**
78 * Session
79 */
80static void *test_session[2];
81
82/**
83 * Test ats info
84 */
85struct GNUNET_ATS_Information test_ats_info[2];
86
87/**
88 * Test ats count
89 */
90uint32_t test_ats_count;
91
92/**
93 * Configured WAN out quota
94 */
95unsigned long long wan_quota_out;
96
97/**
98 * Configured WAN in quota
99 */
100unsigned long long wan_quota_in;
101
102
103static void
104end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
105{
106 die_task = GNUNET_SCHEDULER_NO_TASK;
107
108 if (sched_ats != NULL)
109 GNUNET_ATS_scheduling_done (sched_ats);
110 if (perf_ats != NULL)
111 GNUNET_ATS_performance_done (perf_ats);
112 free_test_address (&test_addr[0]);
113 ret = GNUNET_SYSERR;
114}
115
116
117static void
118end ()
119{
120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
121 if (die_task != GNUNET_SCHEDULER_NO_TASK)
122 {
123 GNUNET_SCHEDULER_cancel (die_task);
124 die_task = GNUNET_SCHEDULER_NO_TASK;
125 }
126 GNUNET_ATS_performance_done (perf_ats);
127 perf_ats = NULL;
128 GNUNET_ATS_scheduling_done (sched_ats);
129 sched_ats = NULL;
130 free_test_address (&test_addr[0]);
131}
132
133
134static void
135address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
136 struct Session *session,
137 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
138 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
139 const struct GNUNET_ATS_Information *atsi,
140 uint32_t ats_count)
141{
142 static int stage = 0;
143 unsigned int bw_in = ntohl(bandwidth_in.value__);
144 unsigned int bw_out = ntohl(bandwidth_out.value__);
145 if (0 == stage)
146 {
147 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[0], test_session[0]))
148 {
149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n",
150 stage,
151 GNUNET_i2s (&address->peer));
152 ret = 0;
153 }
154 else
155 {
156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n",
157 stage,
158 GNUNET_i2s (&address->peer));
159 ret = 1;
160 }
161
162 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
163 {
164 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n",
165 stage);
166 ret = 1;
167 }
168
169 if (bw_in > wan_quota_in)
170 {
171 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n",
172 bw_in, wan_quota_in);
173 ret = 1;
174 }
175 else
176 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n",
177 bw_in, wan_quota_in);
178
179 if (bw_out > wan_quota_out)
180 {
181 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n",
182 bw_out, wan_quota_out);
183 ret = 1;
184 }
185 else
186 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n",
187 bw_out, wan_quota_out);
188
189 if (1 == ret)
190 {
191 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
192 GNUNET_SCHEDULER_add_now (&end, NULL);
193 return;
194 }
195
196 stage ++;
197
198 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
199 GNUNET_ATS_suggest_address (sched_ats, &p[1].id);
200 return;
201 }
202 if (1 == stage)
203 {
204 if (GNUNET_OK == compare_addresses (address, session, &test_hello_address[1], test_session[1]))
205 {
206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n",
207 stage,
208 GNUNET_i2s (&address->peer));
209 ret = 0;
210 }
211 else
212 {
213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n",
214 stage,
215 GNUNET_i2s (&address->peer));
216 ret = 1;
217 }
218
219 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
220 {
221 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n",
222 stage);
223 ret = 1;
224 }
225
226 if (bw_in > wan_quota_in)
227 {
228 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN inbound quota %u bigger than allowed quota %llu \n",
229 bw_in, wan_quota_in);
230 ret = 1;
231 }
232 else
233 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN inbound quota %u, allowed quota %llu \n",
234 bw_in, wan_quota_in);
235
236 if (bw_out > wan_quota_out)
237 {
238 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Suggested WAN outbound quota %u bigger than allowed quota %llu \n",
239 bw_out, wan_quota_out);
240 ret = 1;
241 }
242 else
243 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Suggested WAN outbound quota %u, allowed quota %llu \n",
244 bw_out, wan_quota_out);
245
246 if (1 == ret)
247 {
248 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[0].id);
249 GNUNET_SCHEDULER_add_now (&end, NULL);
250 return;
251 }
252
253 stage ++;
254 GNUNET_ATS_suggest_address_cancel (sched_ats, &p[1].id);
255 GNUNET_SCHEDULER_add_now (&end, NULL);
256
257 return;
258 }
259}
260
261static void
262sleep_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
263{
264 GNUNET_ATS_suggest_address (sched_ats, &p[0].id);
265}
266
267static void
268run (void *cls,
269 const struct GNUNET_CONFIGURATION_Handle *cfg,
270 struct GNUNET_TESTING_Peer *peer)
271{
272 char *quota_str;
273
274 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_OUT", &quota_str))
275 {
276 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
277 ret = 1;
278 return;
279 }
280 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_out))
281 {
282 fprintf (stderr, "Cannot load WAN outbound quota from configuration, exit!\n");
283 ret = 1;
284 GNUNET_free (quota_str);
285 return;
286 }
287 GNUNET_free (quota_str);
288 quota_str = NULL;
289
290 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string(cfg, "ats", "WAN_QUOTA_IN", &quota_str))
291 {
292 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
293 ret = 1;
294 return;
295 }
296 if (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_str, &wan_quota_in))
297 {
298 fprintf (stderr, "Cannot load WAN inbound quota from configuration, exit!\n");
299 GNUNET_free (quota_str);
300 ret = 1;
301 return;
302 }
303 GNUNET_free (quota_str);
304 quota_str = NULL;
305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN inbound quota: %llu\n", wan_quota_in);
306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Configured WAN outbound quota: %llu\n", wan_quota_out);
307
308
309 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
310
311 /* Connect to ATS scheduling */
312 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
313 if (sched_ats == NULL)
314 {
315 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
316 ret = 1;
317 end ();
318 return;
319 }
320
321 perf_ats = GNUNET_ATS_performance_init (cfg, NULL, NULL);
322 if (perf_ats == NULL)
323 {
324 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS performance!\n");
325 ret = 1;
326 end ();
327 return;
328 }
329
330 /* Set up peer 0 */
331 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p[0].id.hashPubKey))
332 {
333 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
334 ret = GNUNET_SYSERR;
335 end ();
336 return;
337 }
338
339 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p[0].id)));
340
341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
342 GNUNET_i2s(&p[0].id));
343
344
345 /* Set up peer 0 */
346 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID1, &p[1].id.hashPubKey))
347 {
348 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
349 ret = GNUNET_SYSERR;
350 end ();
351 return;
352 }
353
354 GNUNET_assert (0 == strcmp (PEERID1, GNUNET_i2s_full (&p[1].id)));
355
356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
357 GNUNET_i2s(&p[1].id));
358
359 /* Prepare ATS Information */
360 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
361 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
362 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
363 test_ats_info[1].value = htonl(1);
364 test_ats_count = 2;
365
366 /* Adding address with session */
367 test_session[0] = &test_addr[0];
368 create_test_address (&test_addr[0], "test0", test_session[0], "test0", strlen ("test0") + 1);
369 test_hello_address[0].peer = p[0].id;
370 test_hello_address[0].transport_name = test_addr[0].plugin;
371 test_hello_address[0].address = test_addr[0].addr;
372 test_hello_address[0].address_length = test_addr[0].addr_len;
373 GNUNET_ATS_address_add (sched_ats, &test_hello_address[0], test_session[0], test_ats_info, test_ats_count);
374
375
376 /* Adding address with session */
377 test_session[1] = &test_addr[1];
378 create_test_address (&test_addr[1], "test1", test_session[1], "test1", strlen ("test1") + 1);
379 test_hello_address[1].peer = p[1].id;
380 test_hello_address[1].transport_name = test_addr[0].plugin;
381 test_hello_address[1].address = test_addr[0].addr;
382 test_hello_address[1].address_length = test_addr[0].addr_len;
383 GNUNET_ATS_address_add (sched_ats, &test_hello_address[1], test_session[1], test_ats_info, test_ats_count);
384
385
386 /* Change bandwidth preference */
387 GNUNET_ATS_performance_change_preference (perf_ats,
388 &p[0].id,
389 GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
390 GNUNET_ATS_performance_change_preference (perf_ats,
391 &p[1].id,
392 GNUNET_ATS_PREFERENCE_BANDWIDTH,(double) 1000, GNUNET_ATS_PREFERENCE_END);
393
394
395 /* Change latency preference */
396
397 GNUNET_ATS_performance_change_preference (perf_ats,
398 &p[0].id,
399 GNUNET_ATS_PREFERENCE_LATENCY,(double) 10, GNUNET_ATS_PREFERENCE_END);
400 GNUNET_ATS_performance_change_preference (perf_ats,
401 &p[1].id,
402 GNUNET_ATS_PREFERENCE_LATENCY,(double) 100, GNUNET_ATS_PREFERENCE_END);
403 GNUNET_SCHEDULER_add_delayed (SLEEP, &sleep_task, NULL);
404}
405
406
407int
408main (int argc, char *argv[])
409{
410 if (0 != GNUNET_TESTING_peer_run ("test_ats_simplistic_change_preference",
411 "test_ats_api.conf",
412 &run, NULL))
413 return 1;
414 return ret;
415}
416
417
418/* end of file test_ats_simplistic_change_preference.c */
diff --git a/src/ats/test_ats_simplistic_switch_networks.c b/src/ats/test_ats_simplistic_switch_networks.c
deleted file mode 100644
index 53df468a0..000000000
--- a/src/ats/test_ats_simplistic_switch_networks.c
+++ /dev/null
@@ -1,371 +0,0 @@
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_scheduling_update_address.c
22 * @brief test updating networtk type of an address
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#include "test_ats_api_common.h"
31
32#define BIG_M_STRING "unlimited"
33
34
35static GNUNET_SCHEDULER_TaskIdentifier die_task;
36
37/**
38 * Scheduling handle
39 */
40static struct GNUNET_ATS_SchedulingHandle *sched_ats;
41
42/**
43 * Return value
44 */
45static int ret;
46
47/**
48 * Test address
49 */
50static struct Test_Address test_addr;
51
52/**
53 * Test peer
54 */
55static struct PeerContext p;
56
57/**
58 * HELLO test address
59 */
60
61struct GNUNET_HELLO_Address test_hello_address;
62
63/**
64 * Test session
65 */
66static void *test_session;
67
68/**
69 * Test ats info
70 */
71struct GNUNET_ATS_Information test_ats_info[3];
72
73/**
74 * Test ats count
75 */
76uint32_t test_ats_count;
77
78unsigned long long int quota_out[GNUNET_ATS_NetworkTypeCount];
79unsigned long long int quota_in[GNUNET_ATS_NetworkTypeCount];
80
81static void
82end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
83{
84 die_task = GNUNET_SCHEDULER_NO_TASK;
85
86 if (sched_ats != NULL)
87 GNUNET_ATS_scheduling_done (sched_ats);
88 free_test_address (&test_addr);
89 ret = GNUNET_SYSERR;
90}
91
92
93static void
94end ()
95{
96 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n");
97 if (die_task != GNUNET_SCHEDULER_NO_TASK)
98 {
99 GNUNET_SCHEDULER_cancel (die_task);
100 die_task = GNUNET_SCHEDULER_NO_TASK;
101 }
102 GNUNET_ATS_scheduling_done (sched_ats);
103 sched_ats = NULL;
104 free_test_address (&test_addr);
105}
106
107static uint32_t
108find_ats_value (const struct GNUNET_ATS_Information *atsi,
109 uint32_t ats_count,
110 uint32_t value)
111{
112 int c;
113 for (c = 0; c < ats_count; c ++)
114 {
115 if (ntohl(atsi[c].type) == value)
116 return ntohl (atsi[c].value);
117 }
118 GNUNET_break (0);
119 return UINT32_MAX;
120}
121
122
123static void
124address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
125 struct Session *session,
126 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
127 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
128 const struct GNUNET_ATS_Information *atsi,
129 uint32_t ats_count)
130{
131 static int stage = 0;
132 int level;
133 char *text;
134 if (0 == stage)
135 {
136 //GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
137 if (GNUNET_OK == compare_addresses(address, session, &test_hello_address, test_session))
138 {
139 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback for correct address `%s'\n",
140 stage, GNUNET_i2s (&address->peer));
141 ret = 0;
142 }
143 else
144 {
145 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect address `%s'\n",
146 stage, GNUNET_i2s (&address->peer));
147 ret = 1;
148 GNUNET_SCHEDULER_add_now (&end, NULL);
149 return;
150 }
151
152 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
153 {
154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n", stage);
155 ret = 1;
156 GNUNET_SCHEDULER_add_now (&end, NULL);
157 return;
158 }
159
160 if (ntohl(bandwidth_out.value__) == quota_out[GNUNET_ATS_NET_WAN])
161 {
162 level = GNUNET_ERROR_TYPE_DEBUG;
163 text = "correct";
164 ret = 0;
165 }
166 else
167 {
168 level = GNUNET_ERROR_TYPE_ERROR;
169 text = "wrong";
170 ret = 1;
171 }
172
173 GNUNET_log (level, "Stage %u: WAN outbound quota out %s: Received %llu, configured %llu\n",
174 stage,
175 text,
176 (unsigned long long int) ntohl(bandwidth_out.value__),
177 quota_out[GNUNET_ATS_NET_WAN]);
178
179 if (ntohl(bandwidth_in.value__) == quota_in[GNUNET_ATS_NET_WAN])
180 {
181 level = GNUNET_ERROR_TYPE_DEBUG;
182 text = "correct";
183 ret = 0;
184 }
185 else
186 {
187 level = GNUNET_ERROR_TYPE_ERROR;
188 text = "wrong";
189 ret = 1;
190 }
191
192 GNUNET_log (level, "Stage %u: WAN inbound quota out %s: Received %llu, configured %llu\n",
193 stage,
194 text,
195 (unsigned long long int) ntohl(bandwidth_out.value__),
196 quota_out[GNUNET_ATS_NET_WAN]);
197
198 if (GNUNET_ATS_NET_WAN != find_ats_value (atsi, ats_count, GNUNET_ATS_NETWORK_TYPE))
199 {
200 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Incorrect network type, exptected %s, got %s \n",
201 stage,
202 GNUNET_ATS_print_network_type(GNUNET_ATS_NET_WAN),
203 GNUNET_ATS_print_network_type(find_ats_value (atsi, ats_count, GNUNET_ATS_NETWORK_TYPE)));
204 ret = 1;
205 }
206
207 if (1 == ret)
208 {
209 GNUNET_SCHEDULER_add_now (&end, NULL);
210 return;
211 }
212
213 /* Update address */
214 /* Prepare ATS Information: change network */
215 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
216 test_ats_info[0].value = htonl(GNUNET_ATS_NET_LAN);
217 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
218 test_ats_info[1].value = htonl(3);
219 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
220 test_ats_info[1].value = htonl(30);
221 test_ats_count = 2;
222
223 GNUNET_ATS_address_update (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
224
225 /* Request address */
226 GNUNET_ATS_suggest_address (sched_ats, &p.id);
227 stage ++;
228 }
229 else if (1 == stage)
230 {
231 GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id);
232 if (GNUNET_OK == compare_addresses(address, session, &test_hello_address, test_session))
233 {
234 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", stage,
235 GNUNET_i2s (&address->peer));
236 ret = 0;
237 }
238 else
239 {
240 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect address `%s'\n", stage,
241 GNUNET_i2s (&address->peer));
242 ret = 1;
243 }
244
245 if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count))
246 {
247 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n");
248 ret = 1;
249 GNUNET_SCHEDULER_add_now (&end, NULL);
250 return;
251 }
252
253 if (ntohl(bandwidth_out.value__) == quota_out[GNUNET_ATS_NET_LAN])
254 {
255 level = GNUNET_ERROR_TYPE_DEBUG;
256 text = "correct";
257 ret = 0;
258 }
259 else
260 {
261 level = GNUNET_ERROR_TYPE_ERROR;
262 text = "wrong";
263 ret = 1;
264 }
265
266 GNUNET_log (level, "Stage %u: LAN outbound quota out %s: Received %llu, configured %llu\n",
267 stage,
268 text,
269 (unsigned long long int) ntohl(bandwidth_out.value__),
270 quota_out[GNUNET_ATS_NET_LAN]);
271
272 if (ntohl(bandwidth_in.value__) == quota_in[GNUNET_ATS_NET_LAN])
273 {
274 level = GNUNET_ERROR_TYPE_DEBUG;
275 text = "correct";
276 ret = 0;
277 }
278 else
279 {
280 level = GNUNET_ERROR_TYPE_ERROR;
281 text = "wrong";
282 ret = 1;
283 }
284
285 GNUNET_log (level, "Stage %u: LAN inbound quota out %s: Received %llu, configured %llu\n",
286 stage,
287 text,
288 (unsigned long long int) ntohl(bandwidth_out.value__),
289 quota_out[GNUNET_ATS_NET_LAN]);
290
291 if (GNUNET_ATS_NET_LAN != find_ats_value (atsi, ats_count, GNUNET_ATS_NETWORK_TYPE))
292 {
293 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Incorrect network type, exptected %s, got %s \n",
294 stage,
295 GNUNET_ATS_print_network_type(GNUNET_ATS_NET_LAN),
296 GNUNET_ATS_print_network_type(find_ats_value (atsi, ats_count, GNUNET_ATS_NETWORK_TYPE)));
297 ret = 1;
298 }
299
300 GNUNET_SCHEDULER_add_now (&end, NULL);
301 }
302}
303
304
305static void
306run (void *cls,
307 const struct GNUNET_CONFIGURATION_Handle *cfg,
308 struct GNUNET_TESTING_Peer *peer)
309{
310 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
311
312 load_quotas (cfg, quota_out, quota_in, GNUNET_ATS_NetworkTypeCount);
313
314 /* Connect to ATS scheduling */
315 sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL);
316 if (sched_ats == NULL)
317 {
318 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n");
319 ret = 1;
320 end ();
321 return;
322 }
323
324 /* Set up peer */
325 if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey))
326 {
327 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n");
328 ret = GNUNET_SYSERR;
329 end ();
330 return;
331 }
332
333 GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id)));
334
335 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n",
336 GNUNET_i2s_full(&p.id));
337
338 /* Prepare ATS Information */
339 test_ats_info[0].type = htonl (GNUNET_ATS_NETWORK_TYPE);
340 test_ats_info[0].value = htonl(GNUNET_ATS_NET_WAN);
341 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE);
342 test_ats_info[1].value = htonl(1);
343 test_ats_info[1].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY);
344 test_ats_info[1].value = htonl(10);
345 test_ats_count = 2;
346
347 /* Adding address without session */
348 test_session = &test_addr;
349 create_test_address (&test_addr, "test", &test_addr, "test", strlen ("test") + 1);
350 test_hello_address.peer = p.id;
351 test_hello_address.transport_name = test_addr.plugin;
352 test_hello_address.address = test_addr.addr;
353 test_hello_address.address_length = test_addr.addr_len;
354 GNUNET_ATS_address_add (sched_ats, &test_hello_address, test_session, test_ats_info, test_ats_count);
355
356 /* Request address */
357 GNUNET_ATS_suggest_address (sched_ats, &p.id);
358}
359
360
361int
362main (int argc, char *argv[])
363{
364 if (0 != GNUNET_TESTING_peer_run ("test_ats_api_scheduling_update_address",
365 "test_ats_api.conf",
366 &run, NULL))
367 return 1;
368 return ret;
369}
370
371/* end of file test_ats_api_scheduling_update_address.c */