diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-19 14:59:43 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-04-19 14:59:43 +0000 |
commit | 87c2411c30758a5a6f39b433b8012c030ecd5963 (patch) | |
tree | 368ac889496cef47d5136b860c3c7688e0314a1e /src/testing/testing.c | |
parent | 1079f746c943b2efffa28970fe03f679334c3bb3 (diff) | |
download | gnunet-87c2411c30758a5a6f39b433b8012c030ecd5963.tar.gz gnunet-87c2411c30758a5a6f39b433b8012c030ecd5963.zip |
- simple test case for service sharing in testing deployments
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 23cd7ddc7..1b2448ffc 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -385,13 +385,13 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, | |||
385 | const char *trusted_ip, | 385 | const char *trusted_ip, |
386 | const char *hostname, | 386 | const char *hostname, |
387 | const struct | 387 | const struct |
388 | GNUNET_TESTING_SharedService ** | 388 | GNUNET_TESTING_SharedService * |
389 | shared_services, | 389 | shared_services, |
390 | uint16_t lowport, | 390 | uint16_t lowport, |
391 | uint16_t highport) | 391 | uint16_t highport) |
392 | { | 392 | { |
393 | struct GNUNET_TESTING_System *system; | 393 | struct GNUNET_TESTING_System *system; |
394 | const struct GNUNET_TESTING_SharedService *tss; | 394 | struct GNUNET_TESTING_SharedService tss; |
395 | struct SharedService *ss; | 395 | struct SharedService *ss; |
396 | unsigned int cnt; | 396 | unsigned int cnt; |
397 | 397 | ||
@@ -416,17 +416,17 @@ GNUNET_TESTING_system_create_with_portrange (const char *testdir, | |||
416 | } | 416 | } |
417 | if (NULL == shared_services) | 417 | if (NULL == shared_services) |
418 | return system; | 418 | return system; |
419 | for (cnt = 0; NULL != (tss = shared_services[cnt]); cnt++) | 419 | for (cnt = 0; NULL != shared_services[cnt].service; cnt++) |
420 | { | 420 | { |
421 | tss = shared_services[cnt]; | ||
421 | ss = GNUNET_malloc (sizeof (struct SharedService)); | 422 | ss = GNUNET_malloc (sizeof (struct SharedService)); |
422 | ss->sname = GNUNET_strdup (tss->service); | 423 | ss->sname = GNUNET_strdup (tss.service); |
423 | ss->cfg = GNUNET_CONFIGURATION_dup (tss->cfg); | ||
424 | ss->cfg = GNUNET_CONFIGURATION_create (); | 424 | ss->cfg = GNUNET_CONFIGURATION_create (); |
425 | GNUNET_CONFIGURATION_iterate_section_values (tss->cfg, ss->sname, | 425 | GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, ss->sname, |
426 | &cfg_copy_iterator, ss->cfg); | 426 | &cfg_copy_iterator, ss->cfg); |
427 | GNUNET_CONFIGURATION_iterate_section_values (tss->cfg, "TESTING", | 427 | GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, "TESTING", |
428 | &cfg_copy_iterator, ss->cfg); | 428 | &cfg_copy_iterator, ss->cfg); |
429 | ss->share = tss->share; | 429 | ss->share = tss.share; |
430 | GNUNET_array_append (system->shared_services, system->n_shared_services, | 430 | GNUNET_array_append (system->shared_services, system->n_shared_services, |
431 | ss); | 431 | ss); |
432 | } | 432 | } |
@@ -456,7 +456,7 @@ struct GNUNET_TESTING_System * | |||
456 | GNUNET_TESTING_system_create (const char *testdir, | 456 | GNUNET_TESTING_system_create (const char *testdir, |
457 | const char *trusted_ip, | 457 | const char *trusted_ip, |
458 | const char *hostname, | 458 | const char *hostname, |
459 | const struct GNUNET_TESTING_SharedService ** | 459 | const struct GNUNET_TESTING_SharedService * |
460 | shared_services) | 460 | shared_services) |
461 | { | 461 | { |
462 | return GNUNET_TESTING_system_create_with_portrange (testdir, | 462 | return GNUNET_TESTING_system_create_with_portrange (testdir, |
@@ -486,18 +486,22 @@ static int | |||
486 | start_shared_service_instance (struct SharedServiceInstance *i) | 486 | start_shared_service_instance (struct SharedServiceInstance *i) |
487 | { | 487 | { |
488 | char *binary; | 488 | char *binary; |
489 | char *libexec_binary; | ||
489 | 490 | ||
490 | GNUNET_assert (NULL == i->proc); | 491 | GNUNET_assert (NULL == i->proc); |
491 | GNUNET_assert (NULL != i->cfg_fn); | 492 | GNUNET_assert (NULL != i->cfg_fn); |
492 | (void) GNUNET_asprintf (&binary, "gnunet-service-%s", i->ss->sname); | 493 | (void) GNUNET_asprintf (&binary, "gnunet-service-%s", i->ss->sname); |
494 | libexec_binary = GNUNET_OS_get_libexec_binary_path (binary); | ||
495 | GNUNET_free (binary); | ||
493 | i->proc = GNUNET_OS_start_process (PIPE_CONTROL, | 496 | i->proc = GNUNET_OS_start_process (PIPE_CONTROL, |
494 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 497 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
495 | NULL, NULL, | 498 | NULL, NULL, |
496 | binary, | 499 | libexec_binary, |
497 | binary, | 500 | libexec_binary, |
498 | "-c", | 501 | "-c", |
499 | i->cfg_fn, | 502 | i->cfg_fn, |
500 | NULL); | 503 | NULL); |
504 | GNUNET_free (libexec_binary); | ||
501 | if (NULL == i->proc) | 505 | if (NULL == i->proc) |
502 | return GNUNET_SYSERR; | 506 | return GNUNET_SYSERR; |
503 | return GNUNET_OK; | 507 | return GNUNET_OK; |
@@ -1004,6 +1008,7 @@ associate_shared_service (struct GNUNET_TESTING_System *system, | |||
1004 | (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", service_home); | 1008 | (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", service_home); |
1005 | GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "SERVICEHOME", | 1009 | GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "SERVICEHOME", |
1006 | service_home); | 1010 | service_home); |
1011 | GNUNET_free (service_home); | ||
1007 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH", | 1012 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH", |
1008 | i->unix_sock); | 1013 | i->unix_sock); |
1009 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT", | 1014 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT", |