diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-28 06:47:51 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-28 06:47:51 +0000 |
commit | a7649a53a34e0d61f6e460be90a4ec5e10bdabc3 (patch) | |
tree | 871aa7a32b3237eed97730fdc699abefdc4a88f1 | |
parent | ecc8bf638aae207dc1686f77843a2a6126b5df0b (diff) | |
download | gnunet-a7649a53a34e0d61f6e460be90a4ec5e10bdabc3.tar.gz gnunet-a7649a53a34e0d61f6e460be90a4ec5e10bdabc3.zip |
testcase with one peer is passing
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_learning.c | 122 |
1 files changed, 94 insertions, 28 deletions
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index 64fd062dc..cd22226f1 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "gnunet_resolver_service.h" | 30 | #include "gnunet_resolver_service.h" |
31 | #include "gnunet_statistics_service.h" | 31 | #include "gnunet_statistics_service.h" |
32 | 32 | ||
33 | #define VERBOSE GNUNET_NO | 33 | #define VERBOSE GNUNET_YES |
34 | 34 | ||
35 | #define START_ARM GNUNET_YES | 35 | #define START_ARM GNUNET_YES |
36 | #define MAX_URL_LEN 1000 | 36 | #define MAX_URL_LEN 1000 |
@@ -42,10 +42,15 @@ | |||
42 | #define CHECK_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) | 42 | #define CHECK_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1) |
43 | 43 | ||
44 | static int timeout; | 44 | static int timeout; |
45 | static int adv_arrived; | ||
46 | static int adv_sent; | 45 | static int adv_sent; |
47 | static int learned_hostlist_saved; | 46 | |
48 | static int learned_hostlist_downloaded; | 47 | static int adv_arrived_p1; |
48 | static int learned_hostlist_saved_p1; | ||
49 | static int learned_hostlist_downloaded_p1; | ||
50 | |||
51 | static int adv_arrived_p2; | ||
52 | static int learned_hostlist_saved_p2; | ||
53 | static int learned_hostlist_downloaded_p2; | ||
49 | 54 | ||
50 | static char * current_adv_uri; | 55 | static char * current_adv_uri; |
51 | 56 | ||
@@ -139,11 +144,12 @@ static void shutdown_testcase() | |||
139 | GNUNET_TRANSPORT_disconnect (learn_peer.th); | 144 | GNUNET_TRANSPORT_disconnect (learn_peer.th); |
140 | learn_peer.th = NULL; | 145 | learn_peer.th = NULL; |
141 | } | 146 | } |
147 | /* | ||
142 | if (learn_peer2.th != NULL) | 148 | if (learn_peer2.th != NULL) |
143 | { | 149 | { |
144 | GNUNET_TRANSPORT_disconnect (learn_peer2.th); | 150 | GNUNET_TRANSPORT_disconnect (learn_peer2.th); |
145 | learn_peer2.th = NULL; | 151 | learn_peer2.th = NULL; |
146 | } | 152 | }*/ |
147 | if (adv_peer.core != NULL) | 153 | if (adv_peer.core != NULL) |
148 | { | 154 | { |
149 | GNUNET_CORE_disconnect (adv_peer.core); | 155 | GNUNET_CORE_disconnect (adv_peer.core); |
@@ -154,19 +160,20 @@ static void shutdown_testcase() | |||
154 | GNUNET_CORE_disconnect (learn_peer.core); | 160 | GNUNET_CORE_disconnect (learn_peer.core); |
155 | learn_peer.core = NULL; | 161 | learn_peer.core = NULL; |
156 | } | 162 | } |
163 | /* | ||
157 | if (learn_peer2.core != NULL) | 164 | if (learn_peer2.core != NULL) |
158 | { | 165 | { |
159 | GNUNET_CORE_disconnect (learn_peer2.core); | 166 | GNUNET_CORE_disconnect (learn_peer2.core); |
160 | learn_peer2.core = NULL; | 167 | learn_peer2.core = NULL; |
161 | } | 168 | }*/ |
162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 169 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
163 | "Asking ARM to stop core services\n"); | 170 | "Asking ARM to stop core services\n"); |
164 | learn_peer.arm = GNUNET_ARM_connect (learn_peer.cfg, sched, NULL); | 171 | learn_peer.arm = GNUNET_ARM_connect (learn_peer.cfg, sched, NULL); |
165 | GNUNET_ARM_stop_service (learn_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, | 172 | GNUNET_ARM_stop_service (learn_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, |
166 | &stop_cb, &learn_peer); | 173 | &stop_cb, &learn_peer); |
167 | learn_peer2.arm = GNUNET_ARM_connect (learn_peer2.cfg, sched, NULL); | 174 | /* learn_peer2.arm = GNUNET_ARM_connect (learn_peer2.cfg, sched, NULL); |
168 | GNUNET_ARM_stop_service (learn_peer2.arm, "core", GNUNET_TIME_UNIT_SECONDS, | 175 | GNUNET_ARM_stop_service (learn_peer2.arm, "core", GNUNET_TIME_UNIT_SECONDS, |
169 | &stop_cb, &learn_peer2); | 176 | &stop_cb, &learn_peer2);*/ |
170 | adv_peer.arm = GNUNET_ARM_connect (adv_peer.cfg, sched, NULL); | 177 | adv_peer.arm = GNUNET_ARM_connect (adv_peer.cfg, sched, NULL); |
171 | GNUNET_ARM_stop_service (adv_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, | 178 | GNUNET_ARM_stop_service (adv_peer.arm, "core", GNUNET_TIME_UNIT_SECONDS, |
172 | &stop_cb, &adv_peer); | 179 | &stop_cb, &adv_peer); |
@@ -194,13 +201,22 @@ process_downloads (void *cls, | |||
194 | uint64_t value, | 201 | uint64_t value, |
195 | int is_persistent) | 202 | int is_persistent) |
196 | { | 203 | { |
197 | if ( (value == 2) && (learned_hostlist_downloaded == GNUNET_NO) ) | 204 | |
205 | |||
206 | if ( ((struct PeerContext *) cls == &learn_peer) && (value == 2) && (learned_hostlist_downloaded_p1 == GNUNET_NO) ) | ||
198 | { | 207 | { |
199 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 208 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
200 | _("Client has successfully downloaded advertised URI \n")); | 209 | _("Peer1 has successfully downloaded advertised URI \n")); |
201 | learned_hostlist_downloaded = GNUNET_YES; | 210 | learned_hostlist_downloaded_p1 = GNUNET_YES; |
202 | } | 211 | } |
203 | if ( GNUNET_NO != learned_hostlist_downloaded ) | 212 | /* |
213 | if ( ((struct PeerContext *) cls == &learn_peer2) && (value == 2) && (learned_hostlist_downloaded_p2 == GNUNET_NO) ) | ||
214 | { | ||
215 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
216 | _("Peer2 has successfully downloaded advertised URI \n")); | ||
217 | learned_hostlist_downloaded_p2 = GNUNET_YES; | ||
218 | }*/ | ||
219 | if ( (GNUNET_NO != learned_hostlist_downloaded_p1) /*&& (GNUNET_NO != learned_hostlist_downloaded_p2)*/ ) | ||
204 | shutdown_testcase(); | 220 | shutdown_testcase(); |
205 | return GNUNET_OK; | 221 | return GNUNET_OK; |
206 | } | 222 | } |
@@ -212,12 +228,19 @@ process_uris_recv (void *cls, | |||
212 | uint64_t value, | 228 | uint64_t value, |
213 | int is_persistent) | 229 | int is_persistent) |
214 | { | 230 | { |
215 | if ( (value == 1) && (learned_hostlist_saved == GNUNET_NO)) | 231 | if ( ((struct PeerContext *) cls == &learn_peer) && (value == 1) && (learned_hostlist_saved_p1 == GNUNET_NO)) |
216 | { | 232 | { |
217 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
218 | _("Client has successfully saved advertised URI \n")); | 234 | _("Peer1 has successfully saved advertised URI \n")); |
219 | learned_hostlist_saved = GNUNET_YES; | 235 | learned_hostlist_saved_p1 = GNUNET_YES; |
220 | } | 236 | } |
237 | /* | ||
238 | if ( ((struct PeerContext *) cls == &learn_peer2) && (value == 1) && (learned_hostlist_saved_p2 == GNUNET_NO)) | ||
239 | { | ||
240 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
241 | _("Peer2 has successfully saved advertised URI \n")); | ||
242 | learned_hostlist_saved_p2 = GNUNET_YES; | ||
243 | }*/ | ||
221 | return GNUNET_OK; | 244 | return GNUNET_OK; |
222 | } | 245 | } |
223 | 246 | ||
@@ -228,7 +251,7 @@ process_adv_sent (void *cls, | |||
228 | uint64_t value, | 251 | uint64_t value, |
229 | int is_persistent) | 252 | int is_persistent) |
230 | { | 253 | { |
231 | if ( (value == 1) && (adv_sent == GNUNET_NO)) | 254 | if ( (value >= 1) && (adv_sent == GNUNET_NO)) |
232 | { | 255 | { |
233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 256 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
234 | _("Server has successfully sent advertisement\n")); | 257 | _("Server has successfully sent advertisement\n")); |
@@ -254,15 +277,30 @@ check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
254 | GNUNET_TIME_UNIT_MINUTES, | 277 | GNUNET_TIME_UNIT_MINUTES, |
255 | NULL, | 278 | NULL, |
256 | &process_downloads, | 279 | &process_downloads, |
257 | NULL); | 280 | &learn_peer); |
281 | /*GNUNET_STATISTICS_get (learn_peer2.stats, | ||
282 | "hostlist", | ||
283 | stat, | ||
284 | GNUNET_TIME_UNIT_MINUTES, | ||
285 | NULL, | ||
286 | &process_downloads, | ||
287 | &learn_peer2);*/ | ||
258 | GNUNET_free (stat); | 288 | GNUNET_free (stat); |
289 | |||
259 | GNUNET_STATISTICS_get (learn_peer.stats, | 290 | GNUNET_STATISTICS_get (learn_peer.stats, |
260 | "hostlist", | 291 | "hostlist", |
261 | gettext_noop("# advertised hostlist URIs"), | 292 | gettext_noop("# advertised hostlist URIs"), |
262 | GNUNET_TIME_UNIT_MINUTES, | 293 | GNUNET_TIME_UNIT_MINUTES, |
263 | NULL, | 294 | NULL, |
264 | &process_uris_recv, | 295 | &process_uris_recv, |
265 | NULL); | 296 | &learn_peer); |
297 | /*GNUNET_STATISTICS_get (learn_peer2.stats, | ||
298 | "hostlist", | ||
299 | gettext_noop("# advertised hostlist URIs"), | ||
300 | GNUNET_TIME_UNIT_MINUTES, | ||
301 | NULL, | ||
302 | &process_uris_recv, | ||
303 | &learn_peer2);*/ | ||
266 | GNUNET_STATISTICS_get (adv_peer.stats, | 304 | GNUNET_STATISTICS_get (adv_peer.stats, |
267 | "hostlist", | 305 | "hostlist", |
268 | gettext_noop("# hostlist advertisements send"), | 306 | gettext_noop("# hostlist advertisements send"), |
@@ -325,7 +363,8 @@ static int ad_arrive_handler (void *cls, | |||
325 | { | 363 | { |
326 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 364 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
327 | "Recieved hostlist advertisement with URI `%s' as expected\n", current_adv_uri); | 365 | "Recieved hostlist advertisement with URI `%s' as expected\n", current_adv_uri); |
328 | adv_arrived = GNUNET_YES; | 366 | adv_arrived_p1 = GNUNET_YES; |
367 | adv_arrived_p2 = GNUNET_YES; | ||
329 | } | 368 | } |
330 | else | 369 | else |
331 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 370 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -415,9 +454,16 @@ run (void *cls, | |||
415 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 454 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
416 | { | 455 | { |
417 | timeout = GNUNET_NO; | 456 | timeout = GNUNET_NO; |
418 | adv_arrived = GNUNET_NO; | ||
419 | adv_sent =GNUNET_NO; | 457 | adv_sent =GNUNET_NO; |
420 | learned_hostlist_downloaded = GNUNET_NO; | 458 | |
459 | adv_arrived_p1 = GNUNET_NO; | ||
460 | learned_hostlist_downloaded_p1 = GNUNET_NO; | ||
461 | learned_hostlist_saved_p1 = GNUNET_NO; | ||
462 | |||
463 | /*adv_arrived_p2 = GNUNET_NO; | ||
464 | learned_hostlist_downloaded_p2 = GNUNET_NO; | ||
465 | learned_hostlist_saved_p2 = GNUNET_NO;*/ | ||
466 | |||
421 | sched = s; | 467 | sched = s; |
422 | timeout_task = GNUNET_SCHEDULER_add_delayed (sched, | 468 | timeout_task = GNUNET_SCHEDULER_add_delayed (sched, |
423 | TIMEOUT, | 469 | TIMEOUT, |
@@ -430,7 +476,7 @@ run (void *cls, | |||
430 | 476 | ||
431 | setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); | 477 | setup_adv_peer (&adv_peer, "test_learning_adv_peer.conf"); |
432 | setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); | 478 | setup_learn_peer (&learn_peer, "test_learning_learn_peer.conf"); |
433 | setup_learn_peer (&learn_peer2, "test_learning_learn_peer2.conf"); | 479 | // setup_learn_peer (&learn_peer2, "test_learning_learn_peer2.conf"); |
434 | 480 | ||
435 | } | 481 | } |
436 | 482 | ||
@@ -462,24 +508,44 @@ check () | |||
462 | "Testcase could not set up two communicating peers, timeout\n"); | 508 | "Testcase could not set up two communicating peers, timeout\n"); |
463 | failed = GNUNET_YES; | 509 | failed = GNUNET_YES; |
464 | } | 510 | } |
465 | if (adv_arrived == GNUNET_NO) | 511 | if (adv_arrived_p1 == GNUNET_NO) |
466 | { | 512 | { |
467 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 513 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
468 | "Learning peer did not recieve advertisement from server\n"); | 514 | "Peer1: Learning peer did not recieve advertisement from server\n"); |
469 | failed = GNUNET_YES; | 515 | failed = GNUNET_YES; |
470 | } | 516 | } |
471 | if ( learned_hostlist_saved == GNUNET_NO ) | 517 | if ( learned_hostlist_saved_p1 == GNUNET_NO ) |
472 | { | 518 | { |
473 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 519 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
474 | "Advertised hostlist was not saved in datastore\n"); | 520 | "Peer1: Advertised hostlist was not saved in datastore\n"); |
475 | failed = GNUNET_YES; | 521 | failed = GNUNET_YES; |
476 | } | 522 | } |
477 | if (learned_hostlist_downloaded == GNUNET_NO) | 523 | if (learned_hostlist_downloaded_p1 == GNUNET_NO) |
478 | { | 524 | { |
479 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 525 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
480 | "Advertised hostlist could not be downloaded from server\n"); | 526 | "Peer1: Advertised hostlist could not be downloaded from server\n"); |
481 | failed = GNUNET_YES; | 527 | failed = GNUNET_YES; |
482 | } | 528 | } |
529 | /* | ||
530 | if (adv_arrived_p2 == GNUNET_NO) | ||
531 | { | ||
532 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
533 | "Peer2: Learning peer did not recieve advertisement from server\n"); | ||
534 | failed = GNUNET_YES; | ||
535 | } | ||
536 | if ( learned_hostlist_saved_p2 == GNUNET_NO ) | ||
537 | { | ||
538 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
539 | "Peer2: Advertised hostlist was not saved in datastore\n"); | ||
540 | failed = GNUNET_YES; | ||
541 | } | ||
542 | if (learned_hostlist_downloaded_p2 == GNUNET_NO) | ||
543 | { | ||
544 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
545 | "Peer2: Advertised hostlist could not be downloaded from server\n"); | ||
546 | failed = GNUNET_YES; | ||
547 | }*/ | ||
548 | |||
483 | if (adv_sent == GNUNET_NO) | 549 | if (adv_sent == GNUNET_NO) |
484 | { | 550 | { |
485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 551 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |