diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 13:02:52 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-16 13:02:52 +0000 |
commit | b0685d4301b6ddf5d95e5467add39a23b51aa5a1 (patch) | |
tree | a9808ba0b435e871f1b85ac4e7006895979e9d8b /src/testing/test_testing_topology.c | |
parent | 7f082ef1cd69b48984b05ae72f3c124493fdd86e (diff) | |
download | gnunet-b0685d4301b6ddf5d95e5467add39a23b51aa5a1.tar.gz gnunet-b0685d4301b6ddf5d95e5467add39a23b51aa5a1.zip |
Fix for testing where peer_start callback immediately calls peer_stop (also white space changes)
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 633 |
1 files changed, 359 insertions, 274 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 62fbc07e0..36ccad6c9 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -96,11 +96,12 @@ static unsigned int dotnum; | |||
96 | 96 | ||
97 | static enum GNUNET_TESTING_Topology topology; | 97 | static enum GNUNET_TESTING_Topology topology; |
98 | 98 | ||
99 | static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */ | 99 | static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */ |
100 | 100 | ||
101 | static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */ | 101 | static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */ |
102 | 102 | ||
103 | static enum GNUNET_TESTING_TopologyOption connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; | 103 | static enum GNUNET_TESTING_TopologyOption connect_topology_option = |
104 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL; | ||
104 | 105 | ||
105 | static double connect_topology_option_modifier = 0.0; | 106 | static double connect_topology_option_modifier = 0.0; |
106 | 107 | ||
@@ -151,14 +152,13 @@ static struct TestMessageContext *test_messages; | |||
151 | /** | 152 | /** |
152 | * Check whether peers successfully shut down. | 153 | * Check whether peers successfully shut down. |
153 | */ | 154 | */ |
154 | void shutdown_callback (void *cls, | 155 | void |
155 | const char *emsg) | 156 | shutdown_callback (void *cls, const char *emsg) |
156 | { | 157 | { |
157 | if (emsg != NULL) | 158 | if (emsg != NULL) |
158 | { | 159 | { |
159 | #if VERBOSE | 160 | #if VERBOSE |
160 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); |
161 | "Shutdown of peers failed!\n"); | ||
162 | #endif | 162 | #endif |
163 | if (ok == 0) | 163 | if (ok == 0) |
164 | ok = 666; | 164 | ok = 666; |
@@ -173,15 +173,17 @@ void shutdown_callback (void *cls, | |||
173 | } | 173 | } |
174 | 174 | ||
175 | #if DELAY_FOR_LOGGING | 175 | #if DELAY_FOR_LOGGING |
176 | static void gather_log_data () | 176 | static void |
177 | gather_log_data () | ||
177 | { | 178 | { |
178 | char *peer_number; | 179 | char *peer_number; |
179 | char *connect_number; | 180 | char *connect_number; |
180 | struct GNUNET_OS_Process *mem_process; | 181 | struct GNUNET_OS_Process *mem_process; |
181 | GNUNET_asprintf(&peer_number, "%llu", num_peers); | 182 | GNUNET_asprintf (&peer_number, "%llu", num_peers); |
182 | GNUNET_asprintf(&connect_number, "%llu", expected_connections); | 183 | GNUNET_asprintf (&connect_number, "%llu", expected_connections); |
183 | mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", | 184 | mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", |
184 | "memsize.pl", "totals.txt", peer_number, connect_number, NULL); | 185 | "memsize.pl", "totals.txt", |
186 | peer_number, connect_number, NULL); | ||
185 | GNUNET_OS_process_wait (mem_process); | 187 | GNUNET_OS_process_wait (mem_process); |
186 | GNUNET_OS_process_close (mem_process); | 188 | GNUNET_OS_process_close (mem_process); |
187 | mem_process = NULL; | 189 | mem_process = NULL; |
@@ -205,37 +207,38 @@ finish_testing () | |||
205 | { | 207 | { |
206 | if (pos->peer1handle != NULL) | 208 | if (pos->peer1handle != NULL) |
207 | { | 209 | { |
208 | GNUNET_CORE_disconnect(pos->peer1handle); | 210 | GNUNET_CORE_disconnect (pos->peer1handle); |
209 | pos->peer1handle = NULL; | 211 | pos->peer1handle = NULL; |
210 | } | 212 | } |
211 | if (pos->peer2handle != NULL) | 213 | if (pos->peer2handle != NULL) |
212 | { | 214 | { |
213 | GNUNET_CORE_disconnect(pos->peer2handle); | 215 | GNUNET_CORE_disconnect (pos->peer2handle); |
214 | pos->peer2handle = NULL; | 216 | pos->peer2handle = NULL; |
215 | } | 217 | } |
216 | free_pos = pos; | 218 | free_pos = pos; |
217 | pos = pos->next; | 219 | pos = pos->next; |
218 | if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | 220 | if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) |
219 | { | 221 | { |
220 | GNUNET_SCHEDULER_cancel(free_pos->disconnect_task); | 222 | GNUNET_SCHEDULER_cancel (free_pos->disconnect_task); |
221 | } | 223 | } |
222 | GNUNET_free(free_pos); | 224 | GNUNET_free (free_pos); |
223 | } | 225 | } |
224 | #if VERBOSE | 226 | #if VERBOSE |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 227 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
226 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); | 228 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", |
229 | transmit_ready_scheduled, transmit_ready_failed, | ||
230 | transmit_ready_called); | ||
227 | #endif | 231 | #endif |
228 | 232 | ||
229 | #if VERBOSE | 233 | #if VERBOSE |
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 234 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling daemons_stop\n"); |
231 | "Calling daemons_stop\n"); | ||
232 | #endif | 235 | #endif |
233 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 236 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
234 | 237 | ||
235 | if (dotOutFile != NULL) | 238 | if (dotOutFile != NULL) |
236 | { | 239 | { |
237 | fprintf(dotOutFile, "}"); | 240 | fprintf (dotOutFile, "}"); |
238 | fclose(dotOutFile); | 241 | fclose (dotOutFile); |
239 | } | 242 | } |
240 | 243 | ||
241 | ok = 0; | 244 | ok = 0; |
@@ -243,23 +246,25 @@ finish_testing () | |||
243 | 246 | ||
244 | 247 | ||
245 | static void | 248 | static void |
246 | disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 249 | disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
247 | { | 250 | { |
248 | struct TestMessageContext *pos = cls; | 251 | struct TestMessageContext *pos = cls; |
249 | 252 | ||
250 | /* Disconnect from the respective cores */ | 253 | /* Disconnect from the respective cores */ |
251 | #if VERBOSE > 1 | 254 | #if VERBOSE > 1 |
252 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 255 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
253 | "Disconnecting from peer 1 `%4s'\n", GNUNET_i2s (&pos->peer1->id)); | 256 | "Disconnecting from peer 1 `%4s'\n", |
257 | GNUNET_i2s (&pos->peer1->id)); | ||
254 | #endif | 258 | #endif |
255 | if (pos->peer1handle != NULL) | 259 | if (pos->peer1handle != NULL) |
256 | GNUNET_CORE_disconnect(pos->peer1handle); | 260 | GNUNET_CORE_disconnect (pos->peer1handle); |
257 | #if VERBOSE > 1 | 261 | #if VERBOSE > 1 |
258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 262 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
259 | "Disconnecting from peer 2 `%4s'\n", GNUNET_i2s (&pos->peer2->id)); | 263 | "Disconnecting from peer 2 `%4s'\n", |
264 | GNUNET_i2s (&pos->peer2->id)); | ||
260 | #endif | 265 | #endif |
261 | if (pos->peer2handle != NULL) | 266 | if (pos->peer2handle != NULL) |
262 | GNUNET_CORE_disconnect(pos->peer2handle); | 267 | GNUNET_CORE_disconnect (pos->peer2handle); |
263 | /* Set handles to NULL so test case can be ended properly */ | 268 | /* Set handles to NULL so test case can be ended properly */ |
264 | pos->peer1handle = NULL; | 269 | pos->peer1handle = NULL; |
265 | pos->peer2handle = NULL; | 270 | pos->peer2handle = NULL; |
@@ -268,7 +273,8 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
268 | total_server_connections -= 2; | 273 | total_server_connections -= 2; |
269 | } | 274 | } |
270 | 275 | ||
271 | static void stats_finished (void *cls, int result) | 276 | static void |
277 | stats_finished (void *cls, int result) | ||
272 | { | 278 | { |
273 | GNUNET_SCHEDULER_add_now (&finish_testing, NULL); | 279 | GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
274 | } | 280 | } |
@@ -284,42 +290,45 @@ static void stats_finished (void *cls, int result) | |||
284 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | 290 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not |
285 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 291 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
286 | */ | 292 | */ |
287 | static int stats_print (void *cls, | 293 | static int |
288 | const struct GNUNET_PeerIdentity *peer, | 294 | stats_print (void *cls, |
289 | const char *subsystem, | 295 | const struct GNUNET_PeerIdentity *peer, |
290 | const char *name, | 296 | const char *subsystem, |
291 | uint64_t value, | 297 | const char *name, uint64_t value, int is_persistent) |
292 | int is_persistent) | ||
293 | { | 298 | { |
294 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s:%s:%s -- %llu\n", GNUNET_i2s(peer), subsystem, name, value); | 299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s:%s -- %llu\n", |
300 | GNUNET_i2s (peer), subsystem, name, value); | ||
295 | return GNUNET_OK; | 301 | return GNUNET_OK; |
296 | } | 302 | } |
297 | 303 | ||
298 | static void topology_cb (void *cls, | 304 | static void |
299 | const struct GNUNET_PeerIdentity *first, | 305 | topology_cb (void *cls, |
300 | const struct GNUNET_PeerIdentity *second, | 306 | const struct GNUNET_PeerIdentity *first, |
301 | const char *emsg) | 307 | const struct GNUNET_PeerIdentity *second, const char *emsg) |
302 | { | 308 | { |
303 | FILE *outfile = cls; | 309 | FILE *outfile = cls; |
304 | if (first != NULL) | 310 | if (first != NULL) |
305 | { | ||
306 | if (outfile != NULL) | ||
307 | { | 311 | { |
308 | fprintf(outfile, "\t\"%s\" -- ", GNUNET_i2s(first)); | 312 | if (outfile != NULL) |
309 | fprintf(outfile, "\"%s\";\n", GNUNET_i2s(second)); | 313 | { |
314 | fprintf (outfile, "\t\"%s\" -- ", GNUNET_i2s (first)); | ||
315 | fprintf (outfile, "\"%s\";\n", GNUNET_i2s (second)); | ||
316 | } | ||
317 | topology_connections++; | ||
310 | } | 318 | } |
311 | topology_connections++; | ||
312 | } | ||
313 | else | 319 | else |
314 | { | 320 | { |
315 | fprintf(stderr, "Finished iterating over topology, %d total connections!\n", topology_connections); | 321 | fprintf (stderr, |
322 | "Finished iterating over topology, %d total connections!\n", | ||
323 | topology_connections); | ||
316 | if (outfile != NULL) | 324 | if (outfile != NULL) |
317 | { | 325 | { |
318 | fprintf(outfile, "}\n"); | 326 | fprintf (outfile, "}\n"); |
319 | fclose(outfile); | 327 | fclose (outfile); |
320 | GNUNET_TESTING_get_statistics(pg, &stats_finished, &stats_print, NULL); | 328 | GNUNET_TESTING_get_statistics (pg, &stats_finished, &stats_print, |
321 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); | 329 | NULL); |
322 | } | 330 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
331 | } | ||
323 | } | 332 | } |
324 | } | 333 | } |
325 | 334 | ||
@@ -327,68 +336,71 @@ static int | |||
327 | process_mtype (void *cls, | 336 | process_mtype (void *cls, |
328 | const struct GNUNET_PeerIdentity *peer, | 337 | const struct GNUNET_PeerIdentity *peer, |
329 | const struct GNUNET_MessageHeader *message, | 338 | const struct GNUNET_MessageHeader *message, |
330 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 339 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
331 | { | 340 | { |
332 | char *dotOutFileNameFinished; | 341 | char *dotOutFileNameFinished; |
333 | FILE *dotOutFileFinished; | 342 | FILE *dotOutFileFinished; |
334 | struct TestMessageContext *pos = cls; | 343 | struct TestMessageContext *pos = cls; |
335 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message; | 344 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message; |
336 | if (pos->uid != ntohl(msg->uid)) | 345 | if (pos->uid != ntohl (msg->uid)) |
337 | return GNUNET_OK; | 346 | return GNUNET_OK; |
338 | 347 | ||
339 | #if VERBOSE | 348 | #if VERBOSE |
340 | if ((total_messages_received) % modnum == 0) | 349 | if ((total_messages_received) % modnum == 0) |
341 | { | 350 | { |
342 | if (total_messages_received == 0) | 351 | if (total_messages_received == 0) |
343 | fprintf (stdout, "0%%"); | 352 | fprintf (stdout, "0%%"); |
344 | else | 353 | else |
345 | fprintf (stdout, "%d%%", | 354 | fprintf (stdout, "%d%%", |
346 | (int) (((float) total_messages_received / | 355 | (int) (((float) total_messages_received / |
347 | expected_messages) * 100)); | 356 | expected_messages) * 100)); |
348 | 357 | ||
349 | } | 358 | } |
350 | else if (total_messages_received % dotnum == 0) | 359 | else if (total_messages_received % dotnum == 0) |
351 | { | 360 | { |
352 | fprintf (stdout, "."); | 361 | fprintf (stdout, "."); |
353 | } | 362 | } |
354 | fflush (stdout); | 363 | fflush (stdout); |
355 | #endif | 364 | #endif |
356 | 365 | ||
357 | total_messages_received++; | 366 | total_messages_received++; |
358 | #if VERBOSE > 1 | 367 | #if VERBOSE > 1 |
359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
360 | "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), ntohs(message->type)); | 369 | "Received message from `%4s', type %d.\n", GNUNET_i2s (peer), |
370 | ntohs (message->type)); | ||
361 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 371 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
362 | "Total messages received %d, expected %d.\n", total_messages_received, expected_messages); | 372 | "Total messages received %d, expected %d.\n", |
373 | total_messages_received, expected_messages); | ||
363 | #endif | 374 | #endif |
364 | 375 | ||
365 | if (total_messages_received == expected_messages) | 376 | if (total_messages_received == expected_messages) |
366 | { | 377 | { |
367 | #if VERBOSE | 378 | #if VERBOSE |
368 | fprintf(stdout, "100%%]\n"); | 379 | fprintf (stdout, "100%%]\n"); |
369 | #endif | 380 | #endif |
370 | GNUNET_SCHEDULER_cancel (die_task); | 381 | GNUNET_SCHEDULER_cancel (die_task); |
371 | GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology"); | 382 | GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology"); |
372 | dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); | 383 | dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); |
373 | GNUNET_free(dotOutFileNameFinished); | 384 | GNUNET_free (dotOutFileNameFinished); |
374 | if (dotOutFileFinished != NULL) | 385 | if (dotOutFileFinished != NULL) |
375 | { | 386 | { |
376 | fprintf(dotOutFileFinished, "strict graph G {\n"); | 387 | fprintf (dotOutFileFinished, "strict graph G {\n"); |
377 | } | 388 | } |
378 | topology_connections = 0; | 389 | topology_connections = 0; |
379 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); | 390 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); |
380 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); | 391 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
381 | } | 392 | } |
382 | else | 393 | else |
383 | { | 394 | { |
384 | pos->disconnect_task = GNUNET_SCHEDULER_add_now(&disconnect_cores, pos); | 395 | pos->disconnect_task = |
396 | GNUNET_SCHEDULER_add_now (&disconnect_cores, pos); | ||
385 | } | 397 | } |
386 | 398 | ||
387 | return GNUNET_OK; | 399 | return GNUNET_OK; |
388 | } | 400 | } |
389 | 401 | ||
390 | static void | 402 | static void |
391 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 403 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
392 | { | 404 | { |
393 | char *msg = cls; | 405 | char *msg = cls; |
394 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 406 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -401,24 +413,27 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
401 | { | 413 | { |
402 | if (pos->peer1handle != NULL) | 414 | if (pos->peer1handle != NULL) |
403 | { | 415 | { |
404 | GNUNET_CORE_disconnect(pos->peer1handle); | 416 | GNUNET_CORE_disconnect (pos->peer1handle); |
405 | pos->peer1handle = NULL; | 417 | pos->peer1handle = NULL; |
406 | } | 418 | } |
407 | if (pos->peer2handle != NULL) | 419 | if (pos->peer2handle != NULL) |
408 | { | 420 | { |
409 | GNUNET_CORE_disconnect(pos->peer2handle); | 421 | GNUNET_CORE_disconnect (pos->peer2handle); |
410 | pos->peer2handle = NULL; | 422 | pos->peer2handle = NULL; |
411 | } | 423 | } |
412 | free_pos = pos; | 424 | free_pos = pos; |
413 | pos = pos->next; | 425 | pos = pos->next; |
414 | GNUNET_free(free_pos); | 426 | GNUNET_free (free_pos); |
415 | } | 427 | } |
416 | 428 | ||
417 | #if VERBOSE | 429 | #if VERBOSE |
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
419 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", transmit_ready_scheduled, transmit_ready_failed, transmit_ready_called); | 431 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", |
420 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 432 | transmit_ready_scheduled, transmit_ready_failed, |
421 | "Total messages received %d, expected %d.\n", total_messages_received, expected_messages); | 433 | transmit_ready_called); |
434 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
435 | "Total messages received %d, expected %d.\n", | ||
436 | total_messages_received, expected_messages); | ||
422 | #endif | 437 | #endif |
423 | 438 | ||
424 | if (pg != NULL) | 439 | if (pg != NULL) |
@@ -431,8 +446,8 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
431 | 446 | ||
432 | if (dotOutFile != NULL) | 447 | if (dotOutFile != NULL) |
433 | { | 448 | { |
434 | fprintf(dotOutFile, "}"); | 449 | fprintf (dotOutFile, "}"); |
435 | fclose(dotOutFile); | 450 | fclose (dotOutFile); |
436 | } | 451 | } |
437 | } | 452 | } |
438 | 453 | ||
@@ -446,11 +461,13 @@ transmit_ready (void *cls, size_t size, void *buf) | |||
446 | m = (struct GNUNET_TestMessage *) buf; | 461 | m = (struct GNUNET_TestMessage *) buf; |
447 | m->header.type = htons (MTYPE); | 462 | m->header.type = htons (MTYPE); |
448 | m->header.size = htons (sizeof (struct GNUNET_TestMessage)); | 463 | m->header.size = htons (sizeof (struct GNUNET_TestMessage)); |
449 | m->uid = htonl(pos->uid); | 464 | m->uid = htonl (pos->uid); |
450 | transmit_ready_called++; | 465 | transmit_ready_called++; |
451 | #if VERBOSE > 1 | 466 | #if VERBOSE > 1 |
452 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
453 | "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", GNUNET_i2s(&pos->peer1->id), transmit_ready_scheduled, transmit_ready_called); | 468 | "transmit ready for peer %s\ntransmit_ready's scheduled %d, transmit_ready's called %d\n", |
469 | GNUNET_i2s (&pos->peer1->id), transmit_ready_scheduled, | ||
470 | transmit_ready_called); | ||
454 | #endif | 471 | #endif |
455 | return sizeof (struct GNUNET_TestMessage); | 472 | return sizeof (struct GNUNET_TestMessage); |
456 | } | 473 | } |
@@ -467,9 +484,10 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { | |||
467 | 484 | ||
468 | static void | 485 | static void |
469 | init_notify_peer2 (void *cls, | 486 | init_notify_peer2 (void *cls, |
470 | struct GNUNET_CORE_Handle *server, | 487 | struct GNUNET_CORE_Handle *server, |
471 | const struct GNUNET_PeerIdentity *my_identity, | 488 | const struct GNUNET_PeerIdentity *my_identity, |
472 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 489 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
490 | *publicKey) | ||
473 | { | 491 | { |
474 | struct TestMessageContext *pos = cls; | 492 | struct TestMessageContext *pos = cls; |
475 | 493 | ||
@@ -484,7 +502,8 @@ init_notify_peer2 (void *cls, | |||
484 | 0, | 502 | 0, |
485 | TIMEOUT, | 503 | TIMEOUT, |
486 | &pos->peer2->id, | 504 | &pos->peer2->id, |
487 | sizeof (struct GNUNET_TestMessage), | 505 | sizeof (struct |
506 | GNUNET_TestMessage), | ||
488 | &transmit_ready, pos)) | 507 | &transmit_ready, pos)) |
489 | { | 508 | { |
490 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 509 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -501,9 +520,10 @@ init_notify_peer2 (void *cls, | |||
501 | 520 | ||
502 | static void | 521 | static void |
503 | init_notify_peer1 (void *cls, | 522 | init_notify_peer1 (void *cls, |
504 | struct GNUNET_CORE_Handle *server, | 523 | struct GNUNET_CORE_Handle *server, |
505 | const struct GNUNET_PeerIdentity *my_identity, | 524 | const struct GNUNET_PeerIdentity *my_identity, |
506 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 525 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
526 | *publicKey) | ||
507 | { | 527 | { |
508 | struct TestMessageContext *pos = cls; | 528 | struct TestMessageContext *pos = cls; |
509 | total_server_connections++; | 529 | total_server_connections++; |
@@ -518,19 +538,20 @@ init_notify_peer1 (void *cls, | |||
518 | * Connect to the receiving peer | 538 | * Connect to the receiving peer |
519 | */ | 539 | */ |
520 | pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, | 540 | pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, |
521 | 1, | 541 | 1, |
522 | pos, | 542 | pos, |
523 | &init_notify_peer2, | 543 | &init_notify_peer2, |
524 | NULL, | 544 | NULL, |
525 | NULL, | 545 | NULL, |
526 | NULL, NULL, | 546 | NULL, NULL, |
527 | GNUNET_YES, NULL, GNUNET_YES, handlers); | 547 | GNUNET_YES, NULL, GNUNET_YES, |
548 | handlers); | ||
528 | 549 | ||
529 | } | 550 | } |
530 | 551 | ||
531 | 552 | ||
532 | static void | 553 | static void |
533 | send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | 554 | send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
534 | { | 555 | { |
535 | struct TestMessageContext *pos = cls; | 556 | struct TestMessageContext *pos = cls; |
536 | 557 | ||
@@ -545,29 +566,32 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
545 | if (die_task == GNUNET_SCHEDULER_NO_TASK) | 566 | if (die_task == GNUNET_SCHEDULER_NO_TASK) |
546 | { | 567 | { |
547 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 568 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, |
548 | &end_badly, "from send test messages (timeout)"); | 569 | &end_badly, |
570 | "from send test messages (timeout)"); | ||
549 | } | 571 | } |
550 | 572 | ||
551 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) | 573 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) |
552 | { | 574 | { |
553 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | 575 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
576 | (GNUNET_TIME_UNIT_SECONDS, 1), | ||
554 | &send_test_messages, pos); | 577 | &send_test_messages, pos); |
555 | return; /* Otherwise we'll double schedule messages here! */ | 578 | return; /* Otherwise we'll double schedule messages here! */ |
556 | } | 579 | } |
557 | 580 | ||
558 | /* | 581 | /* |
559 | * Connect to the sending peer | 582 | * Connect to the sending peer |
560 | */ | 583 | */ |
561 | pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, | 584 | pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, |
562 | 1, | 585 | 1, |
563 | pos, | 586 | pos, |
564 | &init_notify_peer1, | 587 | &init_notify_peer1, |
565 | NULL, NULL, | 588 | NULL, NULL, |
566 | NULL, | 589 | NULL, |
567 | NULL, | 590 | NULL, |
568 | GNUNET_NO, NULL, GNUNET_NO, no_handlers); | 591 | GNUNET_NO, NULL, GNUNET_NO, |
592 | no_handlers); | ||
569 | 593 | ||
570 | GNUNET_assert(pos->peer1handle != NULL); | 594 | GNUNET_assert (pos->peer1handle != NULL); |
571 | 595 | ||
572 | if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) | 596 | if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) |
573 | { | 597 | { |
@@ -575,7 +599,8 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
575 | } | 599 | } |
576 | else | 600 | else |
577 | { | 601 | { |
578 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | 602 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
603 | (GNUNET_TIME_UNIT_SECONDS, 1), | ||
579 | &send_test_messages, pos->next); | 604 | &send_test_messages, pos->next); |
580 | } | 605 | } |
581 | } | 606 | } |
@@ -596,29 +621,28 @@ topology_callback (void *cls, | |||
596 | if (emsg == NULL) | 621 | if (emsg == NULL) |
597 | { | 622 | { |
598 | #if VERBOSE | 623 | #if VERBOSE |
599 | if ((total_connections) % modnum == 0) | 624 | if ((total_connections) % modnum == 0) |
600 | { | 625 | { |
601 | if (total_connections == 0) | 626 | if (total_connections == 0) |
602 | fprintf (stdout, "0%%"); | 627 | fprintf (stdout, "0%%"); |
603 | else | 628 | else |
604 | fprintf (stdout, "%d%%", | 629 | fprintf (stdout, "%d%%", |
605 | (int) (((float) total_connections / | 630 | (int) (((float) total_connections / |
606 | expected_connections) * 100)); | 631 | expected_connections) * 100)); |
607 | 632 | ||
608 | } | 633 | } |
609 | else if (total_connections % dotnum == 0) | 634 | else if (total_connections % dotnum == 0) |
610 | { | 635 | { |
611 | fprintf (stdout, "."); | 636 | fprintf (stdout, "."); |
612 | } | 637 | } |
613 | fflush (stdout); | 638 | fflush (stdout); |
614 | #endif | 639 | #endif |
615 | total_connections++; | 640 | total_connections++; |
616 | #if VERBOSE > 1 | 641 | #if VERBOSE > 1 |
617 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n", | 642 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s\n", |
618 | first_daemon->shortname, | 643 | first_daemon->shortname, second_daemon->shortname); |
619 | second_daemon->shortname); | ||
620 | #endif | 644 | #endif |
621 | temp_context = GNUNET_malloc(sizeof(struct TestMessageContext)); | 645 | temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); |
622 | temp_context->peer1 = first_daemon; | 646 | temp_context->peer1 = first_daemon; |
623 | temp_context->peer2 = second_daemon; | 647 | temp_context->peer2 = second_daemon; |
624 | temp_context->next = test_messages; | 648 | temp_context->next = test_messages; |
@@ -628,22 +652,23 @@ topology_callback (void *cls, | |||
628 | 652 | ||
629 | expected_messages++; | 653 | expected_messages++; |
630 | if (dotOutFile != NULL) | 654 | if (dotOutFile != NULL) |
631 | fprintf(dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, second_daemon->shortname); | 655 | fprintf (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, |
656 | second_daemon->shortname); | ||
632 | } | 657 | } |
633 | #if VERBOSE | 658 | #if VERBOSE |
634 | else | 659 | else |
635 | { | 660 | { |
636 | failed_connections++; | 661 | failed_connections++; |
637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n", | 662 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
638 | first_daemon->shortname, | 663 | "Failed to connect peer %s to peer %s with error :\n%s\n", |
639 | second_daemon->shortname, emsg); | 664 | first_daemon->shortname, second_daemon->shortname, emsg); |
640 | } | 665 | } |
641 | #endif | 666 | #endif |
642 | 667 | ||
643 | if (total_connections == expected_connections) | 668 | if (total_connections == expected_connections) |
644 | { | 669 | { |
645 | #if VERBOSE | 670 | #if VERBOSE |
646 | fprintf(stdout, "100%%]\n"); | 671 | fprintf (stdout, "100%%]\n"); |
647 | #endif | 672 | #endif |
648 | #if VERBOSE | 673 | #if VERBOSE |
649 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 674 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -655,26 +680,28 @@ topology_callback (void *cls, | |||
655 | GNUNET_SCHEDULER_cancel (die_task); | 680 | GNUNET_SCHEDULER_cancel (die_task); |
656 | die_task = GNUNET_SCHEDULER_NO_TASK; | 681 | die_task = GNUNET_SCHEDULER_NO_TASK; |
657 | #if DELAY_FOR_LOGGING | 682 | #if DELAY_FOR_LOGGING |
658 | fprintf(stdout, "Sending test messages in 10 seconds.\n"); | 683 | fprintf (stdout, "Sending test messages in 10 seconds.\n"); |
659 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 684 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
660 | (GNUNET_TIME_UNIT_SECONDS, 10), | 685 | (GNUNET_TIME_UNIT_SECONDS, 10), |
661 | &send_test_messages, test_messages); | 686 | &send_test_messages, test_messages); |
662 | gather_log_data(); | 687 | gather_log_data (); |
663 | #else | 688 | #else |
664 | if (settle_time.rel_value > 0) | 689 | if (settle_time.rel_value > 0) |
665 | { | 690 | { |
666 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); | 691 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); |
667 | } | 692 | } |
668 | GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, test_messages); | 693 | GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, |
694 | test_messages); | ||
669 | #endif | 695 | #endif |
670 | #if VERBOSE | 696 | #if VERBOSE |
671 | fprintf(stdout, "Test message progress: ["); | 697 | fprintf (stdout, "Test message progress: ["); |
672 | #endif | 698 | #endif |
673 | 699 | ||
674 | } | 700 | } |
675 | else if (total_connections + failed_connections == expected_connections) | 701 | else if (total_connections + failed_connections == expected_connections) |
676 | { | 702 | { |
677 | if (failed_connections < (unsigned int)(fail_percentage * total_connections)) | 703 | if (failed_connections < |
704 | (unsigned int) (fail_percentage * total_connections)) | ||
678 | { | 705 | { |
679 | GNUNET_SCHEDULER_cancel (die_task); | 706 | GNUNET_SCHEDULER_cancel (die_task); |
680 | die_task = GNUNET_SCHEDULER_NO_TASK; | 707 | die_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -683,7 +710,9 @@ topology_callback (void *cls, | |||
683 | else | 710 | else |
684 | { | 711 | { |
685 | GNUNET_SCHEDULER_cancel (die_task); | 712 | GNUNET_SCHEDULER_cancel (die_task); |
686 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); | 713 | die_task = |
714 | GNUNET_SCHEDULER_add_now (&end_badly, | ||
715 | "from topology_callback (too many failed connections)"); | ||
687 | } | 716 | } |
688 | } | 717 | } |
689 | else | 718 | else |
@@ -691,17 +720,20 @@ topology_callback (void *cls, | |||
691 | #if VERBOSE > 1 | 720 | #if VERBOSE > 1 |
692 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 721 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
693 | "Have %d total connections, %d failed connections, Want %d (at least %d)\n", | 722 | "Have %d total connections, %d failed connections, Want %d (at least %d)\n", |
694 | total_connections, failed_connections, expected_connections, expected_connections - (unsigned int)(fail_percentage * expected_connections)); | 723 | total_connections, failed_connections, expected_connections, |
724 | expected_connections - | ||
725 | (unsigned int) (fail_percentage * expected_connections)); | ||
695 | #endif | 726 | #endif |
696 | } | 727 | } |
697 | } | 728 | } |
698 | 729 | ||
699 | static void topology_creation_finished (void *cls, | 730 | static void |
700 | const char *emsg) | 731 | topology_creation_finished (void *cls, const char *emsg) |
701 | { | 732 | { |
702 | #if VERBOSE | 733 | #if VERBOSE |
703 | if (emsg == NULL) | 734 | if (emsg == NULL) |
704 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "All topology connections created successfully!\n"); | 735 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
736 | "All topology connections created successfully!\n"); | ||
705 | #endif | 737 | #endif |
706 | } | 738 | } |
707 | 739 | ||
@@ -711,7 +743,11 @@ connect_topology () | |||
711 | expected_connections = -1; | 743 | expected_connections = -1; |
712 | if ((pg != NULL) && (peers_left == 0)) | 744 | if ((pg != NULL) && (peers_left == 0)) |
713 | { | 745 | { |
714 | expected_connections = GNUNET_TESTING_connect_topology (pg, connection_topology, connect_topology_option, connect_topology_option_modifier, &topology_creation_finished, NULL); | 746 | expected_connections = |
747 | GNUNET_TESTING_connect_topology (pg, connection_topology, | ||
748 | connect_topology_option, | ||
749 | connect_topology_option_modifier, | ||
750 | &topology_creation_finished, NULL); | ||
715 | #if VERBOSE > 1 | 751 | #if VERBOSE > 1 |
716 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 752 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
717 | "Have %d expected connections\n", expected_connections); | 753 | "Have %d expected connections\n", expected_connections); |
@@ -721,52 +757,60 @@ connect_topology () | |||
721 | GNUNET_SCHEDULER_cancel (die_task); | 757 | GNUNET_SCHEDULER_cancel (die_task); |
722 | if (expected_connections == GNUNET_SYSERR) | 758 | if (expected_connections == GNUNET_SYSERR) |
723 | { | 759 | { |
724 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); | 760 | die_task = |
761 | GNUNET_SCHEDULER_add_now (&end_badly, | ||
762 | "from connect topology (bad return)"); | ||
725 | } | 763 | } |
726 | 764 | ||
727 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 765 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, |
728 | &end_badly, "from connect topology (timeout)"); | 766 | &end_badly, |
767 | "from connect topology (timeout)"); | ||
729 | modnum = expected_connections / 4; | 768 | modnum = expected_connections / 4; |
730 | dotnum = (expected_connections / 50) + 1; | 769 | dotnum = (expected_connections / 50) + 1; |
731 | #if VERBOSE | 770 | #if VERBOSE |
732 | fprintf(stdout, "Peer connection progress: ["); | 771 | fprintf (stdout, "Peer connection progress: ["); |
733 | #endif | 772 | #endif |
734 | } | 773 | } |
735 | 774 | ||
736 | static void | 775 | static void |
737 | create_topology () | 776 | create_topology () |
738 | { | 777 | { |
739 | peers_left = num_peers; /* Reset counter */ | 778 | peers_left = num_peers; /* Reset counter */ |
740 | if (GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR) | 779 | if (GNUNET_TESTING_create_topology |
780 | (pg, topology, blacklist_topology, | ||
781 | blacklist_transports) != GNUNET_SYSERR) | ||
741 | { | 782 | { |
742 | #if VERBOSE | 783 | #if VERBOSE |
743 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
744 | "Topology set up, now starting peers!\n"); | 785 | "Topology set up, now starting peers!\n"); |
745 | fprintf(stdout, "Daemon start progress ["); | 786 | fprintf (stdout, "Daemon start progress ["); |
746 | #endif | 787 | #endif |
747 | GNUNET_TESTING_daemons_continue_startup(pg); | 788 | GNUNET_TESTING_daemons_continue_startup (pg); |
748 | } | 789 | } |
749 | else | 790 | else |
750 | { | 791 | { |
751 | GNUNET_SCHEDULER_cancel (die_task); | 792 | GNUNET_SCHEDULER_cancel (die_task); |
752 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); | 793 | die_task = |
794 | GNUNET_SCHEDULER_add_now (&end_badly, | ||
795 | "from create topology (bad return)"); | ||
753 | } | 796 | } |
754 | GNUNET_SCHEDULER_cancel (die_task); | 797 | GNUNET_SCHEDULER_cancel (die_task); |
755 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 798 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, |
756 | &end_badly, "from continue startup (timeout)"); | 799 | &end_badly, |
800 | "from continue startup (timeout)"); | ||
757 | } | 801 | } |
758 | 802 | ||
759 | 803 | ||
760 | static void | 804 | static void |
761 | peers_started_callback (void *cls, | 805 | peers_started_callback (void *cls, |
762 | const struct GNUNET_PeerIdentity *id, | 806 | const struct GNUNET_PeerIdentity *id, |
763 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 807 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
764 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 808 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
765 | { | 809 | { |
766 | if (emsg != NULL) | 810 | if (emsg != NULL) |
767 | { | 811 | { |
768 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to start daemon with error: `%s'\n", | 812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
769 | emsg); | 813 | "Failed to start daemon with error: `%s'\n", emsg); |
770 | return; | 814 | return; |
771 | } | 815 | } |
772 | GNUNET_assert (id != NULL); | 816 | GNUNET_assert (id != NULL); |
@@ -775,27 +819,27 @@ peers_started_callback (void *cls, | |||
775 | (num_peers - peers_left) + 1, num_peers); | 819 | (num_peers - peers_left) + 1, num_peers); |
776 | #endif | 820 | #endif |
777 | #if VERBOSE | 821 | #if VERBOSE |
778 | if ((num_peers - peers_left) % modnum == 0) | 822 | if ((num_peers - peers_left) % modnum == 0) |
779 | { | 823 | { |
780 | if (num_peers - peers_left == 0) | 824 | if (num_peers - peers_left == 0) |
781 | fprintf (stdout, "0%%"); | 825 | fprintf (stdout, "0%%"); |
782 | else | 826 | else |
783 | fprintf (stdout, "%d%%", | 827 | fprintf (stdout, "%d%%", |
784 | (int) (((float) (num_peers - peers_left) / | 828 | (int) (((float) (num_peers - peers_left) / |
785 | num_peers) * 100)); | 829 | num_peers) * 100)); |
786 | 830 | ||
787 | } | 831 | } |
788 | else if ((num_peers - peers_left) % dotnum == 0) | 832 | else if ((num_peers - peers_left) % dotnum == 0) |
789 | { | 833 | { |
790 | fprintf (stdout, "."); | 834 | fprintf (stdout, "."); |
791 | } | 835 | } |
792 | fflush (stdout); | 836 | fflush (stdout); |
793 | #endif | 837 | #endif |
794 | peers_left--; | 838 | peers_left--; |
795 | if (peers_left == 0) | 839 | if (peers_left == 0) |
796 | { | 840 | { |
797 | #if VERBOSE | 841 | #if VERBOSE |
798 | fprintf(stdout, "100%%]\n"); | 842 | fprintf (stdout, "100%%]\n"); |
799 | #endif | 843 | #endif |
800 | #if VERBOSE | 844 | #if VERBOSE |
801 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 845 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -807,10 +851,11 @@ peers_started_callback (void *cls, | |||
807 | * within a reasonable amount of time */ | 851 | * within a reasonable amount of time */ |
808 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 852 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
809 | (GNUNET_TIME_UNIT_MINUTES, 8), | 853 | (GNUNET_TIME_UNIT_MINUTES, 8), |
810 | &end_badly, "from peers_started_callback"); | 854 | &end_badly, |
855 | "from peers_started_callback"); | ||
811 | #if DELAY_FOR_LOGGING | 856 | #if DELAY_FOR_LOGGING |
812 | fprintf(stdout, "Connecting topology in 10 seconds\n"); | 857 | fprintf (stdout, "Connecting topology in 10 seconds\n"); |
813 | gather_log_data(); | 858 | gather_log_data (); |
814 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 859 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
815 | (GNUNET_TIME_UNIT_SECONDS, 10), | 860 | (GNUNET_TIME_UNIT_SECONDS, 10), |
816 | &connect_topology, NULL); | 861 | &connect_topology, NULL); |
@@ -829,56 +874,58 @@ peers_started_callback (void *cls, | |||
829 | * @param d the daemon handle (pretty useless at this point, remove?) | 874 | * @param d the daemon handle (pretty useless at this point, remove?) |
830 | * @param emsg non-null on failure | 875 | * @param emsg non-null on failure |
831 | */ | 876 | */ |
832 | void hostkey_callback (void *cls, | 877 | void |
833 | const struct GNUNET_PeerIdentity *id, | 878 | hostkey_callback (void *cls, |
834 | struct GNUNET_TESTING_Daemon *d, | 879 | const struct GNUNET_PeerIdentity *id, |
835 | const char *emsg) | 880 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
836 | { | 881 | { |
837 | if (emsg != NULL) | 882 | if (emsg != NULL) |
838 | { | 883 | { |
839 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Hostkey callback received error: %s\n", emsg); | 884 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
885 | "Hostkey callback received error: %s\n", emsg); | ||
840 | } | 886 | } |
841 | 887 | ||
842 | #if VERBOSE > 1 | 888 | #if VERBOSE > 1 |
843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 889 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
844 | "Hostkey (%d/%d) created for peer `%s'\n", | 890 | "Hostkey (%d/%d) created for peer `%s'\n", |
845 | num_peers - peers_left, num_peers, GNUNET_i2s(id)); | 891 | num_peers - peers_left, num_peers, GNUNET_i2s (id)); |
846 | #endif | 892 | #endif |
847 | 893 | ||
848 | #if VERBOSE | 894 | #if VERBOSE |
849 | if ((num_peers - peers_left) % modnum == 0) | 895 | if ((num_peers - peers_left) % modnum == 0) |
850 | { | 896 | { |
851 | if (num_peers - peers_left == 0) | 897 | if (num_peers - peers_left == 0) |
852 | fprintf (stdout, "0%%"); | 898 | fprintf (stdout, "0%%"); |
853 | else | 899 | else |
854 | fprintf (stdout, "%d%%", | 900 | fprintf (stdout, "%d%%", |
855 | (int) (((float) (num_peers - peers_left) / | 901 | (int) (((float) (num_peers - peers_left) / |
856 | num_peers) * 100)); | 902 | num_peers) * 100)); |
857 | 903 | ||
858 | } | 904 | } |
859 | else if ((num_peers - peers_left) % dotnum == 0) | 905 | else if ((num_peers - peers_left) % dotnum == 0) |
860 | { | 906 | { |
861 | fprintf (stdout, "."); | 907 | fprintf (stdout, "."); |
862 | } | 908 | } |
863 | fflush (stdout); | 909 | fflush (stdout); |
864 | #endif | 910 | #endif |
865 | peers_left--; | 911 | peers_left--; |
866 | if (peers_left == 0) | 912 | if (peers_left == 0) |
867 | { | 913 | { |
868 | #if VERBOSE | 914 | #if VERBOSE |
869 | fprintf(stdout, "100%%]\n"); | 915 | fprintf (stdout, "100%%]\n"); |
870 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 916 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
871 | "All %d hostkeys created, now creating topology!\n", | 917 | "All %d hostkeys created, now creating topology!\n", |
872 | num_peers); | 918 | num_peers); |
873 | #endif | 919 | #endif |
874 | GNUNET_SCHEDULER_cancel (die_task); | 920 | GNUNET_SCHEDULER_cancel (die_task); |
875 | /* Set up task in case topology creation doesn't finish | 921 | /* Set up task in case topology creation doesn't finish |
876 | * within a reasonable amount of time */ | 922 | * within a reasonable amount of time */ |
877 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 923 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
878 | &end_badly, "from create_topology"); | 924 | &end_badly, |
879 | GNUNET_SCHEDULER_add_now(&create_topology, NULL); | 925 | "from create_topology"); |
880 | ok = 0; | 926 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); |
881 | } | 927 | ok = 0; |
928 | } | ||
882 | } | 929 | } |
883 | 930 | ||
884 | static void | 931 | static void |
@@ -886,11 +933,11 @@ run (void *cls, | |||
886 | char *const *args, | 933 | char *const *args, |
887 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | 934 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) |
888 | { | 935 | { |
889 | char * topology_str; | 936 | char *topology_str; |
890 | char * connect_topology_str; | 937 | char *connect_topology_str; |
891 | char * blacklist_topology_str; | 938 | char *blacklist_topology_str; |
892 | char * connect_topology_option_str; | 939 | char *connect_topology_option_str; |
893 | char * connect_topology_option_modifier_string; | 940 | char *connect_topology_option_modifier_string; |
894 | unsigned long long temp_settle; | 941 | unsigned long long temp_settle; |
895 | ok = 1; | 942 | ok = 1; |
896 | 943 | ||
@@ -905,71 +952,97 @@ run (void *cls, | |||
905 | "Starting daemons based on config file %s\n", cfgfile); | 952 | "Starting daemons based on config file %s\n", cfgfile); |
906 | #endif | 953 | #endif |
907 | 954 | ||
908 | if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) | 955 | if (GNUNET_YES != |
956 | GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", | ||
957 | &test_directory)) | ||
909 | { | 958 | { |
910 | ok = 404; | 959 | ok = 404; |
911 | return; | 960 | return; |
912 | } | 961 | } |
913 | 962 | ||
914 | if ((GNUNET_YES == | 963 | if ((GNUNET_YES == |
915 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology", | 964 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", |
916 | &topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&topology, topology_str))) | 965 | &topology_str)) |
966 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) | ||
917 | { | 967 | { |
918 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 968 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
919 | "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "TOPOLOGY"); | 969 | "Invalid topology `%s' given for section %s option %s\n", |
920 | topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ | 970 | topology_str, "TESTING", "TOPOLOGY"); |
971 | topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ | ||
921 | } | 972 | } |
922 | 973 | ||
923 | if ((GNUNET_YES == | 974 | if ((GNUNET_YES == |
924 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology", | 975 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
925 | &connect_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&connection_topology, connect_topology_str))) | 976 | "connect_topology", |
977 | &connect_topology_str)) | ||
978 | && (GNUNET_NO == | ||
979 | GNUNET_TESTING_topology_get (&connection_topology, | ||
980 | connect_topology_str))) | ||
926 | { | 981 | { |
927 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 982 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
928 | "Invalid connect topology `%s' given for section %s option %s\n", connect_topology_str, "TESTING", "CONNECT_TOPOLOGY"); | 983 | "Invalid connect topology `%s' given for section %s option %s\n", |
984 | connect_topology_str, "TESTING", "CONNECT_TOPOLOGY"); | ||
929 | } | 985 | } |
930 | GNUNET_free_non_null(connect_topology_str); | 986 | GNUNET_free_non_null (connect_topology_str); |
931 | if ((GNUNET_YES == | 987 | if ((GNUNET_YES == |
932 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology_option", | 988 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
933 | &connect_topology_option_str)) && (GNUNET_NO == GNUNET_TESTING_topology_option_get(&connect_topology_option, connect_topology_option_str))) | 989 | "connect_topology_option", |
990 | &connect_topology_option_str)) | ||
991 | && (GNUNET_NO == | ||
992 | GNUNET_TESTING_topology_option_get (&connect_topology_option, | ||
993 | connect_topology_option_str))) | ||
934 | { | 994 | { |
935 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 995 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
936 | "Invalid connect topology option `%s' given for section %s option %s\n", connect_topology_option_str, "TESTING", "CONNECT_TOPOLOGY_OPTION"); | 996 | "Invalid connect topology option `%s' given for section %s option %s\n", |
937 | connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ | 997 | connect_topology_option_str, "TESTING", |
998 | "CONNECT_TOPOLOGY_OPTION"); | ||
999 | connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ | ||
938 | } | 1000 | } |
939 | GNUNET_free_non_null(connect_topology_option_str); | 1001 | GNUNET_free_non_null (connect_topology_option_str); |
940 | if (GNUNET_YES == | 1002 | if (GNUNET_YES == |
941 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option_modifier", | 1003 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
942 | &connect_topology_option_modifier_string)) | 1004 | "connect_topology_option_modifier", |
1005 | &connect_topology_option_modifier_string)) | ||
943 | { | 1006 | { |
944 | if (sscanf(connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) | 1007 | if (sscanf |
945 | { | 1008 | (connect_topology_option_modifier_string, "%lf", |
946 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1009 | &connect_topology_option_modifier) != 1) |
947 | _("Invalid value `%s' for option `%s' in section `%s': expected float\n"), | 1010 | { |
948 | connect_topology_option_modifier_string, | 1011 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
949 | "connect_topology_option_modifier", | 1012 | _ |
950 | "TESTING"); | 1013 | ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), |
951 | } | 1014 | connect_topology_option_modifier_string, |
1015 | "connect_topology_option_modifier", "TESTING"); | ||
1016 | } | ||
952 | GNUNET_free (connect_topology_option_modifier_string); | 1017 | GNUNET_free (connect_topology_option_modifier_string); |
953 | } | 1018 | } |
954 | 1019 | ||
955 | if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "blacklist_transports", | 1020 | if (GNUNET_YES != |
956 | &blacklist_transports)) | 1021 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
1022 | "blacklist_transports", | ||
1023 | &blacklist_transports)) | ||
957 | blacklist_transports = NULL; | 1024 | blacklist_transports = NULL; |
958 | 1025 | ||
959 | if ((GNUNET_YES == | 1026 | if ((GNUNET_YES == |
960 | GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "blacklist_topology", | 1027 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
961 | &blacklist_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&blacklist_topology, blacklist_topology_str))) | 1028 | "blacklist_topology", |
1029 | &blacklist_topology_str)) | ||
1030 | && (GNUNET_NO == | ||
1031 | GNUNET_TESTING_topology_get (&blacklist_topology, | ||
1032 | blacklist_topology_str))) | ||
962 | { | 1033 | { |
963 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1034 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
964 | "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "BLACKLIST_TOPOLOGY"); | 1035 | "Invalid topology `%s' given for section %s option %s\n", |
1036 | topology_str, "TESTING", "BLACKLIST_TOPOLOGY"); | ||
965 | } | 1037 | } |
966 | GNUNET_free_non_null(topology_str); | 1038 | GNUNET_free_non_null (topology_str); |
967 | GNUNET_free_non_null(blacklist_topology_str); | 1039 | GNUNET_free_non_null (blacklist_topology_str); |
968 | 1040 | ||
969 | if (GNUNET_OK == | 1041 | if (GNUNET_OK == |
970 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time", | 1042 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time", |
971 | &temp_settle)) | 1043 | &temp_settle)) |
972 | settle_time = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, temp_settle); | 1044 | settle_time = |
1045 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); | ||
973 | 1046 | ||
974 | if (GNUNET_SYSERR == | 1047 | if (GNUNET_SYSERR == |
975 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", | 1048 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", |
@@ -985,12 +1058,21 @@ run (void *cls, | |||
985 | fprintf (stdout, "Hostkey generation progress: ["); | 1058 | fprintf (stdout, "Hostkey generation progress: ["); |
986 | #endif | 1059 | #endif |
987 | /* Set up a task to end testing if peer start fails */ | 1060 | /* Set up a task to end testing if peer start fails */ |
988 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), | 1061 | die_task = |
989 | &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); | 1062 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
990 | 1063 | (GNUNET_TIME_UNIT_SECONDS, | |
991 | GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1); | 1064 | SECONDS_PER_PEER_START * num_peers), |
1065 | &end_badly, | ||
1066 | "didn't generate all hostkeys within a reasonable amount of time!!!"); | ||
1067 | |||
1068 | GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); | ||
992 | pg = GNUNET_TESTING_daemons_start (cfg, | 1069 | pg = GNUNET_TESTING_daemons_start (cfg, |
993 | peers_left, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), &hostkey_callback, NULL, &peers_started_callback, NULL, | 1070 | peers_left, |
1071 | GNUNET_TIME_relative_multiply | ||
1072 | (GNUNET_TIME_UNIT_SECONDS, | ||
1073 | SECONDS_PER_PEER_START * num_peers), | ||
1074 | &hostkey_callback, NULL, | ||
1075 | &peers_started_callback, NULL, | ||
994 | &topology_callback, NULL, NULL); | 1076 | &topology_callback, NULL, NULL); |
995 | 1077 | ||
996 | } | 1078 | } |
@@ -1000,10 +1082,11 @@ check () | |||
1000 | { | 1082 | { |
1001 | char *binary_name; | 1083 | char *binary_name; |
1002 | char *config_file_name; | 1084 | char *config_file_name; |
1003 | GNUNET_asprintf(&binary_name, "test-testing-topology-%s", topology_string); | 1085 | GNUNET_asprintf (&binary_name, "test-testing-topology-%s", topology_string); |
1004 | GNUNET_asprintf(&config_file_name, "test_testing_data_topology_%s.conf", topology_string); | 1086 | GNUNET_asprintf (&config_file_name, "test_testing_data_topology_%s.conf", |
1087 | topology_string); | ||
1005 | int ret; | 1088 | int ret; |
1006 | char *const argv[] = {binary_name, | 1089 | char *const argv[] = { binary_name, |
1007 | "-c", | 1090 | "-c", |
1008 | config_file_name, | 1091 | config_file_name, |
1009 | #if VERBOSE | 1092 | #if VERBOSE |
@@ -1015,14 +1098,15 @@ check () | |||
1015 | GNUNET_GETOPT_OPTION_END | 1098 | GNUNET_GETOPT_OPTION_END |
1016 | }; | 1099 | }; |
1017 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 1100 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
1018 | argv, binary_name, "nohelp", | 1101 | argv, binary_name, "nohelp", options, &run, &ok); |
1019 | options, &run, &ok); | ||
1020 | if (ret != GNUNET_OK) | 1102 | if (ret != GNUNET_OK) |
1021 | { | 1103 | { |
1022 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`test-testing-topology-%s': Failed with error code %d\n", topology_string, ret); | 1104 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1105 | "`test-testing-topology-%s': Failed with error code %d\n", | ||
1106 | topology_string, ret); | ||
1023 | } | 1107 | } |
1024 | GNUNET_free(binary_name); | 1108 | GNUNET_free (binary_name); |
1025 | GNUNET_free(config_file_name); | 1109 | GNUNET_free (config_file_name); |
1026 | return ok; | 1110 | return ok; |
1027 | } | 1111 | } |
1028 | 1112 | ||
@@ -1033,18 +1117,18 @@ main (int argc, char *argv[]) | |||
1033 | char *binary_start_pos; | 1117 | char *binary_start_pos; |
1034 | char *our_binary_name; | 1118 | char *our_binary_name; |
1035 | 1119 | ||
1036 | binary_start_pos = rindex(argv[0], '/'); | 1120 | binary_start_pos = rindex (argv[0], '/'); |
1037 | GNUNET_assert(binary_start_pos != NULL); | 1121 | GNUNET_assert (binary_start_pos != NULL); |
1038 | topology_string = strstr (binary_start_pos, | 1122 | topology_string = strstr (binary_start_pos, "_topology"); |
1039 | "_topology"); | ||
1040 | GNUNET_assert (topology_string != NULL); | 1123 | GNUNET_assert (topology_string != NULL); |
1041 | topology_string++; | 1124 | topology_string++; |
1042 | topology_string = strstr (topology_string, "_"); | 1125 | topology_string = strstr (topology_string, "_"); |
1043 | GNUNET_assert (topology_string != NULL); | 1126 | GNUNET_assert (topology_string != NULL); |
1044 | topology_string++; | 1127 | topology_string++; |
1045 | 1128 | ||
1046 | GNUNET_asprintf(&our_binary_name, "test-testing-topology_%s", topology_string); | 1129 | GNUNET_asprintf (&our_binary_name, "test-testing-topology_%s", |
1047 | GNUNET_asprintf(&dotOutFileName, "topology_%s.dot", topology_string); | 1130 | topology_string); |
1131 | GNUNET_asprintf (&dotOutFileName, "topology_%s.dot", topology_string); | ||
1048 | 1132 | ||
1049 | GNUNET_log_setup (our_binary_name, | 1133 | GNUNET_log_setup (our_binary_name, |
1050 | #if VERBOSE | 1134 | #if VERBOSE |
@@ -1061,9 +1145,10 @@ main (int argc, char *argv[]) | |||
1061 | */ | 1145 | */ |
1062 | if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK) | 1146 | if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK) |
1063 | { | 1147 | { |
1064 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to remove testing directory %s\n", test_directory); | 1148 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1149 | "Failed to remove testing directory %s\n", test_directory); | ||
1065 | } | 1150 | } |
1066 | GNUNET_free(our_binary_name); | 1151 | GNUNET_free (our_binary_name); |
1067 | return ret; | 1152 | return ret; |
1068 | } | 1153 | } |
1069 | 1154 | ||