aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-01-23 10:10:57 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-01-23 10:10:57 +0000
commit27ebda5ab80f37b3c619ae71c07e74205ad577d3 (patch)
tree9947265a59a233dabf6cf7dc05b2e7f48e2c5285 /src
parent737087afe30838bc1ab2604548f13749145edcab (diff)
downloadgnunet-27ebda5ab80f37b3c619ae71c07e74205ad577d3.tar.gz
gnunet-27ebda5ab80f37b3c619ae71c07e74205ad577d3.zip
test
Diffstat (limited to 'src')
-rw-r--r--src/ats/test_ats_simplistic_pref_aging.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/ats/test_ats_simplistic_pref_aging.c b/src/ats/test_ats_simplistic_pref_aging.c
index 9eb896ff5..8591ef13e 100644
--- a/src/ats/test_ats_simplistic_pref_aging.c
+++ b/src/ats/test_ats_simplistic_pref_aging.c
@@ -169,7 +169,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
169 /* Callback for initial suggestion */ 169 /* Callback for initial suggestion */
170 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) 170 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
171 { 171 {
172 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n", 172 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
173 stage, 173 stage,
174 GNUNET_i2s (&address->peer), 174 GNUNET_i2s (&address->peer),
175 ntohl (bandwidth_in.value__), 175 ntohl (bandwidth_in.value__),
@@ -180,7 +180,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
180 } 180 }
181 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) 181 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
182 { 182 {
183 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n", 183 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
184 stage, 184 stage,
185 GNUNET_i2s (&address->peer), 185 GNUNET_i2s (&address->peer),
186 ntohl (bandwidth_in.value__), 186 ntohl (bandwidth_in.value__),
@@ -205,7 +205,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
205 /* Callback due to preference change */ 205 /* Callback due to preference change */
206 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) 206 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
207 { 207 {
208 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n", 208 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
209 stage, 209 stage,
210 GNUNET_i2s (&address->peer), 210 GNUNET_i2s (&address->peer),
211 ntohl (bandwidth_in.value__), 211 ntohl (bandwidth_in.value__),
@@ -222,7 +222,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
222 } 222 }
223 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) 223 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
224 { 224 {
225 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n", 225 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
226 stage, 226 stage,
227 GNUNET_i2s (&address->peer), 227 GNUNET_i2s (&address->peer),
228 ntohl (bandwidth_in.value__), 228 ntohl (bandwidth_in.value__),
@@ -231,9 +231,15 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
231 231
232 /* Peer 1 should get less bandwidth */ 232 /* Peer 1 should get less bandwidth */
233 if (cur_bandwidth_out >= p1_last_bandwidth_out) 233 if (cur_bandwidth_out >= p1_last_bandwidth_out)
234 {
234 GNUNET_break (0); 235 GNUNET_break (0);
236 goto error;
237 }
235 if (cur_bandwidth_in >= p1_last_bandwidth_in) 238 if (cur_bandwidth_in >= p1_last_bandwidth_in)
239 {
236 GNUNET_break (0); 240 GNUNET_break (0);
241 goto error;
242 }
237 p1_last_bandwidth_out = ntohl(bandwidth_out.value__); 243 p1_last_bandwidth_out = ntohl(bandwidth_out.value__);
238 p1_last_bandwidth_in = ntohl(bandwidth_in.value__); 244 p1_last_bandwidth_in = ntohl(bandwidth_in.value__);
239 } 245 }
@@ -250,7 +256,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
250 /* Callback due to preference aging */ 256 /* Callback due to preference aging */
251 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id))) 257 if (0 == memcmp (&address->peer, &p[0].id, sizeof (p[0].id)))
252 { 258 {
253 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n", 259 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 0 `%s': (in/out) %llu/%llu\n",
254 stage, 260 stage,
255 GNUNET_i2s (&address->peer), 261 GNUNET_i2s (&address->peer),
256 ntohl (bandwidth_in.value__), 262 ntohl (bandwidth_in.value__),
@@ -267,7 +273,7 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
267 } 273 }
268 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id))) 274 if (0 == memcmp (&address->peer, &p[1].id, sizeof (p[1].id)))
269 { 275 {
270 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n", 276 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Callback for peer 1 `%s': (in/out) %llu/%llu\n",
271 stage, 277 stage,
272 GNUNET_i2s (&address->peer), 278 GNUNET_i2s (&address->peer),
273 ntohl (bandwidth_in.value__), 279 ntohl (bandwidth_in.value__),
@@ -275,17 +281,34 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
275 sug_p1 = GNUNET_YES; 281 sug_p1 = GNUNET_YES;
276 /* Peer 1 should get more bandwidth */ 282 /* Peer 1 should get more bandwidth */
277 if (cur_bandwidth_out <= p1_last_bandwidth_out) 283 if (cur_bandwidth_out <= p1_last_bandwidth_out)
284 {
278 GNUNET_break (0); 285 GNUNET_break (0);
286 goto error;
287 }
279 if (cur_bandwidth_in <= p1_last_bandwidth_in) 288 if (cur_bandwidth_in <= p1_last_bandwidth_in)
289 {
280 GNUNET_break (0); 290 GNUNET_break (0);
291 goto error;
292 }
281 p0_last_bandwidth_out = ntohl(bandwidth_out.value__); 293 p0_last_bandwidth_out = ntohl(bandwidth_out.value__);
282 p0_last_bandwidth_in = ntohl(bandwidth_in.value__); 294 p0_last_bandwidth_in = ntohl(bandwidth_in.value__);
283 } 295 }
284 296
285 /* Done ! */ 297 if ((GNUNET_YES == sug_p0) && (GNUNET_YES == sug_p1))
286 GNUNET_SCHEDULER_add_now (&end,NULL); 298 {
287 return; 299 /* Done ! */
300 stage ++;
301 ret = 0;
302 GNUNET_SCHEDULER_add_now (&end,NULL);
303 return;
304 }
288 } 305 }
306 return;
307
308error:
309 /* Error ! */
310 ret = 1;
311 GNUNET_SCHEDULER_add_now (&end,NULL);
289} 312}
290 313
291static void 314static void