* by one for each configured peer. Even if peers are destroyed,
* we never re-use path counters.
*/
* by one for each configured peer. Even if peers are destroyed,
* we never re-use path counters.
*/
/**
* Handle to the running binary of the service, NULL if the
* peer/service is currently not running.
/**
* Handle to the running binary of the service, NULL if the
* peer/service is currently not running.
/**
* The cached identity of this peer. Will be populated on call to
* GNUNET_TESTING_peer_get_identity()
/**
* The cached identity of this peer. Will be populated on call to
* GNUNET_TESTING_peer_get_identity()
GNUNET_assert (NULL == system->hostkeys_data);
data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir);
GNUNET_assert (NULL == system->hostkeys_data);
data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir);
GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
fs = 0;
if (0 == fs)
GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
fs = 0;
if (0 == fs)
*
* @param testdir only the directory name without any path. This is used for
* all service homes; the directory will be created in a temporary
*
* @param testdir only the directory name without any path. This is used for
* all service homes; the directory will be created in a temporary
- * location depending on the underlying OS
+ * location depending on the underlying OS. This variable will be
+ * overridden with the value of the environmental variable
+ * GNUNET_TESTING_PREFIX, if it exists.
* @param trusted_ip the ip address which will be set as TRUSTED HOST in all
* service configurations generated to allow control connections from
* this ip. This can either be a single ip address or a network address
* @param trusted_ip the ip address which will be set as TRUSTED HOST in all
* service configurations generated to allow control connections from
* this ip. This can either be a single ip address or a network address
- system = GNUNET_malloc (sizeof (struct GNUNET_TESTING_System));
- system->tmppath = GNUNET_DISK_mkdtemp (testdir);
+ system = GNUNET_new (struct GNUNET_TESTING_System);
+ if (NULL == (system->tmppath = getenv (GNUNET_TESTING_PREFIX)))
+ system->tmppath = GNUNET_DISK_mkdtemp (testdir);
+ else
+ system->tmppath = GNUNET_strdup (system->tmppath);
system->lowport = lowport;
system->highport = highport;
if (NULL == system->tmppath)
system->lowport = lowport;
system->highport = highport;
if (NULL == system->tmppath)
ss->sname = GNUNET_strdup (tss.service);
ss->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, ss->sname,
&cfg_copy_iterator, ss->cfg);
GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, "TESTING",
&cfg_copy_iterator, ss->cfg);
ss->sname = GNUNET_strdup (tss.service);
ss->cfg = GNUNET_CONFIGURATION_create ();
GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, ss->sname,
&cfg_copy_iterator, ss->cfg);
GNUNET_CONFIGURATION_iterate_section_values (tss.cfg, "TESTING",
&cfg_copy_iterator, ss->cfg);
*
* @param testdir only the directory name without any path. This is used for all
* service homes; the directory will be created in a temporary location
*
* @param testdir only the directory name without any path. This is used for all
* service homes; the directory will be created in a temporary location
- * depending on the underlying OS
+ * depending on the underlying OS. This variable will be
+ * overridden with the value of the environmental variable
+ * GNUNET_TESTING_PREFIX, if it exists.
* @param trusted_ip the ip address which will be set as TRUSTED HOST in all
* service configurations generated to allow control connections from
* this ip. This can either be a single ip address or a network address
* @param trusted_ip the ip address which will be set as TRUSTED HOST in all
* service configurations generated to allow control connections from
* this ip. This can either be a single ip address or a network address
GNUNET_free (binary);
i->proc = GNUNET_OS_start_process (PIPE_CONTROL,
GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
GNUNET_free (binary);
i->proc = GNUNET_OS_start_process (PIPE_CONTROL,
GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
LOG (GNUNET_ERROR_TYPE_WARNING,
"Killing shared service instance (%s) failed\n", i->ss->sname);
(void) GNUNET_OS_process_wait (i->proc);
LOG (GNUNET_ERROR_TYPE_WARNING,
"Killing shared service instance (%s) failed\n", i->ss->sname);
(void) GNUNET_OS_process_wait (i->proc);
GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
{
struct GNUNET_NETWORK_Handle *socket;
GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
{
struct GNUNET_NETWORK_Handle *socket;
/*
FIXME: Instead of using getaddrinfo we should try to determine the port
status by the following heurestics.
/*
FIXME: Instead of using getaddrinfo we should try to determine the port
status by the following heurestics.
On systems which support both IPv4 and IPv6, only ports open on both
address families are considered open.
On system with either IPv4 or IPv6. A port is considered open if it's
On systems which support both IPv4 and IPv6, only ports open on both
address families are considered open.
On system with either IPv4 or IPv6. A port is considered open if it's
* faster peer startup. This function can be used to
* access the n-th key of those pre-created hostkeys; note
* that these keys are ONLY useful for testing and not
* faster peer startup. This function can be used to
* access the n-th key of those pre-created hostkeys; note
* that these keys are ONLY useful for testing and not
* key; if NULL, GNUNET_SYSERR is returned immediately
* @return NULL on error (not enough keys)
*/
* key; if NULL, GNUNET_SYSERR is returned immediately
* @return NULL on error (not enough keys)
*/
GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
uint32_t key_number,
struct GNUNET_PeerIdentity *id)
GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
uint32_t key_number,
struct GNUNET_PeerIdentity *id)
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Key number %u does not exist\n"), key_number);
return NULL;
LOG (GNUNET_ERROR_TYPE_ERROR,
_("Key number %u does not exist\n"), key_number);
return NULL;
memcpy (private_key,
system->hostkeys_data +
(key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
GNUNET_TESTING_HOSTKEYFILESIZE);
memcpy (private_key,
system->hostkeys_data +
(key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
GNUNET_TESTING_HOSTKEYFILESIZE);
- GNUNET_CRYPTO_ecc_key_get_public_for_signature (private_key, &public_key);
- GNUNET_CRYPTO_hash (&public_key,
- sizeof (struct GNUNET_CRYPTO_EccPublicSignKey),
- &(id->hashPubKey));
+ GNUNET_CRYPTO_eddsa_key_get_public (private_key,
+ &id->public_key);
single_variable))
{
GNUNET_snprintf (uval, sizeof (uval), "%s/%s.sock",
single_variable))
{
GNUNET_snprintf (uval, sizeof (uval), "%s/%s.sock",
GNUNET_CONFIGURATION_get_value_string (uc->cfg, section,
"TESTING_IGNORE_KEYS", &val));
ptr = val;
GNUNET_CONFIGURATION_get_value_string (uc->cfg, section,
"TESTING_IGNORE_KEYS", &val));
ptr = val;
GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "PORT", &ptr))
{
GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "PORT", &ptr))
{
(NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */
ACCEPT_FROM_key = "ACCEPT_FROM6";
(NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */
ACCEPT_FROM_key = "ACCEPT_FROM6";
GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, ACCEPT_FROM_key,
&orig_allowed_hosts))
{
GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, ACCEPT_FROM_key,
&orig_allowed_hosts))
{
GNUNET_free (orig_allowed_hosts);
GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, ACCEPT_FROM_key,
allowed_hosts);
GNUNET_free (orig_allowed_hosts);
GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, ACCEPT_FROM_key,
allowed_hosts);
cleanup_shared_service_instance (i);
return NULL;
}
GNUNET_array_append (ss->instances, ss->n_instances, i);
temp = GNUNET_CONFIGURATION_dup (ss->cfg);
(void) GNUNET_asprintf (&i->port_str, "%u", port);
cleanup_shared_service_instance (i);
return NULL;
}
GNUNET_array_append (ss->instances, ss->n_instances, i);
temp = GNUNET_CONFIGURATION_dup (ss->cfg);
(void) GNUNET_asprintf (&i->port_str, "%u", port);
- (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", service_home);
- GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "SERVICEHOME",
- service_home);
- GNUNET_free (service_home);
+ (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", gnunet_home);
+ GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "GNUNET_HOME",
+ gnunet_home);
+ GNUNET_free (gnunet_home);
GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH",
i->unix_sock);
GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT",
GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH",
i->unix_sock);
GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT",
&cfg_copy_iterator, cfg);
GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "UNIXPATH",
i->unix_sock);
&cfg_copy_iterator, cfg);
GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "UNIXPATH",
i->unix_sock);
* Create a new configuration using the given configuration as a template;
* ports and paths will be modified to select available ports on the local
* system. The default configuration will be available in PATHS section under
* Create a new configuration using the given configuration as a template;
* ports and paths will be modified to select available ports on the local
* system. The default configuration will be available in PATHS section under
* @param ports array with port numbers used in the created configuration.
* Will be updated upon successful return. Can be NULL
* @param nports the size of the `ports' array. Will be updated.
* @param ports array with port numbers used in the created configuration.
* Will be updated upon successful return. Can be NULL
* @param nports the size of the `ports' array. Will be updated.
- GNUNET_asprintf (&uc.service_home, "%s/%u", system->tmppath,
+ GNUNET_asprintf (&uc.gnunet_home, "%s/%u", system->tmppath,
GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG",
default_config);
GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG",
default_config);
GNUNET_free (default_config);
GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG",
default_config);
GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG",
default_config);
GNUNET_free (default_config);
- GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "SERVICEHOME",
- uc.service_home);
+ GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "GNUNET_HOME",
+ uc.gnunet_home);
/* make PORTs and UNIXPATHs unique */
GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc);
/* allow connections to services from system trusted_ip host */
GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc);
/* enable loopback-based connections between peers */
/* make PORTs and UNIXPATHs unique */
GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc);
/* allow connections to services from system trusted_ip host */
GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc);
/* enable loopback-based connections between peers */
* Create a new configuration using the given configuration as a template;
* ports and paths will be modified to select available ports on the local
* system. The default configuration will be available in PATHS section under
* Create a new configuration using the given configuration as a template;
* ports and paths will be modified to select available ports on the local
* system. The default configuration will be available in PATHS section under
* section to the temporary directory specific to this configuration. If we run
* out of "*port" numbers, return SYSERR.
*
* section to the temporary directory specific to this configuration. If we run
* out of "*port" numbers, return SYSERR.
*
*
* @param system system to use to coordinate resource usage
* @param cfg configuration to use; will be UPDATED (to reflect needed
* changes in port numbers and paths)
* @param key_number number of the hostkey to use for the peer
* @param id identifier for the daemon, will be set, can be NULL
*
* @param system system to use to coordinate resource usage
* @param cfg configuration to use; will be UPDATED (to reflect needed
* changes in port numbers and paths)
* @param key_number number of the hostkey to use for the peer
* @param id identifier for the daemon, will be set, can be NULL
_("Failed to initialize hostkey for peer %u\n"),
(unsigned int) key_number);
goto err_ret;
_("Failed to initialize hostkey for peer %u\n"),
(unsigned int) key_number);
goto err_ret;
GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER",
"PRIVATE_KEY",
&hostkey_filename));
fd = GNUNET_DISK_file_open (hostkey_filename,
GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE,
GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER",
"PRIVATE_KEY",
&hostkey_filename));
fd = GNUNET_DISK_file_open (hostkey_filename,
GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE,
+ (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
GNUNET_TESTING_HOSTKEYFILESIZE))
{
+ (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
GNUNET_TESTING_HOSTKEYFILESIZE))
{
ss = system->shared_services[cnt];
ss_instances[cnt] = associate_shared_service (system, ss, cfg);
if (NULL == ss_instances[cnt])
ss = system->shared_services[cnt];
ss_instances[cnt] = associate_shared_service (system, ss, cfg);
if (NULL == ss_instances[cnt])
- GNUNET_CONFIGURATION_get_value_string
- (cfg, "PATHS", "DEFAULTCONFIG", &config_filename));
+ GNUNET_CONFIGURATION_get_value_filename
+ (cfg, "PATHS", "DEFAULTCONFIG", &config_filename));
if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename))
{
GNUNET_asprintf (&emsg_,
_("Failed to write configuration file `%s' for peer %u: %s\n"),
config_filename,
(unsigned int) key_number,
if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename))
{
GNUNET_asprintf (&emsg_,
_("Failed to write configuration file `%s' for peer %u: %s\n"),
config_filename,
(unsigned int) key_number,
peer->ss_instances = ss_instances;
peer->cfgfile = config_filename; /* Free in peer_destroy */
peer->cfg = GNUNET_CONFIGURATION_dup (cfg);
peer->ss_instances = ss_instances;
peer->cfgfile = config_filename; /* Free in peer_destroy */
peer->cfg = GNUNET_CONFIGURATION_dup (cfg);
*
* @param peer peer to start
* @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running)
*
* @param peer peer to start
* @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running)
- peer->main_process = GNUNET_OS_start_process (PIPE_CONTROL,
- GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL,
- peer->main_binary,
- peer->main_binary,
- peer->args,
- "-c",
- peer->cfgfile,
- NULL);
+ peer->main_binary = GNUNET_CONFIGURATION_expand_dollar (peer->cfg, peer->main_binary);
+ peer->main_process = GNUNET_OS_start_process_s (PIPE_CONTROL,
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
+ NULL,
+ peer->main_binary,
+ peer->args,
+ "-c",
+ peer->cfgfile,
+ NULL);
if (NULL == peer->main_process)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
if (NULL == peer->main_process)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
const char *service_name,
struct GNUNET_TIME_Relative timeout,
GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
const char *service_name,
struct GNUNET_TIME_Relative timeout,
*
* @param peer peer to stop
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*
* @param peer peer to stop
* @return GNUNET_OK on success, GNUNET_SYSERR on error
GNUNET_TESTING_peer_destroy (peer);
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_TESTING_system_destroy (system, GNUNET_YES);
GNUNET_TESTING_peer_destroy (peer);
GNUNET_CONFIGURATION_destroy (cfg);
GNUNET_TESTING_system_destroy (system, GNUNET_YES);
* Sometimes we use the binary name to determine which specific
* test to run. In those cases, the string after the last "_"
* in 'argv[0]' specifies a string that determines the configuration
* Sometimes we use the binary name to determine which specific
* test to run. In those cases, the string after the last "_"
* in 'argv[0]' specifies a string that determines the configuration
*
* This function returns the respective substring, taking care
* of issues such as binaries ending in '.exe' on W32.
*
* @param argv0 the name of the binary
* @return string between the last '_' and the '.exe' (or the end of the string),
*
* This function returns the respective substring, taking care
* of issues such as binaries ending in '.exe' on W32.
*
* @param argv0 the name of the binary
* @return string between the last '_' and the '.exe' (or the end of the string),