aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r--src/testing/testing.c484
1 files changed, 217 insertions, 267 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index c21166775..c107ec593 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -67,10 +67,9 @@ static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} };
67 67
68#if EMPTY_HACK 68#if EMPTY_HACK
69static int 69static int
70test_address (void *cls, 70test_address (void *cls, const char *tname,
71 const char *tname, 71 struct GNUNET_TIME_Absolute expiration, const void *addr,
72 struct GNUNET_TIME_Absolute expiration, 72 uint16_t addrlen)
73 const void *addr, uint16_t addrlen)
74{ 73{
75 int *empty = cls; 74 int *empty = cls;
76 75
@@ -144,8 +143,8 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
144 } 143 }
145#if DEBUG_TESTING 144#if DEBUG_TESTING
146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
147 "Received `%s' from transport service of `%4s'\n", 146 "Received `%s' from transport service of `%4s'\n", "HELLO",
148 "HELLO", GNUNET_i2s (&daemon->id)); 147 GNUNET_i2s (&daemon->id));
149#endif 148#endif
150 149
151 GNUNET_free_non_null (daemon->hello); 150 GNUNET_free_non_null (daemon->hello);
@@ -165,8 +164,8 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
165#endif 164#endif
166} 165}
167 166
168static void 167static void start_fsm (void *cls,
169start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 168 const struct GNUNET_SCHEDULER_TaskContext *tc);
170 169
171#if WAIT_FOR_HELLO 170#if WAIT_FOR_HELLO
172/** 171/**
@@ -182,8 +181,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
182 * @param publicKey public key of this peer, NULL if we failed 181 * @param publicKey public key of this peer, NULL if we failed
183 */ 182 */
184static void 183static void
185testing_init (void *cls, 184testing_init (void *cls, struct GNUNET_CORE_Handle *server,
186 struct GNUNET_CORE_Handle *server,
187 const struct GNUNET_PeerIdentity *my_identity, 185 const struct GNUNET_PeerIdentity *my_identity,
188 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 186 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
189{ 187{
@@ -197,17 +195,18 @@ testing_init (void *cls,
197 d->server = NULL; 195 d->server = NULL;
198 if (GNUNET_YES == d->dead) 196 if (GNUNET_YES == d->dead)
199 GNUNET_TESTING_daemon_stop (d, 197 GNUNET_TESTING_daemon_stop (d,
200 GNUNET_TIME_absolute_get_remaining 198 GNUNET_TIME_absolute_get_remaining (d->
201 (d->max_timeout), d->dead_cb, 199 max_timeout),
202 d->dead_cb_cls, GNUNET_YES, GNUNET_NO); 200 d->dead_cb, d->dead_cb_cls, GNUNET_YES,
201 GNUNET_NO);
203 else if (NULL != d->cb) 202 else if (NULL != d->cb)
204 d->cb (d->cb_cls, NULL, d->cfg, d, 203 d->cb (d->cb_cls, NULL, d->cfg, d,
205 _("Failed to connect to core service\n")); 204 _("Failed to connect to core service\n"));
206 return; 205 return;
207 } 206 }
208#if DEBUG_TESTING 207#if DEBUG_TESTING
209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started peer `%4s'.\n",
210 "Successfully started peer `%4s'.\n", GNUNET_i2s (my_identity)); 209 GNUNET_i2s (my_identity));
211#endif 210#endif
212 d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */ 211 d->id = *my_identity; /* FIXME: shouldn't we already have this from reading the hostkey file? */
213 if (d->shortname == NULL) 212 if (d->shortname == NULL)
@@ -234,9 +233,10 @@ testing_init (void *cls,
234 { 233 {
235 if (GNUNET_YES == d->dead) 234 if (GNUNET_YES == d->dead)
236 GNUNET_TESTING_daemon_stop (d, 235 GNUNET_TESTING_daemon_stop (d,
237 GNUNET_TIME_absolute_get_remaining 236 GNUNET_TIME_absolute_get_remaining (d->
238 (d->max_timeout), d->dead_cb, 237 max_timeout),
239 d->dead_cb_cls, GNUNET_YES, GNUNET_NO); 238 d->dead_cb, d->dead_cb_cls, GNUNET_YES,
239 GNUNET_NO);
240 else if (NULL != d->cb) 240 else if (NULL != d->cb)
241 d->cb (d->cb_cls, &d->id, d->cfg, d, 241 d->cb (d->cb_cls, &d->id, d->cfg, d,
242 _("Failed to connect to transport service!\n")); 242 _("Failed to connect to transport service!\n"));
@@ -252,9 +252,8 @@ testing_init (void *cls,
252 /* wait some more */ 252 /* wait some more */
253 if (d->task != GNUNET_SCHEDULER_NO_TASK) 253 if (d->task != GNUNET_SCHEDULER_NO_TASK)
254 GNUNET_SCHEDULER_cancel (d->task); 254 GNUNET_SCHEDULER_cancel (d->task);
255 d->task 255 d->task =
256 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 256 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d);
257 &start_fsm, d);
258} 257}
259#endif 258#endif
260 259
@@ -312,17 +311,15 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
312 cb = d->cb; 311 cb = d->cb;
313 d->cb = NULL; 312 d->cb = NULL;
314 if (NULL != cb) 313 if (NULL != cb)
315 cb (d->cb_cls, 314 cb (d->cb_cls, NULL, d->cfg, d,
316 NULL,
317 d->cfg, d,
318 _ 315 _
319 ("`scp' does not seem to terminate (timeout copying config).\n")); 316 ("`scp' does not seem to terminate (timeout copying config).\n"));
320 return; 317 return;
321 } 318 }
322 /* wait some more */ 319 /* wait some more */
323 d->task 320 d->task =
324 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 321 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
325 &start_fsm, d); 322 d);
326 return; 323 return;
327 } 324 }
328 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) 325 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
@@ -350,13 +347,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
350 cb = d->cb; 347 cb = d->cb;
351 d->cb = NULL; 348 d->cb = NULL;
352 if (NULL != cb) 349 if (NULL != cb)
353 cb (d->cb_cls, 350 cb (d->cb_cls, NULL, d->cfg, d,
354 NULL, 351 (NULL ==
355 d->cfg, 352 d->
356 d, 353 hostname) ?
357 (NULL == d->hostname) 354 _("Failed to create pipe for `gnunet-peerinfo' process.\n") :
358 ? _("Failed to create pipe for `gnunet-peerinfo' process.\n") 355 _("Failed to create pipe for `ssh' process.\n"));
359 : _("Failed to create pipe for `ssh' process.\n"));
360 return; 356 return;
361 } 357 }
362 if (NULL == d->hostname) 358 if (NULL == d->hostname)
@@ -369,8 +365,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
369#endif 365#endif
370 d->proc = 366 d->proc =
371 GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo", 367 GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo",
372 "gnunet-peerinfo", "-c", d->cfgfile, 368 "gnunet-peerinfo", "-c", d->cfgfile, "-sq",
373 "-sq", NULL); 369 NULL);
374 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); 370 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
375 } 371 }
376 else 372 else
@@ -392,20 +388,19 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
392#if !DEBUG_TESTING 388#if !DEBUG_TESTING
393 "-q", 389 "-q",
394#endif 390#endif
395 dst, 391 dst, "gnunet-peerinfo", "-c",
396 "gnunet-peerinfo", 392 d->cfgfile, "-sq", NULL);
397 "-c", d->cfgfile, "-sq", NULL);
398 } 393 }
399 else 394 else
400 { 395 {
401 d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", 396 d->proc =
402 "ssh", "-p", d->ssh_port_str, 397 GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", "ssh", "-p",
398 d->ssh_port_str,
403#if !DEBUG_TESTING 399#if !DEBUG_TESTING
404 "-q", 400 "-q",
405#endif 401#endif
406 dst, 402 dst, "gnunet-peerinfo", "-c", d->cfgfile,
407 "gnunet-peerinfo", 403 "-sq", NULL);
408 "-c", d->cfgfile, "-sq", NULL);
409 } 404 }
410 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); 405 GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
411 GNUNET_free (dst); 406 GNUNET_free (dst);
@@ -418,13 +413,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
418 cb = d->cb; 413 cb = d->cb;
419 d->cb = NULL; 414 d->cb = NULL;
420 if (NULL != cb) 415 if (NULL != cb)
421 cb (d->cb_cls, 416 cb (d->cb_cls, NULL, d->cfg, d,
422 NULL, 417 (NULL ==
423 d->cfg, 418 d->
424 d, 419 hostname) ? _("Failed to start `gnunet-peerinfo' process.\n") :
425 (NULL == d->hostname) 420 _("Failed to start `ssh' process.\n"));
426 ? _("Failed to start `gnunet-peerinfo' process.\n")
427 : _("Failed to start `ssh' process.\n"));
428 GNUNET_DISK_pipe_close (d->pipe_stdout); 421 GNUNET_DISK_pipe_close (d->pipe_stdout);
429 return; 422 return;
430 } 423 }
@@ -433,13 +426,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
433 "Started `%s', waiting for hostkey.\n", "gnunet-peerinfo"); 426 "Started `%s', waiting for hostkey.\n", "gnunet-peerinfo");
434#endif 427#endif
435 d->phase = SP_HOSTKEY_CREATE; 428 d->phase = SP_HOSTKEY_CREATE;
436 d->task 429 d->task =
437 =
438 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining 430 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
439 (d->max_timeout), 431 (d->max_timeout),
440 GNUNET_DISK_pipe_handle 432 GNUNET_DISK_pipe_handle (d->
441 (d->pipe_stdout, 433 pipe_stdout,
442 GNUNET_DISK_PIPE_END_READ), 434 GNUNET_DISK_PIPE_END_READ),
443 &start_fsm, d); 435 &start_fsm, d);
444 } 436 }
445 else /* Already have a hostkey! */ 437 else /* Already have a hostkey! */
@@ -469,21 +461,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
469 if ((d->hostkeybufpos < 104) && (bytes_read > 0)) 461 if ((d->hostkeybufpos < 104) && (bytes_read > 0))
470 { 462 {
471 /* keep reading */ 463 /* keep reading */
472 d->task 464 d->task =
473 =
474 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining 465 GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
475 (d->max_timeout), 466 (d->max_timeout),
476 GNUNET_DISK_pipe_handle 467 GNUNET_DISK_pipe_handle (d->
477 (d->pipe_stdout, 468 pipe_stdout,
478 GNUNET_DISK_PIPE_END_READ), 469 GNUNET_DISK_PIPE_END_READ),
479 &start_fsm, d); 470 &start_fsm, d);
480 return; 471 return;
481 } 472 }
482 d->hostkeybuf[103] = '\0'; 473 d->hostkeybuf[103] = '\0';
483 474
484 if ((bytes_read < 0) || 475 if ((bytes_read < 0) ||
485 (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, 476 (GNUNET_OK !=
486 &d->id.hashPubKey))) 477 GNUNET_CRYPTO_hash_from_string (d->hostkeybuf, &d->id.hashPubKey)))
487 { 478 {
488 /* error */ 479 /* error */
489 if (bytes_read < 0) 480 if (bytes_read < 0)
@@ -529,20 +520,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
529 /* Fall through */ 520 /* Fall through */
530 case SP_HOSTKEY_CREATED: 521 case SP_HOSTKEY_CREATED:
531 /* wait for topology finished */ 522 /* wait for topology finished */
532 if ((GNUNET_YES == d->dead) 523 if ((GNUNET_YES == d->dead) ||
533 || (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0)) 524 (GNUNET_TIME_absolute_get_remaining (d->max_timeout).rel_value == 0))
534 { 525 {
535 cb = d->cb; 526 cb = d->cb;
536 d->cb = NULL; 527 d->cb = NULL;
537 if (NULL != cb) 528 if (NULL != cb)
538 cb (d->cb_cls, 529 cb (d->cb_cls, NULL, d->cfg, d,
539 NULL, d->cfg, d, _("`Failed while waiting for topology setup!\n")); 530 _("`Failed while waiting for topology setup!\n"));
540 return; 531 return;
541 } 532 }
542 533
543 d->task 534 d->task =
544 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 535 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
545 &start_fsm, d); 536 d);
546 break; 537 break;
547 case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! */ 538 case SP_TOPOLOGY_SETUP: /* Indicates topology setup has completed! */
548 /* start GNUnet on remote host */ 539 /* start GNUnet on remote host */
@@ -551,18 +542,19 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
551#if DEBUG_TESTING 542#if DEBUG_TESTING
552 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 543 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
553 "Starting `%s', with command `%s %s %s %s %s %s'.\n", 544 "Starting `%s', with command `%s %s %s %s %s %s'.\n",
554 "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, 545 "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBUG",
555 "-L", "DEBUG", "-s"); 546 "-s");
556#endif 547#endif
557 d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", 548 d->proc =
558 "gnunet-arm", "-c", d->cfgfile, 549 GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm", "-c",
550 d->cfgfile,
559#if DEBUG_TESTING 551#if DEBUG_TESTING
560 "-L", "DEBUG", 552 "-L", "DEBUG",
561#endif 553#endif
562 "-s", "-q", "-T", 554 "-s", "-q", "-T",
563 GNUNET_TIME_relative_to_string 555 GNUNET_TIME_relative_to_string
564 (GNUNET_TIME_absolute_get_remaining 556 (GNUNET_TIME_absolute_get_remaining
565 (d->max_timeout)), NULL); 557 (d->max_timeout)), NULL);
566 } 558 }
567 else 559 else
568 { 560 {
@@ -574,8 +566,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
574#if DEBUG_TESTING 566#if DEBUG_TESTING
575 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 567 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
576 "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n", 568 "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n",
577 "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", 569 "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile,
578 d->cfgfile, "-L", "DEBUG", "-s", "-q"); 570 "-L", "DEBUG", "-s", "-q");
579#endif 571#endif
580 if (d->ssh_port_str == NULL) 572 if (d->ssh_port_str == NULL)
581 { 573 {
@@ -587,8 +579,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
587#if DEBUG_TESTING 579#if DEBUG_TESTING
588 "-L", "DEBUG", 580 "-L", "DEBUG",
589#endif 581#endif
590 "-c", d->cfgfile, "-s", "-q", 582 "-c", d->cfgfile, "-s", "-q", "-T",
591 "-T",
592 GNUNET_TIME_relative_to_string 583 GNUNET_TIME_relative_to_string
593 (GNUNET_TIME_absolute_get_remaining 584 (GNUNET_TIME_absolute_get_remaining
594 (d->max_timeout)), NULL); 585 (d->max_timeout)), NULL);
@@ -596,20 +587,20 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
596 else 587 else
597 { 588 {
598 589
599 d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", 590 d->proc =
600 "ssh", "-p", d->ssh_port_str, 591 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-p",
592 d->ssh_port_str,
601#if !DEBUG_TESTING 593#if !DEBUG_TESTING
602 "-q", 594 "-q",
603#endif 595#endif
604 dst, "gnunet-arm", 596 dst, "gnunet-arm",
605#if DEBUG_TESTING 597#if DEBUG_TESTING
606 "-L", "DEBUG", 598 "-L", "DEBUG",
607#endif 599#endif
608 "-c", d->cfgfile, "-s", "-q", 600 "-c", d->cfgfile, "-s", "-q", "-T",
609 "-T", 601 GNUNET_TIME_relative_to_string
610 GNUNET_TIME_relative_to_string 602 (GNUNET_TIME_absolute_get_remaining
611 (GNUNET_TIME_absolute_get_remaining 603 (d->max_timeout)), NULL);
612 (d->max_timeout)), NULL);
613 } 604 }
614 GNUNET_free (dst); 605 GNUNET_free (dst);
615 } 606 }
@@ -621,24 +612,22 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
621 cb = d->cb; 612 cb = d->cb;
622 d->cb = NULL; 613 d->cb = NULL;
623 if (NULL != cb) 614 if (NULL != cb)
624 cb (d->cb_cls, 615 cb (d->cb_cls, NULL, d->cfg, d,
625 NULL, 616 (NULL ==
626 d->cfg, 617 d->
627 d, 618 hostname) ? _("Failed to start `gnunet-arm' process.\n") :
628 (NULL == d->hostname) 619 _("Failed to start `ssh' process.\n"));
629 ? _("Failed to start `gnunet-arm' process.\n")
630 : _("Failed to start `ssh' process.\n"));
631 return; 620 return;
632 } 621 }
633#if DEBUG_TESTING 622#if DEBUG_TESTING
634 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 623 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
635 "Started `%s', waiting for `%s' to be up.\n", 624 "Started `%s', waiting for `%s' to be up.\n", "gnunet-arm",
636 "gnunet-arm", "gnunet-service-core"); 625 "gnunet-service-core");
637#endif 626#endif
638 d->phase = SP_START_ARMING; 627 d->phase = SP_START_ARMING;
639 d->task 628 d->task =
640 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 629 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
641 &start_fsm, d); 630 d);
642 break; 631 break;
643 case SP_START_ARMING: 632 case SP_START_ARMING:
644 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code)) 633 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
@@ -648,13 +637,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
648 cb = d->cb; 637 cb = d->cb;
649 d->cb = NULL; 638 d->cb = NULL;
650 if (NULL != cb) 639 if (NULL != cb)
651 cb (d->cb_cls, 640 cb (d->cb_cls, NULL, d->cfg, d,
652 NULL, 641 (NULL ==
653 d->cfg, 642 d->
654 d, 643 hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
655 (NULL == d->hostname) 644 _("`ssh' does not seem to terminate.\n"));
656 ? _("`gnunet-arm' does not seem to terminate.\n")
657 : _("`ssh' does not seem to terminate.\n"));
658 GNUNET_CONFIGURATION_destroy (d->cfg); 645 GNUNET_CONFIGURATION_destroy (d->cfg);
659 GNUNET_free (d->cfgfile); 646 GNUNET_free (d->cfgfile);
660 GNUNET_free_non_null (d->hostname); 647 GNUNET_free_non_null (d->hostname);
@@ -664,14 +651,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
664 return; 651 return;
665 } 652 }
666 /* wait some more */ 653 /* wait some more */
667 d->task 654 d->task =
668 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 655 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
669 &start_fsm, d); 656 d);
670 return; 657 return;
671 } 658 }
672#if DEBUG_TESTING 659#if DEBUG_TESTING
673 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 660 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Successfully started `%s'.\n",
674 "Successfully started `%s'.\n", "gnunet-arm"); 661 "gnunet-arm");
675#endif 662#endif
676 GNUNET_free (d->proc); 663 GNUNET_free (d->proc);
677 d->phase = SP_START_CORE; 664 d->phase = SP_START_CORE;
@@ -689,9 +676,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
689 cb = d->cb; 676 cb = d->cb;
690 d->cb = NULL; 677 d->cb = NULL;
691 if (NULL != cb) 678 if (NULL != cb)
692 cb (d->cb_cls, 679 cb (d->cb_cls, NULL, d->cfg, d,
693 NULL, 680 _("Unable to connect to CORE service for peer!\n"));
694 d->cfg, d, _("Unable to connect to CORE service for peer!\n"));
695 GNUNET_CONFIGURATION_destroy (d->cfg); 681 GNUNET_CONFIGURATION_destroy (d->cfg);
696 GNUNET_free (d->cfgfile); 682 GNUNET_free (d->cfgfile);
697 GNUNET_free_non_null (d->hostname); 683 GNUNET_free_non_null (d->hostname);
@@ -699,14 +685,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
699 GNUNET_free (d); 685 GNUNET_free (d);
700 return; 686 return;
701 } 687 }
702 d->server = GNUNET_CORE_connect (d->cfg, 1, 688 d->server =
703 d, 689 GNUNET_CORE_connect (d->cfg, 1, d, &testing_init, NULL, NULL, NULL,
704 &testing_init, 690 NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers);
705 NULL, NULL, NULL, 691 d->task =
706 NULL, GNUNET_NO,
707 NULL, GNUNET_NO, no_handlers);
708 d->task
709 =
710 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 692 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
711 (GNUNET_CONSTANTS_SERVICE_RETRY, 2), 693 (GNUNET_CONSTANTS_SERVICE_RETRY, 2),
712 &start_fsm, d); 694 &start_fsm, d);
@@ -716,9 +698,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
716 { 698 {
717 if (GNUNET_YES == d->dead) 699 if (GNUNET_YES == d->dead)
718 GNUNET_TESTING_daemon_stop (d, 700 GNUNET_TESTING_daemon_stop (d,
719 GNUNET_TIME_absolute_get_remaining 701 GNUNET_TIME_absolute_get_remaining (d->
720 (d->max_timeout), d->dead_cb, 702 max_timeout),
721 d->dead_cb_cls, GNUNET_YES, GNUNET_NO); 703 d->dead_cb, d->dead_cb_cls, GNUNET_YES,
704 GNUNET_NO);
722 else if (NULL != d->cb) 705 else if (NULL != d->cb)
723 d->cb (d->cb_cls, &d->id, d->cfg, d, 706 d->cb (d->cb_cls, &d->id, d->cfg, d,
724 _("Failed to connect to transport service!\n")); 707 _("Failed to connect to transport service!\n"));
@@ -761,8 +744,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
761 if (d->hello != NULL) 744 if (d->hello != NULL)
762 return; 745 return;
763 GNUNET_assert (d->task == GNUNET_SCHEDULER_NO_TASK); 746 GNUNET_assert (d->task == GNUNET_SCHEDULER_NO_TASK);
764 d->task 747 d->task =
765 =
766 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 748 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
767 (GNUNET_CONSTANTS_SERVICE_RETRY, 2), 749 (GNUNET_CONSTANTS_SERVICE_RETRY, 2),
768 &start_fsm, d); 750 &start_fsm, d);
@@ -779,19 +761,17 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
779 cb = d->cb; 761 cb = d->cb;
780 d->cb = NULL; 762 d->cb = NULL;
781 if (NULL != cb) 763 if (NULL != cb)
782 cb (d->cb_cls, 764 cb (d->cb_cls, NULL, d->cfg, d,
783 NULL, 765 (NULL ==
784 d->cfg, 766 d->
785 d, 767 hostname) ? _("`gnunet-arm' does not seem to terminate.\n") :
786 (NULL == d->hostname) 768 _("`ssh' does not seem to terminate.\n"));
787 ? _("`gnunet-arm' does not seem to terminate.\n")
788 : _("`ssh' does not seem to terminate.\n"));
789 return; 769 return;
790 } 770 }
791 /* wait some more */ 771 /* wait some more */
792 d->task 772 d->task =
793 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 773 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
794 &start_fsm, d); 774 d);
795 return; 775 return;
796 } 776 }
797#if EXTRA_CHECKS 777#if EXTRA_CHECKS
@@ -800,12 +780,10 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
800 cb = d->cb; 780 cb = d->cb;
801 d->cb = NULL; 781 d->cb = NULL;
802 if (NULL != cb) 782 if (NULL != cb)
803 cb (d->cb_cls, 783 cb (d->cb_cls, NULL, d->cfg, d,
804 NULL, 784 (NULL ==
805 d->cfg, 785 d->
806 d, 786 hostname) ?
807 (NULL == d->hostname)
808 ?
809 _ 787 _
810 ("`gnunet-arm' terminated with non-zero exit status (or timed out)!\n") 788 ("`gnunet-arm' terminated with non-zero exit status (or timed out)!\n")
811 : _("`ssh' does not seem to terminate.\n")); 789 : _("`ssh' does not seem to terminate.\n"));
@@ -834,9 +812,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
834 return; 812 return;
835 } 813 }
836 /* wait some more */ 814 /* wait some more */
837 d->task 815 d->task =
838 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 816 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
839 &start_fsm, d); 817 d);
840 return; 818 return;
841 } 819 }
842#if EXTRA_CHECKS 820#if EXTRA_CHECKS
@@ -883,9 +861,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
883 return; 861 return;
884 } 862 }
885 /* wait some more */ 863 /* wait some more */
886 d->task 864 d->task =
887 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 865 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
888 &start_fsm, d); 866 d);
889 return; 867 return;
890 } 868 }
891 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) 869 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
@@ -963,14 +941,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
963 cb = d->cb; 941 cb = d->cb;
964 d->cb = NULL; 942 d->cb = NULL;
965 if (NULL != cb) 943 if (NULL != cb)
966 cb (d->cb_cls, 944 cb (d->cb_cls, NULL, d->cfg, d,
967 NULL, d->cfg, d, _("`scp' does not seem to terminate.\n")); 945 _("`scp' does not seem to terminate.\n"));
968 return; 946 return;
969 } 947 }
970 /* wait some more */ 948 /* wait some more */
971 d->task 949 d->task =
972 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 950 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
973 &start_fsm, d); 951 d);
974 return; 952 return;
975 } 953 }
976 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) 954 if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0))
@@ -1231,8 +1209,7 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
1231 daemon->phase = SP_TOPOLOGY_SETUP; 1209 daemon->phase = SP_TOPOLOGY_SETUP;
1232 daemon->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); 1210 daemon->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
1233 1211
1234 GNUNET_SCHEDULER_add_continuation (&start_fsm, 1212 GNUNET_SCHEDULER_add_continuation (&start_fsm, daemon,
1235 daemon,
1236 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1213 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1237} 1214}
1238 1215
@@ -1261,12 +1238,9 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon,
1261 */ 1238 */
1262struct GNUNET_TESTING_Daemon * 1239struct GNUNET_TESTING_Daemon *
1263GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg, 1240GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1264 struct GNUNET_TIME_Relative timeout, 1241 struct GNUNET_TIME_Relative timeout, int pretend,
1265 int pretend, 1242 const char *hostname, const char *ssh_username,
1266 const char *hostname, 1243 uint16_t sshport, const char *hostkey,
1267 const char *ssh_username,
1268 uint16_t sshport,
1269 const char *hostkey,
1270 GNUNET_TESTING_NotifyHostkeyCreated 1244 GNUNET_TESTING_NotifyHostkeyCreated
1271 hostkey_callback, void *hostkey_cls, 1245 hostkey_callback, void *hostkey_cls,
1272 GNUNET_TESTING_NotifyDaemonRunning cb, 1246 GNUNET_TESTING_NotifyDaemonRunning cb,
@@ -1295,8 +1269,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1295 1269
1296 /* Find service home and base service home directories, create it if it doesn't exist */ 1270 /* Find service home and base service home directories, create it if it doesn't exist */
1297 GNUNET_assert (GNUNET_OK == 1271 GNUNET_assert (GNUNET_OK ==
1298 GNUNET_CONFIGURATION_get_value_string (cfg, 1272 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS",
1299 "PATHS",
1300 "SERVICEHOME", 1273 "SERVICEHOME",
1301 &servicehome)); 1274 &servicehome));
1302 1275
@@ -1321,9 +1294,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1321 ret->cb_cls = cb_cls; 1294 ret->cb_cls = cb_cls;
1322 ret->max_timeout = GNUNET_TIME_relative_to_absolute (timeout); 1295 ret->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
1323 ret->cfg = GNUNET_CONFIGURATION_dup (cfg); 1296 ret->cfg = GNUNET_CONFIGURATION_dup (cfg);
1324 GNUNET_CONFIGURATION_set_value_string (ret->cfg, 1297 GNUNET_CONFIGURATION_set_value_string (ret->cfg, "PATHS", "DEFAULTCONFIG",
1325 "PATHS", 1298 ret->cfgfile);
1326 "DEFAULTCONFIG", ret->cfgfile);
1327 1299
1328 if (hostkey != NULL) /* Get the peer identity from the hostkey */ 1300 if (hostkey != NULL) /* Get the peer identity from the hostkey */
1329 { 1301 {
@@ -1344,8 +1316,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1344 { 1316 {
1345 GNUNET_asprintf (&hostkeyfile, "%s/.hostkey", servicehome); 1317 GNUNET_asprintf (&hostkeyfile, "%s/.hostkey", servicehome);
1346 fn = GNUNET_DISK_file_open (hostkeyfile, 1318 fn = GNUNET_DISK_file_open (hostkeyfile,
1347 GNUNET_DISK_OPEN_READWRITE 1319 GNUNET_DISK_OPEN_READWRITE |
1348 | GNUNET_DISK_OPEN_CREATE, 1320 GNUNET_DISK_OPEN_CREATE,
1349 GNUNET_DISK_PERM_USER_READ | 1321 GNUNET_DISK_PERM_USER_READ |
1350 GNUNET_DISK_PERM_USER_WRITE); 1322 GNUNET_DISK_PERM_USER_WRITE);
1351 GNUNET_assert (fn != NULL); 1323 GNUNET_assert (fn != NULL);
@@ -1358,8 +1330,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1358 if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile)) 1330 if (GNUNET_OK != GNUNET_CONFIGURATION_write (ret->cfg, ret->cfgfile))
1359 { 1331 {
1360 if (0 != UNLINK (ret->cfgfile)) 1332 if (0 != UNLINK (ret->cfgfile))
1361 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1333 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
1362 "unlink", ret->cfgfile); 1334 ret->cfgfile);
1363 GNUNET_CONFIGURATION_destroy (ret->cfg); 1335 GNUNET_CONFIGURATION_destroy (ret->cfg);
1364 GNUNET_free_non_null (ret->hostname); 1336 GNUNET_free_non_null (ret->hostname);
1365 GNUNET_free (ret->cfgfile); 1337 GNUNET_free (ret->cfgfile);
@@ -1368,11 +1340,10 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1368 } 1340 }
1369 if (ssh_username != NULL) 1341 if (ssh_username != NULL)
1370 username = GNUNET_strdup (ssh_username); 1342 username = GNUNET_strdup (ssh_username);
1371 if ((ssh_username == NULL) && (GNUNET_OK != 1343 if ((ssh_username == NULL) &&
1372 GNUNET_CONFIGURATION_get_value_string (cfg, 1344 (GNUNET_OK !=
1373 "TESTING", 1345 GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "USERNAME",
1374 "USERNAME", 1346 &username)))
1375 &username)))
1376 { 1347 {
1377 if (NULL != getenv ("USER")) 1348 if (NULL != getenv ("USER"))
1378 username = GNUNET_strdup (getenv ("USER")); 1349 username = GNUNET_strdup (getenv ("USER"));
@@ -1420,13 +1391,13 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1420 } 1391 }
1421 else 1392 else
1422 { 1393 {
1423 ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", 1394 ret->proc =
1424 "scp", "-r", "-P", 1395 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", "-P",
1425 ret->ssh_port_str, 1396 ret->ssh_port_str,
1426#if !DEBUG_TESTING 1397#if !DEBUG_TESTING
1427 "-q", 1398 "-q",
1428#endif 1399#endif
1429 servicehome, arg, NULL); 1400 servicehome, arg, NULL);
1430 } 1401 }
1431 GNUNET_free (arg); 1402 GNUNET_free (arg);
1432 if (NULL == ret->proc) 1403 if (NULL == ret->proc)
@@ -1436,25 +1407,25 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1436 ("Could not start `%s' process to copy configuration directory.\n"), 1407 ("Could not start `%s' process to copy configuration directory.\n"),
1437 "scp"); 1408 "scp");
1438 if (0 != UNLINK (ret->cfgfile)) 1409 if (0 != UNLINK (ret->cfgfile))
1439 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1410 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
1440 "unlink", ret->cfgfile); 1411 ret->cfgfile);
1441 GNUNET_CONFIGURATION_destroy (ret->cfg); 1412 GNUNET_CONFIGURATION_destroy (ret->cfg);
1442 GNUNET_free_non_null (ret->hostname); 1413 GNUNET_free_non_null (ret->hostname);
1443 GNUNET_free_non_null (ret->username); 1414 GNUNET_free_non_null (ret->username);
1444 GNUNET_free (ret->cfgfile); 1415 GNUNET_free (ret->cfgfile);
1445 GNUNET_free (ret); 1416 GNUNET_free (ret);
1446 if ((hostkey != NULL) && (0 != UNLINK (hostkeyfile))) 1417 if ((hostkey != NULL) && (0 != UNLINK (hostkeyfile)))
1447 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, 1418 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink",
1448 "unlink", hostkeyfile); 1419 hostkeyfile);
1449 GNUNET_free_non_null (hostkeyfile); 1420 GNUNET_free_non_null (hostkeyfile);
1450 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (servicehome)); 1421 GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (servicehome));
1451 GNUNET_free (servicehome); 1422 GNUNET_free (servicehome);
1452 return NULL; 1423 return NULL;
1453 } 1424 }
1454 1425
1455 ret->task 1426 ret->task =
1456 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 1427 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
1457 &start_fsm, ret); 1428 ret);
1458 GNUNET_free_non_null (hostkeyfile); 1429 GNUNET_free_non_null (hostkeyfile);
1459 GNUNET_free (servicehome); 1430 GNUNET_free (servicehome);
1460 return ret; 1431 return ret;
@@ -1464,8 +1435,7 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
1464 "No need to copy configuration file since we are running locally.\n"); 1435 "No need to copy configuration file since we are running locally.\n");
1465#endif 1436#endif
1466 ret->phase = SP_COPIED; 1437 ret->phase = SP_COPIED;
1467 GNUNET_SCHEDULER_add_continuation (&start_fsm, 1438 GNUNET_SCHEDULER_add_continuation (&start_fsm, ret,
1468 ret,
1469 GNUNET_SCHEDULER_REASON_PREREQ_DONE); 1439 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
1470 } 1440 }
1471 GNUNET_free_non_null (hostkeyfile); 1441 GNUNET_free_non_null (hostkeyfile);
@@ -1520,8 +1490,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
1520 GNUNET_free_non_null (d->hello); 1490 GNUNET_free_non_null (d->hello);
1521 1491
1522#if DEBUG_TESTING 1492#if DEBUG_TESTING
1523 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1493 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
1524 _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); 1494 GNUNET_i2s (&d->id));
1525#endif 1495#endif
1526 1496
1527 d->phase = SP_START_ARMING; 1497 d->phase = SP_START_ARMING;
@@ -1567,9 +1537,8 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
1567 } 1537 }
1568 1538
1569 GNUNET_free_non_null (del_arg); 1539 GNUNET_free_non_null (del_arg);
1570 d->task 1540 d->task =
1571 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 1541 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d);
1572 &start_fsm, d);
1573 1542
1574} 1543}
1575 1544
@@ -1608,8 +1577,8 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
1608 } 1577 }
1609 1578
1610#if DEBUG_TESTING 1579#if DEBUG_TESTING
1611 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1580 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
1612 _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); 1581 GNUNET_i2s (&d->id));
1613#endif 1582#endif
1614 if (d->churned_services != NULL) 1583 if (d->churned_services != NULL)
1615 { 1584 {
@@ -1698,8 +1667,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1698 if (NULL != d->cb) 1667 if (NULL != d->cb)
1699 { 1668 {
1700#if DEBUG_TESTING 1669#if DEBUG_TESTING
1701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1670 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Setting d->dead on peer `%4s'\n"),
1702 _("Setting d->dead on peer `%4s'\n"), GNUNET_i2s (&d->id)); 1671 GNUNET_i2s (&d->id));
1703#endif 1672#endif
1704 d->dead = GNUNET_YES; 1673 d->dead = GNUNET_YES;
1705 return; 1674 return;
@@ -1746,8 +1715,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1746 */ 1715 */
1747 /* shutdown ARM process (will terminate others) */ 1716 /* shutdown ARM process (will terminate others) */
1748#if DEBUG_TESTING 1717#if DEBUG_TESTING
1749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1718 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
1750 _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); 1719 GNUNET_i2s (&d->id));
1751#endif 1720#endif
1752 d->phase = SP_SHUTDOWN_START; 1721 d->phase = SP_SHUTDOWN_START;
1753 d->running = GNUNET_NO; 1722 d->running = GNUNET_NO;
@@ -1781,8 +1750,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1781#if DEBUG_TESTING 1750#if DEBUG_TESTING
1782 "-L", "DEBUG", 1751 "-L", "DEBUG",
1783#endif 1752#endif
1784 "-c", d->cfgfile, "-e", "-q", 1753 "-c", d->cfgfile, "-e", "-q", "-T",
1785 "-T",
1786 GNUNET_TIME_relative_to_string (timeout), 1754 GNUNET_TIME_relative_to_string (timeout),
1787 del_arg, NULL); 1755 del_arg, NULL);
1788 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1801,8 +1769,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1801#if DEBUG_TESTING 1769#if DEBUG_TESTING
1802 "-L", "DEBUG", 1770 "-L", "DEBUG",
1803#endif 1771#endif
1804 "-c", d->cfgfile, "-e", "-q", 1772 "-c", d->cfgfile, "-e", "-q", "-T",
1805 "-T",
1806 GNUNET_TIME_relative_to_string (timeout), 1773 GNUNET_TIME_relative_to_string (timeout),
1807 del_arg, NULL); 1774 del_arg, NULL);
1808 } 1775 }
@@ -1873,8 +1840,7 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
1873 if (NULL == d->proc) 1840 if (NULL == d->proc)
1874 { 1841 {
1875 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1842 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1876 _ 1843 _("Could not start `%s' process to copy configuration file.\n"),
1877 ("Could not start `%s' process to copy configuration file.\n"),
1878 "scp"); 1844 "scp");
1879 if (NULL != cb) 1845 if (NULL != cb)
1880 cb (cb_cls, _("Failed to copy new configuration to remote machine.")); 1846 cb (cb_cls, _("Failed to copy new configuration to remote machine."));
@@ -1883,9 +1849,8 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
1883 } 1849 }
1884 d->update_cb = cb; 1850 d->update_cb = cb;
1885 d->update_cb_cls = cb_cls; 1851 d->update_cb_cls = cb_cls;
1886 d->task 1852 d->task =
1887 = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, 1853 GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm, d);
1888 &start_fsm, d);
1889} 1854}
1890 1855
1891 1856
@@ -1981,9 +1946,9 @@ struct ConnectContext
1981 1946
1982 1947
1983/** Forward declaration **/ 1948/** Forward declaration **/
1984static void 1949static void reattempt_daemons_connect (void *cls,
1985reattempt_daemons_connect (void *cls, 1950 const struct GNUNET_SCHEDULER_TaskContext
1986 const struct GNUNET_SCHEDULER_TaskContext *tc); 1951 *tc);
1987 1952
1988 1953
1989/** 1954/**
@@ -2039,10 +2004,7 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2039 { 2004 {
2040 if (ctx->cb != NULL) 2005 if (ctx->cb != NULL)
2041 { 2006 {
2042 ctx->cb (ctx->cb_cls, 2007 ctx->cb (ctx->cb_cls, &ctx->d1->id, &ctx->d2->id, ctx->distance,
2043 &ctx->d1->id,
2044 &ctx->d2->id,
2045 ctx->distance,
2046 ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, NULL); 2008 ctx->d1->cfg, ctx->d2->cfg, ctx->d1, ctx->d2, NULL);
2047 } 2009 }
2048 } 2010 }
@@ -2081,15 +2043,13 @@ notify_connect_result (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2081 * 2043 *
2082 */ 2044 */
2083static void 2045static void
2084connect_notify (void *cls, 2046connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
2085 const struct GNUNET_PeerIdentity *peer,
2086 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 2047 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
2087{ 2048{
2088 struct ConnectContext *ctx = cls; 2049 struct ConnectContext *ctx = cls;
2089 2050
2090#if DEBUG_TESTING 2051#if DEBUG_TESTING
2091 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2052 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Connected peer %s to peer %s\n",
2092 "Connected peer %s to peer %s\n",
2093 ctx->d1->shortname, GNUNET_i2s (peer)); 2053 ctx->d1->shortname, GNUNET_i2s (peer));
2094#endif 2054#endif
2095 2055
@@ -2118,8 +2078,7 @@ connect_notify (void *cls,
2118 * 2078 *
2119 */ 2079 */
2120static void 2080static void
2121connect_notify_core2 (void *cls, 2081connect_notify_core2 (void *cls, const struct GNUNET_PeerIdentity *peer,
2122 const struct GNUNET_PeerIdentity *peer,
2123 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 2082 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
2124{ 2083{
2125 struct ConnectContext *ctx = cls; 2084 struct ConnectContext *ctx = cls;
@@ -2158,9 +2117,9 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2158 ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK; 2117 ctx->hello_send_task = GNUNET_SCHEDULER_NO_TASK;
2159 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 2118 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
2160 return; 2119 return;
2161 if ((ctx->d1core_ready == GNUNET_YES) && (ctx->d2->hello != NULL) 2120 if ((ctx->d1core_ready == GNUNET_YES) && (ctx->d2->hello != NULL) &&
2162 && (NULL != GNUNET_HELLO_get_header (ctx->d2->hello)) 2121 (NULL != GNUNET_HELLO_get_header (ctx->d2->hello)) &&
2163 && (ctx->d1->phase == SP_START_DONE) && (ctx->d2->phase == SP_START_DONE)) 2122 (ctx->d1->phase == SP_START_DONE) && (ctx->d2->phase == SP_START_DONE))
2164 { 2123 {
2165 hello = GNUNET_HELLO_get_header (ctx->d2->hello); 2124 hello = GNUNET_HELLO_get_header (ctx->d2->hello);
2166 GNUNET_assert (hello != NULL); 2125 GNUNET_assert (hello != NULL);
@@ -2171,8 +2130,7 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2171 GNUNET_TRANSPORT_offer_hello (ctx->d1th, hello, NULL, NULL); 2130 GNUNET_TRANSPORT_offer_hello (ctx->d1th, hello, NULL, NULL);
2172 GNUNET_assert (ctx->d1core != NULL); 2131 GNUNET_assert (ctx->d1core != NULL);
2173 ctx->connect_request_handle = 2132 ctx->connect_request_handle =
2174 GNUNET_CORE_peer_request_connect (ctx->d1core, 2133 GNUNET_CORE_peer_request_connect (ctx->d1core, &ctx->d2->id,
2175 &ctx->d2->id,
2176 &core_connect_request_cont, ctx); 2134 &core_connect_request_cont, ctx);
2177 2135
2178#if DEBUG_TESTING 2136#if DEBUG_TESTING
@@ -2186,8 +2144,8 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2186 GNUNET_TIME_relative_multiply 2144 GNUNET_TIME_relative_multiply
2187 (GNUNET_TIME_UNIT_MILLISECONDS, 500)); 2145 (GNUNET_TIME_UNIT_MILLISECONDS, 500));
2188 } 2146 }
2189 ctx->hello_send_task = GNUNET_SCHEDULER_add_delayed (ctx->timeout_hello, 2147 ctx->hello_send_task =
2190 &send_hello, ctx); 2148 GNUNET_SCHEDULER_add_delayed (ctx->timeout_hello, &send_hello, ctx);
2191} 2149}
2192 2150
2193/** 2151/**
@@ -2199,11 +2157,10 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
2199 * @param publicKey the public key of the peer 2157 * @param publicKey the public key of the peer
2200 */ 2158 */
2201void 2159void
2202core_init_notify (void *cls, 2160core_init_notify (void *cls, struct GNUNET_CORE_Handle *server,
2203 struct GNUNET_CORE_Handle *server,
2204 const struct GNUNET_PeerIdentity *my_identity, 2161 const struct GNUNET_PeerIdentity *my_identity,
2205 const struct 2162 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
2206 GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 2163 *publicKey)
2207{ 2164{
2208 struct ConnectContext *connect_ctx = cls; 2165 struct ConnectContext *connect_ctx = cls;
2209 2166
@@ -2246,12 +2203,10 @@ reattempt_daemons_connect (void *cls,
2246 ctx->connect_attempts--; 2203 ctx->connect_attempts--;
2247 GNUNET_assert (ctx->d1core == NULL); 2204 GNUNET_assert (ctx->d1core == NULL);
2248 ctx->d1core_ready = GNUNET_NO; 2205 ctx->d1core_ready = GNUNET_NO;
2249 ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, 2206 ctx->d1core =
2250 ctx, 2207 GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
2251 &core_init_notify, 2208 &connect_notify, NULL, NULL, NULL, GNUNET_NO, NULL,
2252 &connect_notify, NULL, NULL, 2209 GNUNET_NO, no_handlers);
2253 NULL, GNUNET_NO,
2254 NULL, GNUNET_NO, no_handlers);
2255 if (ctx->d1core == NULL) 2210 if (ctx->d1core == NULL)
2256 { 2211 {
2257 if (NULL != ctx->cb) 2212 if (NULL != ctx->cb)
@@ -2299,9 +2254,9 @@ reattempt_daemons_connect (void *cls,
2299 2254
2300 if (ctx->send_hello == GNUNET_YES) 2255 if (ctx->send_hello == GNUNET_YES)
2301 { 2256 {
2302 ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, 2257 ctx->d1th =
2303 &ctx->d1->id, 2258 GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL,
2304 ctx->d1, NULL, NULL, NULL); 2259 NULL, NULL);
2305 if (ctx->d1th == NULL) 2260 if (ctx->d1th == NULL)
2306 { 2261 {
2307 GNUNET_CORE_disconnect (ctx->d1core); 2262 GNUNET_CORE_disconnect (ctx->d1core);
@@ -2317,8 +2272,7 @@ reattempt_daemons_connect (void *cls,
2317 else 2272 else
2318 { 2273 {
2319 ctx->connect_request_handle = 2274 ctx->connect_request_handle =
2320 GNUNET_CORE_peer_request_connect (ctx->d1core, 2275 GNUNET_CORE_peer_request_connect (ctx->d1core, &ctx->d2->id,
2321 &ctx->d2->id,
2322 &core_connect_request_cont, ctx); 2276 &core_connect_request_cont, ctx);
2323 } 2277 }
2324 ctx->timeout_task = 2278 ctx->timeout_task =
@@ -2338,8 +2292,7 @@ reattempt_daemons_connect (void *cls,
2338 * 2292 *
2339 */ 2293 */
2340static void 2294static void
2341core_initial_iteration (void *cls, 2295core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer,
2342 const struct GNUNET_PeerIdentity *peer,
2343 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 2296 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
2344{ 2297{
2345 struct ConnectContext *ctx = cls; 2298 struct ConnectContext *ctx = cls;
@@ -2355,8 +2308,8 @@ core_initial_iteration (void *cls,
2355 { 2308 {
2356 if (ctx->connected == GNUNET_YES) 2309 if (ctx->connected == GNUNET_YES)
2357 { 2310 {
2358 ctx->timeout_task = GNUNET_SCHEDULER_add_now (&notify_connect_result, 2311 ctx->timeout_task =
2359 ctx); 2312 GNUNET_SCHEDULER_add_now (&notify_connect_result, ctx);
2360 return; 2313 return;
2361 } 2314 }
2362 2315
@@ -2367,12 +2320,10 @@ core_initial_iteration (void *cls,
2367 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2320 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2368 "Peers are NOT connected, connecting to core!\n"); 2321 "Peers are NOT connected, connecting to core!\n");
2369#endif 2322#endif
2370 ctx->d1core = GNUNET_CORE_connect (ctx->d1->cfg, 1, 2323 ctx->d1core =
2371 ctx, 2324 GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
2372 &core_init_notify, 2325 &connect_notify, NULL, NULL, NULL, GNUNET_NO,
2373 &connect_notify, NULL, NULL, 2326 NULL, GNUNET_NO, no_handlers);
2374 NULL, GNUNET_NO,
2375 NULL, GNUNET_NO, no_handlers);
2376 } 2327 }
2377 2328
2378 if (ctx->d1core == NULL) 2329 if (ctx->d1core == NULL)
@@ -2405,9 +2356,9 @@ core_initial_iteration (void *cls,
2405 2356
2406 if (ctx->send_hello == GNUNET_YES) 2357 if (ctx->send_hello == GNUNET_YES)
2407 { 2358 {
2408 ctx->d1th = GNUNET_TRANSPORT_connect (ctx->d1->cfg, 2359 ctx->d1th =
2409 &ctx->d1->id, ctx->d1, NULL, NULL, 2360 GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL,
2410 NULL); 2361 NULL, NULL);
2411 if (ctx->d1th == NULL) 2362 if (ctx->d1th == NULL)
2412 { 2363 {
2413 GNUNET_CORE_disconnect (ctx->d1core); 2364 GNUNET_CORE_disconnect (ctx->d1core);
@@ -2475,8 +2426,7 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
2475 ctx->connected = GNUNET_NO; 2426 ctx->connected = GNUNET_NO;
2476 ctx->send_hello = send_hello; 2427 ctx->send_hello = send_hello;
2477#if DEBUG_TESTING 2428#if DEBUG_TESTING
2478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2429 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s\n",
2479 "Asked to connect peer %s to peer %s\n",
2480 d1->shortname, d2->shortname); 2430 d1->shortname, d2->shortname);
2481#endif 2431#endif
2482 2432