aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorMaximilian Szengel <gnunet@maxsz.de>2012-09-28 10:31:46 +0000
committerMaximilian Szengel <gnunet@maxsz.de>2012-09-28 10:31:46 +0000
commitbe68368adc61a1bf1d970257537ca8ae7a3cff37 (patch)
tree01d64009796a656a333d875f5c7aab69f950852c /src/regex
parent681058cd584808a01388ecbf120ea74c1a4e334f (diff)
downloadgnunet-be68368adc61a1bf1d970257537ca8ae7a3cff37.tar.gz
gnunet-be68368adc61a1bf1d970257537ca8ae7a3cff37.zip
- ssh check for all hosts
- linking directly after registration
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/test_regex_big.c91
1 files changed, 59 insertions, 32 deletions
diff --git a/src/regex/test_regex_big.c b/src/regex/test_regex_big.c
index 57735b974..e37a20efd 100644
--- a/src/regex/test_regex_big.c
+++ b/src/regex/test_regex_big.c
@@ -109,22 +109,15 @@ enum SetupState
109 INIT, 109 INIT,
110 110
111 /** 111 /**
112 * Doing registration
113 */
114 REGISTERING,
115
116 /**
117 * Connecting to slave controller 112 * Connecting to slave controller
118 */ 113 */
119 LINKING 114 LINKING
120}; 115};
121 116
117
122/** 118/**
123 * Various states during test setup 119 * Event Mask for operation callbacks
124 */ 120 */
125// static enum SetupState setup_state;
126
127
128uint64_t event_mask; 121uint64_t event_mask;
129 122
130/** 123/**
@@ -197,9 +190,9 @@ static struct GNUNET_CONFIGURATION_Handle *cfg;
197 * 190 *
198 * @param cls the closure from GNUNET_STREAM_shutdown call 191 * @param cls the closure from GNUNET_STREAM_shutdown call
199 * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR, 192 * @param operation the operation that was shutdown (SHUT_RD, SHUT_WR,
200 * SHUT_RDWR) 193 * SHUT_RDWR)
201 */ 194 */
202// static void 195// static void
203// shutdown_completion (void *cls, 196// shutdown_completion (void *cls,
204// int operation) 197// int operation)
205// { 198// {
@@ -229,14 +222,14 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
229{ 222{
230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n"); 223 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: ABORT\n");
231 result = GNUNET_SYSERR; 224 result = GNUNET_SYSERR;
232 abort_task = 0; 225 abort_task = 0;
233} 226}
234 227
235 228
236/** 229/**
237 * Adapter function called to destroy a connection to 230 * Adapter function called to destroy a connection to
238 * a service. 231 * a service.
239 * 232 *
240 * @param cls closure 233 * @param cls closure
241 * @param op_result service handle returned from the connect adapter 234 * @param op_result service handle returned from the connect adapter
242 */ 235 */
@@ -245,7 +238,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
245// { 238// {
246// struct GNUNET_STREAM_ListenSocket *lsocket; 239// struct GNUNET_STREAM_ListenSocket *lsocket;
247// struct GNUNET_STREAM_Socket *socket; 240// struct GNUNET_STREAM_Socket *socket;
248// 241//
249// if (&peer1 == cls) 242// if (&peer1 == cls)
250// { 243// {
251// lsocket = op_result; 244// lsocket = op_result;
@@ -267,18 +260,18 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
267/** 260/**
268 * Adapter function called to establish a connection to 261 * Adapter function called to establish a connection to
269 * a service. 262 * a service.
270 * 263 *
271 * @param cls closure 264 * @param cls closure
272 * @param cfg configuration of the peer to connect to; will be available until 265 * @param cfg configuration of the peer to connect to; will be available until
273 * GNUNET_TESTBED_operation_done() is called on the operation returned 266 * GNUNET_TESTBED_operation_done() is called on the operation returned
274 * from GNUNET_TESTBED_service_connect() 267 * from GNUNET_TESTBED_service_connect()
275 * @return service handle to return in 'op_result', NULL on error 268 * @return service handle to return in 'op_result', NULL on error
276 */ 269 */
277// static void * 270// static void *
278// stream_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) 271// stream_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
279// { 272// {
280// struct GNUNET_STREAM_ListenSocket *lsocket; 273// struct GNUNET_STREAM_ListenSocket *lsocket;
281// 274//
282// switch (setup_state) 275// switch (setup_state)
283// { 276// {
284// case PEER1_STREAM_CONNECT: 277// case PEER1_STREAM_CONNECT:
@@ -301,7 +294,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
301 */ 294 */
302// static void 295// static void
303// stream_connect (void) 296// stream_connect (void)
304// { 297// {
305// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n"); 298// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n");
306// peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream", 299// peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream",
307// NULL, NULL, 300// NULL, NULL,
@@ -319,7 +312,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
319 * @param emsg error message if the operation has failed; will be NULL if the 312 * @param emsg error message if the operation has failed; will be NULL if the
320 * operation is successfull 313 * operation is successfull
321 */ 314 */
322// static void 315// static void
323// peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_, 316// peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
324// const struct GNUNET_TESTBED_PeerInformation *pinfo, 317// const struct GNUNET_TESTBED_PeerInformation *pinfo,
325// const char *emsg) 318// const char *emsg)
@@ -329,7 +322,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
329// switch (setup_state) 322// switch (setup_state)
330// { 323// {
331// case PEER1_GET_IDENTITY: 324// case PEER1_GET_IDENTITY:
332// memcpy (&peer1.our_id, pinfo->result.id, 325// memcpy (&peer1.our_id, pinfo->result.id,
333// sizeof (struct GNUNET_PeerIdentity)); 326// sizeof (struct GNUNET_PeerIdentity));
334// GNUNET_TESTBED_operation_done (op); 327// GNUNET_TESTBED_operation_done (op);
335// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s 328// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
@@ -379,7 +372,7 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
379// break; 372// break;
380// case GNUNET_TESTBED_ET_OPERATION_FINISHED: 373// case GNUNET_TESTBED_ET_OPERATION_FINISHED:
381// switch (setup_state) 374// switch (setup_state)
382// { 375// {
383// case PEER1_STREAM_CONNECT: 376// case PEER1_STREAM_CONNECT:
384// case PEER2_STREAM_CONNECT: 377// case PEER2_STREAM_CONNECT:
385// GNUNET_assert (NULL == event->details.operation_finished.emsg); 378// GNUNET_assert (NULL == event->details.operation_finished.emsg);
@@ -503,13 +496,6 @@ controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
503 peer_create_cb, 496 peer_create_cb,
504 (void *) i); 497 (void *) i);
505 break; 498 break;
506 case REGISTERING:
507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Register\n");
508 state[i] = LINKING;
509 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Linking host %u\n", i);
510 op[i] = GNUNET_TESTBED_controller_link (master_ctrl, slave_hosts[i],
511 (void *) (long) i, cfg, GNUNET_YES);
512 break;
513 case LINKING: 499 case LINKING:
514 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Link\n"); 500 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Link\n");
515 break; 501 break;
@@ -536,6 +522,16 @@ registration_cont (void *cls, const char *emsg)
536 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg); 522 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "%s\n", emsg);
537 GNUNET_assert (0); 523 GNUNET_assert (0);
538 } 524 }
525
526 state[host_registered] = LINKING;
527 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
528 " Linking host %u\n", host_registered);
529 op[host_registered] = GNUNET_TESTBED_controller_link (master_ctrl,
530 slave_hosts[host_registered],
531 (void *) (long) host_registered,
532 cfg,
533 GNUNET_YES);
534
539 host_registered++; 535 host_registered++;
540 if (NUM_HOSTS != host_registered) 536 if (NUM_HOSTS != host_registered)
541 { 537 {
@@ -545,7 +541,6 @@ registration_cont (void *cls, const char *emsg)
545 slave_hosts[host_registered], 541 slave_hosts[host_registered],
546 &registration_cont, 542 &registration_cont,
547 NULL); 543 NULL);
548 state[host_registered] = REGISTERING;
549 return; 544 return;
550 } 545 }
551} 546}
@@ -588,7 +583,6 @@ status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config,
588 rh = GNUNET_TESTBED_register_host (master_ctrl, slave_hosts[0], 583 rh = GNUNET_TESTBED_register_host (master_ctrl, slave_hosts[0],
589 &registration_cont, 584 &registration_cont,
590 NULL); 585 NULL);
591 state[0] = REGISTERING;
592 GNUNET_assert (NULL != rh); 586 GNUNET_assert (NULL != rh);
593} 587}
594 588
@@ -626,6 +620,8 @@ run (void *cls, char *const *args, const char *cfgfile,
626int main (int argc, char **argv) 620int main (int argc, char **argv)
627{ 621{
628 int ret; 622 int ret;
623 unsigned int i;
624
629 struct GNUNET_GETOPT_CommandLineOption options[] = { 625 struct GNUNET_GETOPT_CommandLineOption options[] = {
630 GNUNET_GETOPT_OPTION_END 626 GNUNET_GETOPT_OPTION_END
631 }; 627 };
@@ -634,13 +630,44 @@ int main (int argc, char **argv)
634 NULL 630 NULL
635 }; 631 };
636 632
633 for (i = 0; i < NUM_HOSTS; i++)
634 {
635 char *const remote_args[] = {
636 "ssh", "-o", "BatchMode=yes", slave_ips[i], "echo", "Hello", "World", NULL
637 };
638 struct GNUNET_OS_Process *auxp;
639 enum GNUNET_OS_ProcessStatusType type;
640 unsigned long code;
641
642 auxp =
643 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
644 NULL, "ssh", remote_args);
645 GNUNET_assert (NULL != auxp);
646 do
647 {
648 ret = GNUNET_OS_process_status (auxp, &type, &code);
649 GNUNET_assert (GNUNET_SYSERR != ret);
650 (void) usleep (300);
651 }
652 while (GNUNET_NO == ret);
653 (void) GNUNET_OS_process_wait (auxp);
654 GNUNET_OS_process_destroy (auxp);
655 if (0 != code)
656 {
657 (void) printf("Unable to run the test as this system is not configured "
658 "to use password less SSH logins to host %s.\n"
659 "Marking test as successful\n", slave_ips[i]);
660 return 0;
661 }
662 }
663
637 result = GNUNET_SYSERR; 664 result = GNUNET_SYSERR;
638 665
639 ret = 666 ret =
640 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, 667 GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2,
641 "test_regex_big", "nohelp", options, 668 "test_regex_big", "nohelp", options,
642 &run, NULL); 669 &run, NULL);
643 670
644 if (GNUNET_SYSERR == result || 0 != ret) 671 if (GNUNET_SYSERR == result || 0 != ret)
645 return 1; 672 return 1;
646 return 0; 673 return 0;