diff options
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 96 |
1 files changed, 77 insertions, 19 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 4ece9359d..8156e6a0a 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -283,14 +283,28 @@ start_fsm (void *cls, | |||
283 | "gnunet-peerinfo", "ssh", dst, "gnunet-peerinfo", "-c", d->cfgfile, | 283 | "gnunet-peerinfo", "ssh", dst, "gnunet-peerinfo", "-c", d->cfgfile, |
284 | "-sq"); | 284 | "-sq"); |
285 | #endif | 285 | #endif |
286 | d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", | 286 | if (d->ssh_port_str == NULL) |
287 | "ssh", | 287 | { |
288 | d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", | ||
289 | "ssh", | ||
288 | #if !DEBUG_TESTING | 290 | #if !DEBUG_TESTING |
289 | "-q", | 291 | "-q", |
290 | #endif | 292 | #endif |
291 | dst, | 293 | dst, |
292 | "gnunet-peerinfo", | 294 | "gnunet-peerinfo", |
293 | "-c", d->cfgfile, "-sq", NULL); | 295 | "-c", d->cfgfile, "-sq", NULL); |
296 | } | ||
297 | else | ||
298 | { | ||
299 | d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", | ||
300 | "ssh", "-p", d->ssh_port_str, | ||
301 | #if !DEBUG_TESTING | ||
302 | "-q", | ||
303 | #endif | ||
304 | dst, | ||
305 | "gnunet-peerinfo", | ||
306 | "-c", d->cfgfile, "-sq", NULL); | ||
307 | } | ||
294 | GNUNET_DISK_pipe_close_end(d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); | 308 | GNUNET_DISK_pipe_close_end(d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); |
295 | GNUNET_free (dst); | 309 | GNUNET_free (dst); |
296 | } | 310 | } |
@@ -446,17 +460,35 @@ start_fsm (void *cls, | |||
446 | "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile, | 460 | "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile, |
447 | "-L", "DEBUG", "-s", "-q"); | 461 | "-L", "DEBUG", "-s", "-q"); |
448 | #endif | 462 | #endif |
449 | d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", | 463 | if (d->ssh_port_str == NULL) |
450 | "ssh", | 464 | { |
465 | d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", | ||
466 | "ssh", | ||
451 | #if !DEBUG_TESTING | 467 | #if !DEBUG_TESTING |
452 | "-q", | 468 | "-q", |
453 | #endif | 469 | #endif |
454 | dst, | 470 | dst, |
455 | "gnunet-arm", | 471 | "gnunet-arm", |
456 | #if DEBUG_TESTING | 472 | #if DEBUG_TESTING |
457 | "-L", "DEBUG", | 473 | "-L", "DEBUG", |
458 | #endif | 474 | #endif |
459 | "-c", d->cfgfile, "-s", "-q", NULL); | 475 | "-c", d->cfgfile, "-s", "-q", NULL); |
476 | } | ||
477 | else | ||
478 | { | ||
479 | |||
480 | d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", | ||
481 | "ssh", "-p", d->ssh_port_str, | ||
482 | #if !DEBUG_TESTING | ||
483 | "-q", | ||
484 | #endif | ||
485 | dst, | ||
486 | "gnunet-arm", | ||
487 | #if DEBUG_TESTING | ||
488 | "-L", "DEBUG", | ||
489 | #endif | ||
490 | "-c", d->cfgfile, "-s", "-q", NULL); | ||
491 | } | ||
460 | GNUNET_free (dst); | 492 | GNUNET_free (dst); |
461 | } | 493 | } |
462 | if (-1 == d->pid) | 494 | if (-1 == d->pid) |
@@ -708,6 +740,8 @@ GNUNET_TESTING_daemon_start_stopped (struct GNUNET_TESTING_Daemon *daemon, | |||
708 | * @param timeout how long to wait starting up peers | 740 | * @param timeout how long to wait starting up peers |
709 | * @param hostname name of the machine where to run GNUnet | 741 | * @param hostname name of the machine where to run GNUnet |
710 | * (use NULL for localhost). | 742 | * (use NULL for localhost). |
743 | * @param ssh_username ssh username to use when connecting to hostname | ||
744 | * @param sshport port to pass to ssh process when connecting to hostname | ||
711 | * @param hostkey_callback function to call once the hostkey has been | 745 | * @param hostkey_callback function to call once the hostkey has been |
712 | * generated for this peer, but it hasn't yet been started | 746 | * generated for this peer, but it hasn't yet been started |
713 | * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start) | 747 | * (NULL to start immediately, otherwise waits on GNUNET_TESTING_daemon_continue_start) |
@@ -721,6 +755,8 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
721 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 755 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
722 | struct GNUNET_TIME_Relative timeout, | 756 | struct GNUNET_TIME_Relative timeout, |
723 | const char *hostname, | 757 | const char *hostname, |
758 | const char *ssh_username, | ||
759 | uint16_t sshport, | ||
724 | GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, | 760 | GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, |
725 | void *hostkey_cls, | 761 | void *hostkey_cls, |
726 | GNUNET_TESTING_NotifyDaemonRunning cb, | 762 | GNUNET_TESTING_NotifyDaemonRunning cb, |
@@ -733,6 +769,12 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
733 | ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon)); | 769 | ret = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Daemon)); |
734 | ret->sched = sched; | 770 | ret->sched = sched; |
735 | ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); | 771 | ret->hostname = (hostname == NULL) ? NULL : GNUNET_strdup (hostname); |
772 | if (sshport != 0) | ||
773 | { | ||
774 | GNUNET_asprintf(&ret->ssh_port_str, "%d", sshport); | ||
775 | } | ||
776 | else | ||
777 | ret->ssh_port_str = NULL; | ||
736 | ret->cfgfile = GNUNET_DISK_mktemp ("gnunet-testing-config"); | 778 | ret->cfgfile = GNUNET_DISK_mktemp ("gnunet-testing-config"); |
737 | #if DEBUG_TESTING | 779 | #if DEBUG_TESTING |
738 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 780 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -766,10 +808,12 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
766 | GNUNET_free (ret); | 808 | GNUNET_free (ret); |
767 | return NULL; | 809 | return NULL; |
768 | } | 810 | } |
769 | if (GNUNET_OK != | 811 | if (ssh_username != NULL) |
812 | username = GNUNET_strdup(ssh_username); | ||
813 | if ((ssh_username == NULL) && (GNUNET_OK != | ||
770 | GNUNET_CONFIGURATION_get_value_string (cfg, | 814 | GNUNET_CONFIGURATION_get_value_string (cfg, |
771 | "TESTING", | 815 | "TESTING", |
772 | "USERNAME", &username)) | 816 | "USERNAME", &username))) |
773 | { | 817 | { |
774 | if (NULL != getenv ("USER")) | 818 | if (NULL != getenv ("USER")) |
775 | username = GNUNET_strdup (getenv ("USER")); | 819 | username = GNUNET_strdup (getenv ("USER")); |
@@ -790,12 +834,25 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
790 | GNUNET_asprintf (&arg, "%s@%s:%s", username, hostname, ret->cfgfile); | 834 | GNUNET_asprintf (&arg, "%s@%s:%s", username, hostname, ret->cfgfile); |
791 | else | 835 | else |
792 | GNUNET_asprintf (&arg, "%s:%s", hostname, ret->cfgfile); | 836 | GNUNET_asprintf (&arg, "%s:%s", hostname, ret->cfgfile); |
793 | ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp", | 837 | |
794 | "scp", | 838 | if (ret->ssh_port_str == NULL) |
839 | { | ||
840 | ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp", | ||
841 | "scp", | ||
795 | #if !DEBUG_TESTING | 842 | #if !DEBUG_TESTING |
796 | "-q", | 843 | "-q", |
797 | #endif | 844 | #endif |
798 | ret->cfgfile, arg, NULL); | 845 | ret->cfgfile, arg, NULL); |
846 | } | ||
847 | else | ||
848 | { | ||
849 | ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp", | ||
850 | "scp", "-P", ret->ssh_port_str, | ||
851 | #if !DEBUG_TESTING | ||
852 | "-q", | ||
853 | #endif | ||
854 | ret->cfgfile, arg, NULL); | ||
855 | } | ||
799 | GNUNET_free (arg); | 856 | GNUNET_free (arg); |
800 | if (-1 == ret->pid) | 857 | if (-1 == ret->pid) |
801 | { | 858 | { |
@@ -983,6 +1040,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
983 | GNUNET_free_non_null (d->username); | 1040 | GNUNET_free_non_null (d->username); |
984 | if (NULL != d->dead_cb) | 1041 | if (NULL != d->dead_cb) |
985 | d->dead_cb (d->dead_cb_cls, NULL); | 1042 | d->dead_cb (d->dead_cb_cls, NULL); |
1043 | GNUNET_free(d); | ||
986 | return; | 1044 | return; |
987 | } | 1045 | } |
988 | 1046 | ||