diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-03-14 20:23:08 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-03-14 20:23:08 +0000 |
commit | 704fb68a88a7202129daff80ef0e123b39b7bfac (patch) | |
tree | 6c9ab11d2b70f4e2e6414a6790779928f1a276e0 /src/testing | |
parent | 0e5d6d6af784d531eedc0f9b661d0ed727d90782 (diff) | |
download | gnunet-704fb68a88a7202129daff80ef0e123b39b7bfac.tar.gz gnunet-704fb68a88a7202129daff80ef0e123b39b7bfac.zip |
schedule task instead of waitpid
Diffstat (limited to 'src/testing')
-rw-r--r-- | src/testing/testing_group.c | 77 |
1 files changed, 42 insertions, 35 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 9fdee3a13..8fb21d01a 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -26,6 +26,7 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | #include "platform.h" | 28 | #include "platform.h" |
29 | #include "gnunet_constants.h" | ||
29 | #include "gnunet_arm_service.h" | 30 | #include "gnunet_arm_service.h" |
30 | #include "gnunet_testing_lib.h" | 31 | #include "gnunet_testing_lib.h" |
31 | #include "gnunet_core_service.h" | 32 | #include "gnunet_core_service.h" |
@@ -5583,43 +5584,24 @@ struct PeerStartHelperContext | |||
5583 | struct GNUNET_TESTING_PeerGroup *pg; | 5584 | struct GNUNET_TESTING_PeerGroup *pg; |
5584 | 5585 | ||
5585 | struct HostData *host; | 5586 | struct HostData *host; |
5587 | |||
5588 | struct GNUNET_OS_Process *proc; | ||
5586 | }; | 5589 | }; |
5587 | 5590 | ||
5588 | static void | 5591 | static void |
5589 | start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 5592 | check_peers_started (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
5590 | { | 5593 | { |
5591 | struct PeerStartHelperContext *helper = cls; | 5594 | struct PeerStartHelperContext *helper = cls; |
5592 | char *baseservicehome; | ||
5593 | char *tempdir; | ||
5594 | struct GNUNET_OS_Process *proc; | ||
5595 | unsigned int i; | ||
5596 | char *arg; | ||
5597 | enum GNUNET_OS_ProcessStatusType type; | 5595 | enum GNUNET_OS_ProcessStatusType type; |
5598 | unsigned long code; | 5596 | unsigned long code; |
5597 | unsigned int i; | ||
5599 | GNUNET_TESTING_NotifyDaemonRunning cb; | 5598 | GNUNET_TESTING_NotifyDaemonRunning cb; |
5600 | /* ssh user@host peerStartHelper /path/to/basedirectory */ | ||
5601 | 5599 | ||
5602 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (helper->pg->cfg, "PATHS", "SERVICEHOME", | 5600 | if (GNUNET_NO == GNUNET_OS_process_status (helper->proc, &type, &code)) /* Still running, wait some more! */ |
5603 | &baseservicehome)); | 5601 | { |
5604 | GNUNET_asprintf(&tempdir, "%s/%s/", baseservicehome, helper->host->hostname); | 5602 | GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_EXEC_WAIT, &check_peers_started, helper); |
5605 | if (NULL != helper->host->username) | 5603 | return; |
5606 | GNUNET_asprintf (&arg, "%s@%s", helper->host->username, helper->host->hostname); | 5604 | } |
5607 | else | ||
5608 | GNUNET_asprintf (&arg, "%s", helper->host->hostname); | ||
5609 | |||
5610 | /* FIXME: Doesn't support ssh_port option! */ | ||
5611 | proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, | ||
5612 | "peerStartHelper.pl", tempdir, NULL); | ||
5613 | |||
5614 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "starting peers with cmd ssh %s %s %s\n", arg, "peerStartHelper.pl", tempdir); | ||
5615 | |||
5616 | GNUNET_OS_process_wait (proc); | ||
5617 | if (GNUNET_OK != GNUNET_OS_process_status (proc, &type, &code)) | ||
5618 | code = 1; | ||
5619 | GNUNET_OS_process_close(proc); | ||
5620 | GNUNET_free (tempdir); | ||
5621 | GNUNET_free (baseservicehome); | ||
5622 | GNUNET_free (arg); | ||
5623 | 5605 | ||
5624 | helper->pg->starting--; | 5606 | helper->pg->starting--; |
5625 | if (helper->pg->starting == 0) /* All peers have finished starting! */ | 5607 | if (helper->pg->starting == 0) /* All peers have finished starting! */ |
@@ -5633,12 +5615,10 @@ start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5633 | if (NULL != cb) | 5615 | if (NULL != cb) |
5634 | { | 5616 | { |
5635 | if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) | 5617 | if ((type != GNUNET_OS_PROCESS_EXITED) || (code != 0)) |
5636 | { | 5618 | cb (helper->pg->peers[i].daemon->cb_cls, |
5637 | cb (helper->pg->peers[i].daemon->cb_cls, | 5619 | &helper->pg->peers[i].daemon->id, |
5638 | &helper->pg->peers[i].daemon->id, | 5620 | helper->pg->peers[i].daemon->cfg, helper->pg->peers[i].daemon, |
5639 | helper->pg->peers[i].daemon->cfg, helper->pg->peers[i].daemon, | 5621 | "Failed to execute peerStartHelper.pl, or return code bad!"); |
5640 | "Failed to execute peerStartHelper.pl, or return code bad!"); | ||
5641 | } | ||
5642 | else | 5622 | else |
5643 | cb (helper->pg->peers[i].daemon->cb_cls, | 5623 | cb (helper->pg->peers[i].daemon->cb_cls, |
5644 | &helper->pg->peers[i].daemon->id, | 5624 | &helper->pg->peers[i].daemon->id, |
@@ -5649,7 +5629,34 @@ start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5649 | 5629 | ||
5650 | } | 5630 | } |
5651 | } | 5631 | } |
5632 | GNUNET_OS_process_close(helper->proc); | ||
5633 | } | ||
5652 | 5634 | ||
5635 | static void | ||
5636 | start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
5637 | { | ||
5638 | struct PeerStartHelperContext *helper = cls; | ||
5639 | char *baseservicehome; | ||
5640 | char *tempdir; | ||
5641 | char *arg; | ||
5642 | /* ssh user@host peerStartHelper /path/to/basedirectory */ | ||
5643 | GNUNET_assert(GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (helper->pg->cfg, "PATHS", "SERVICEHOME", | ||
5644 | &baseservicehome)); | ||
5645 | GNUNET_asprintf(&tempdir, "%s/%s/", baseservicehome, helper->host->hostname); | ||
5646 | if (NULL != helper->host->username) | ||
5647 | GNUNET_asprintf (&arg, "%s@%s", helper->host->username, helper->host->hostname); | ||
5648 | else | ||
5649 | GNUNET_asprintf (&arg, "%s", helper->host->hostname); | ||
5650 | |||
5651 | /* FIXME: Doesn't support ssh_port option! */ | ||
5652 | helper->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, | ||
5653 | "peerStartHelper.pl", tempdir, NULL); | ||
5654 | |||
5655 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "starting peers with cmd ssh %s %s %s\n", arg, "peerStartHelper.pl", tempdir); | ||
5656 | GNUNET_SCHEDULER_add_now (&check_peers_started, helper); | ||
5657 | GNUNET_free (tempdir); | ||
5658 | GNUNET_free (baseservicehome); | ||
5659 | GNUNET_free (arg); | ||
5653 | } | 5660 | } |
5654 | #endif | 5661 | #endif |
5655 | 5662 | ||
@@ -6029,7 +6036,7 @@ GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
6029 | { | 6036 | { |
6030 | for (off = 0; off < hostcnt; off++) | 6037 | for (off = 0; off < hostcnt; off++) |
6031 | { | 6038 | { |
6032 | GNUNET_asprintf(&newservicehome, "%s/%s", baseservicehome, pg->hosts[off].hostname); | 6039 | GNUNET_asprintf(&newservicehome, "%s/%s/*", baseservicehome, pg->hosts[off].hostname); |
6033 | 6040 | ||
6034 | if (NULL != username) | 6041 | if (NULL != username) |
6035 | GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostname, baseservicehome); | 6042 | GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostname, baseservicehome); |