aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-07-18 13:03:17 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-07-18 13:03:17 +0000
commit1a956f969b0166ee609a88d37ace19486bd6bcee (patch)
tree8a027bd38fa951dbe4f5273bdc3c33243d2a8342 /src/testbed
parent41f993ffa4aeb530a26fba43a1e69c776633ed11 (diff)
downloadgnunet-1a956f969b0166ee609a88d37ace19486bd6bcee.tar.gz
gnunet-1a956f969b0166ee609a88d37ace19486bd6bcee.zip
fix; modified testcase for test_testbed_api; valigrind suppression for zlib
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/Makefile.am1
-rw-r--r--src/testbed/test_testbed_api.c44
-rw-r--r--src/testbed/testbed_api.c34
-rw-r--r--src/testbed/valgrind-zlib.supp7
4 files changed, 65 insertions, 21 deletions
diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am
index 86d04ebde..707040a75 100644
--- a/src/testbed/Makefile.am
+++ b/src/testbed/Makefile.am
@@ -71,6 +71,7 @@ check_PROGRAMS = \
71 71
72if ENABLE_TEST_RUN 72if ENABLE_TEST_RUN
73 TESTS = \ 73 TESTS = \
74 test_testbed_api \
74 test_testbed_api_hosts \ 75 test_testbed_api_hosts \
75 test_gnunet_testbed_helper 76 test_gnunet_testbed_helper
76endif 77endif
diff --git a/src/testbed/test_testbed_api.c b/src/testbed/test_testbed_api.c
index 9bdae1fb0..6378fd9cc 100644
--- a/src/testbed/test_testbed_api.c
+++ b/src/testbed/test_testbed_api.c
@@ -171,23 +171,21 @@ registration_comp (void *cls, const char *emsg)
171 171
172 172
173/** 173/**
174 * Main run function. 174 * Callback to signal successfull startup of the controller process
175 * 175 *
176 * @param cls NULL 176 * @param cls the closure from GNUNET_TESTBED_controller_start()
177 * @param args arguments passed to GNUNET_PROGRAM_run 177 * @param cfg the configuration with which the controller has been started;
178 * @param cfgfile the path to configuration file 178 * NULL if status is not GNUNET_OK
179 * @param cfg the configuration file handle 179 * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not,
180 * GNUNET_TESTBED_controller_stop() shouldn't be called in this case
180 */ 181 */
181static void 182static void
182run (void *cls, char *const *args, const char *cfgfile, 183status_cb (void *cls,
183 const struct GNUNET_CONFIGURATION_Handle *config) 184 const struct GNUNET_CONFIGURATION_Handle *cfg, int status)
184{ 185{
185 uint64_t event_mask; 186 uint64_t event_mask;
186 187
187 host = GNUNET_TESTBED_host_create (NULL, NULL, 0); 188 GNUNET_assert (GNUNET_OK == status);
188 GNUNET_assert (NULL != host);
189 cfg = GNUNET_CONFIGURATION_dup (config);
190 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, NULL, NULL);
191 event_mask = 0; 189 event_mask = 0;
192 event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START); 190 event_mask |= (1L << GNUNET_TESTBED_ET_PEER_START);
193 event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); 191 event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP);
@@ -201,7 +199,27 @@ run (void *cls, char *const *args, const char *cfgfile,
201 reg_handle = 199 reg_handle =
202 GNUNET_TESTBED_register_host (controller, neighbour, &registration_comp, 200 GNUNET_TESTBED_register_host (controller, neighbour, &registration_comp,
203 neighbour); 201 neighbour);
204 GNUNET_assert (NULL != reg_handle); 202 GNUNET_assert (NULL != reg_handle);
203}
204
205
206
207/**
208 * Main run function.
209 *
210 * @param cls NULL
211 * @param args arguments passed to GNUNET_PROGRAM_run
212 * @param cfgfile the path to configuration file
213 * @param cfg the configuration file handle
214 */
215static void
216run (void *cls, char *const *args, const char *cfgfile,
217 const struct GNUNET_CONFIGURATION_Handle *config)
218{
219 host = GNUNET_TESTBED_host_create (NULL, NULL, 0);
220 GNUNET_assert (NULL != host);
221 cfg = GNUNET_CONFIGURATION_dup (config);
222 cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL);
205 abort_task = GNUNET_SCHEDULER_add_delayed 223 abort_task = GNUNET_SCHEDULER_add_delayed
206 (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, NULL); 224 (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, NULL);
207} 225}
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 5af8d71c6..6cdcabdd6 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -444,12 +444,18 @@ struct GNUNET_TESTBED_ControllerProc
444 * The closure for the above callback 444 * The closure for the above callback
445 */ 445 */
446 void *cls; 446 void *cls;
447
447 /** 448 /**
448 * The send handle for the helper 449 * The send handle for the helper
449 */ 450 */
450 struct GNUNET_HELPER_SendHandle *shandle; 451 struct GNUNET_HELPER_SendHandle *shandle;
451 452
452 /** 453 /**
454 * The message corresponding to send handle
455 */
456 struct GNUNET_MessageHeader *msg;
457
458 /**
453 * The port number for ssh; used for helpers starting ssh 459 * The port number for ssh; used for helpers starting ssh
454 */ 460 */
455 char *port; 461 char *port;
@@ -484,6 +490,7 @@ static int helper_mst (void *cls, void *client,
484{ 490{
485 struct GNUNET_TESTBED_ControllerProc *cp = cls; 491 struct GNUNET_TESTBED_ControllerProc *cp = cls;
486 const struct GNUNET_TESTBED_HelperReply *msg; 492 const struct GNUNET_TESTBED_HelperReply *msg;
493 const char *hostname;
487 char *config; 494 char *config;
488 uLongf config_size; 495 uLongf config_size;
489 uLongf xconfig_size; 496 uLongf xconfig_size;
@@ -503,10 +510,13 @@ static int helper_mst (void *cls, void *client,
503 cp->cfg = GNUNET_CONFIGURATION_create (); 510 cp->cfg = GNUNET_CONFIGURATION_create ();
504 GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->cfg, config, 511 GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->cfg, config,
505 config_size, GNUNET_NO)); 512 config_size, GNUNET_NO));
513 GNUNET_free (config);
514 if ((NULL == cp->host) ||
515 (NULL == (hostname = GNUNET_TESTBED_host_get_hostname_ (cp->host))))
516 hostname = "localhost";
506 /* Change the hostname so that we can connect to it */ 517 /* Change the hostname so that we can connect to it */
507 GNUNET_CONFIGURATION_set_value_string (cp->cfg, "testbed", "hostname", 518 GNUNET_CONFIGURATION_set_value_string (cp->cfg, "testbed", "hostname",
508 (NULL == cp->host) ? "localhost" : 519 hostname);
509 GNUNET_TESTBED_host_get_hostname_ (cp->host));
510 cp->cb (cp->cls, cp->cfg, GNUNET_OK); 520 cp->cb (cp->cls, cp->cfg, GNUNET_OK);
511 return GNUNET_OK; 521 return GNUNET_OK;
512} 522}
@@ -523,7 +533,11 @@ static int helper_mst (void *cls, void *client,
523static void 533static void
524clear_msg (void *cls, int result) 534clear_msg (void *cls, int result)
525{ 535{
526 GNUNET_free (cls); 536 struct GNUNET_TESTBED_ControllerProc *cp = cls;
537
538 GNUNET_assert (NULL != cp->shandle);
539 cp->shandle = NULL;
540 GNUNET_free (cp->msg);
527} 541}
528 542
529 543
@@ -561,10 +575,11 @@ helper_exp_cb (void *cls)
561 * configuration (port numbers, unix domain sockets and service home 575 * configuration (port numbers, unix domain sockets and service home
562 * values are changed as per TESTING library on the remote host) 576 * values are changed as per TESTING library on the remote host)
563 * @param cb function called when the controller is successfully started or 577 * @param cb function called when the controller is successfully started or
564 * dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be 578 * dies unexpectedly; GNUNET_TESTBED_controller_stop shouldn't be
565 * called if cb is called with GNUNET_SYSERR as status. Will never be 579 * called if cb is called with GNUNET_SYSERR as status. Will never be
566 * called in the same task as 'GNUNET_TESTBED_controller_start' 580 * called in the same task as 'GNUNET_TESTBED_controller_start'
567 * (synchronous errors will be signalled by returning NULL) 581 * (synchronous errors will be signalled by returning NULL). This
582 * parameter cannot be NULL.
568 * @param cls closure for above callbacks 583 * @param cls closure for above callbacks
569 * @return the controller process handle, NULL on errors 584 * @return the controller process handle, NULL on errors
570 */ 585 */
@@ -625,8 +640,9 @@ GNUNET_TESTBED_controller_start (const char *controller_ip,
625 cp->cb = cb; 640 cp->cb = cb;
626 cp->cls = cls; 641 cp->cls = cls;
627 msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); 642 msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg);
643 cp->msg = &msg->header;
628 cp->shandle = GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, 644 cp->shandle = GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO,
629 &clear_msg, msg); 645 &clear_msg, cp);
630 if (NULL == cp->shandle) 646 if (NULL == cp->shandle)
631 { 647 {
632 GNUNET_free (msg); 648 GNUNET_free (msg);
@@ -650,6 +666,8 @@ GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cp)
650 if (NULL != cp->shandle) 666 if (NULL != cp->shandle)
651 GNUNET_HELPER_send_cancel (cp->shandle); 667 GNUNET_HELPER_send_cancel (cp->shandle);
652 GNUNET_HELPER_stop (cp->helper); 668 GNUNET_HELPER_stop (cp->helper);
669 if (NULL != cp->cfg)
670 GNUNET_CONFIGURATION_destroy (cp->cfg);
653 GNUNET_free_non_null (cp->port); 671 GNUNET_free_non_null (cp->port);
654 GNUNET_free_non_null (cp->dst); 672 GNUNET_free_non_null (cp->dst);
655 GNUNET_free (cp); 673 GNUNET_free (cp);
diff --git a/src/testbed/valgrind-zlib.supp b/src/testbed/valgrind-zlib.supp
new file mode 100644
index 000000000..683eb377a
--- /dev/null
+++ b/src/testbed/valgrind-zlib.supp
@@ -0,0 +1,7 @@
1{
2 <ZlibInflateReset2UninitJump>
3 Memcheck:Cond
4 fun:inflateReset2
5 obj:*
6 obj:*
7} \ No newline at end of file