*/
INIT,
- /**
- * Doing registration
- */
- REGISTERING,
-
/**
* Connecting to slave controller
*/
- LINKING
+ LINKING,
+
+ CREATING_PEER,
+
+ STARTING_PEER,
};
+
/**
- * Various states during test setup
+ * Event Mask for operation callbacks
*/
-// static enum SetupState setup_state;
-
-
uint64_t event_mask;
/**
*
* @param cls the closure from GNUNET_STREAM_shutdown call
* @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
- * SHUT_RDWR)
+ * SHUT_RDWR)
*/
-// static void
+// static void
// shutdown_completion (void *cls,
// int operation)
// {
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n");
result = GNUNET_SYSERR;
- abort_task = 0;
+ abort_task = 0;
}
/**
* Adapter function called to destroy a connection to
* a service.
- *
+ *
* @param cls closure
* @param op_result service handle returned from the connect adapter
*/
// {
// struct GNUNET_STREAM_ListenSocket *lsocket;
// struct GNUNET_STREAM_Socket *socket;
-//
+//
// if (&peer1 == cls)
// {
// lsocket = op_result;
/**
* Adapter function called to establish a connection to
* a service.
- *
+ *
* @param cls closure
* @param cfg configuration of the peer to connect to; will be available until
* GNUNET_TESTBED_operation_done() is called on the operation returned
* from GNUNET_TESTBED_service_connect()
* @return service handle to return in 'op_result', NULL on error
*/
-// static void *
+// static void *
// stream_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
-// {
+// {
// struct GNUNET_STREAM_ListenSocket *lsocket;
-//
+//
// switch (setup_state)
// {
// case PEER1_STREAM_CONNECT:
*/
// static void
// stream_connect (void)
-// {
+// {
// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n");
// peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream",
// NULL, NULL,
* @param emsg error message if the operation has failed; will be NULL if the
* operation is successfull
*/
-// static void
+// static void
// peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
// const struct GNUNET_TESTBED_PeerInformation *pinfo,
// const char *emsg)
// switch (setup_state)
// {
// case PEER1_GET_IDENTITY:
-// memcpy (&peer1.our_id, pinfo->result.id,
+// memcpy (&peer1.our_id, pinfo->result.id,
// sizeof (struct GNUNET_PeerIdentity));
// GNUNET_TESTBED_operation_done (op);
// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
// break;
// case GNUNET_TESTBED_ET_OPERATION_FINISHED:
// switch (setup_state)
-// {
+// {
// case PEER1_STREAM_CONNECT:
// case PEER2_STREAM_CONNECT:
// GNUNET_assert (NULL == event->details.operation_finished.emsg);
long i = (long) cls;
long peer_id;
- GNUNET_TESTBED_operation_done(op[i]);
+// GNUNET_TESTBED_operation_done(op[i]);
peer_id = i; // FIXME A * i + B
peers[peer_id] = peer;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer created\n");
op[i] = GNUNET_TESTBED_peer_start (peer, peer_start_cb, (void *) i);
}
+
/**
* Signature of the event handler function called by the
* respective event controller.
{
case INIT:
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Init\n");
+ break;
+ case LINKING:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Link\n");
+ state[i] = CREATING_PEER;
op[i] = GNUNET_TESTBED_peer_create (master_ctrl,
slave_hosts[i],
cfg,
peer_create_cb,
(void *) i);
break;
- case REGISTERING:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Register\n");
- state[i] = LINKING;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking host %u\n", i);
- op[i] = GNUNET_TESTBED_controller_link (master_ctrl, slave_hosts[i],
- (void *) (long) i, cfg, GNUNET_YES);
- break;
- case LINKING:
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Link\n");
+ case CREATING_PEER:
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Peer create\n");
break;
default:
GNUNET_break (0);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
GNUNET_assert (0);
}
+
+ state[host_registered] = LINKING;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ " Linking host %u\n", host_registered);
+ op[host_registered] = GNUNET_TESTBED_controller_link (master_ctrl,
+ slave_hosts[host_registered],
+ NULL,
+ cfg,
+ GNUNET_YES);
+
host_registered++;
if (NUM_HOSTS != host_registered)
{
slave_hosts[host_registered],
®istration_cont,
NULL);
- state[host_registered] = REGISTERING;
return;
}
}
{
unsigned int i;
+ if (NULL == config)
+ return;
+
event_mask = 0;
event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START);
event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
rh = GNUNET_TESTBED_register_host (master_ctrl, slave_hosts[0],
®istration_cont,
NULL);
- state[0] = REGISTERING;
GNUNET_assert (NULL != rh);
}
int main (int argc, char **argv)
{
int ret;
+ int test_hosts;
+ unsigned int i;
+
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
NULL
};
+ test_hosts = GNUNET_OK;
+ for (i = 0; i < NUM_HOSTS; i++)
+ {
+ char *const remote_args[] = {
+ "ssh", "-o", "BatchMode=yes", slave_ips[i],
+ ". .bashrc; gnunet-helper-testbed --help > /dev/null", NULL
+ };
+ struct GNUNET_OS_Process *auxp;
+ enum GNUNET_OS_ProcessStatusType type;
+ unsigned long code;
+
+ fprintf (stderr, "Testing host %i\n", i);
+ auxp =
+ GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
+ NULL, "ssh", remote_args);
+ GNUNET_assert (NULL != auxp);
+ do
+ {
+ ret = GNUNET_OS_process_status (auxp, &type, &code);
+ GNUNET_assert (GNUNET_SYSERR != ret);
+ (void) usleep (300);
+ }
+ while (GNUNET_NO == ret);
+ (void) GNUNET_OS_process_wait (auxp);
+ GNUNET_OS_process_destroy (auxp);
+ if (0 != code)
+ {
+ fprintf (stderr,
+ "Unable to run the test as this system is not configured "
+ "to use password less SSH logins to host %s.\n",
+ slave_ips[i]);
+ test_hosts = GNUNET_SYSERR;
+ }
+ }
+ if (test_hosts != GNUNET_OK)
+ {
+ fprintf (stderr, "Some hosts have failed the ssh check. Exiting.\n");
+ return 1;
+ }
+ fprintf (stderr, "START.\n");
+
result = GNUNET_SYSERR;
ret =
GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
"test_regex_big", "nohelp", options,
&run, NULL);
-
- if (GNUNET_SYSERR == result || 0 != ret)
+
+ fprintf (stderr, "END.\n");
+
+ if (GNUNET_SYSERR == result || GNUNET_OK != ret)
return 1;
return 0;
}