aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r--src/testing/testing.c122
1 files changed, 61 insertions, 61 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 10d25637e..600c53c1a 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -149,7 +149,7 @@ struct GNUNET_TESTING_System
149 * by one for each configured peer. Even if peers are destroyed, 149 * by one for each configured peer. Even if peers are destroyed,
150 * we never re-use path counters. 150 * we never re-use path counters.
151 */ 151 */
152 uint32_t path_counter; 152 uint32_t path_counter;
153 153
154 /** 154 /**
155 * The number of hostkeys 155 * The number of hostkeys
@@ -185,13 +185,13 @@ struct GNUNET_TESTING_Peer
185 185
186 /** 186 /**
187 * Binary to be executed during 'GNUNET_TESTING_peer_start'. 187 * Binary to be executed during 'GNUNET_TESTING_peer_start'.
188 * Typically 'gnunet-service-arm' (but can be set to a 188 * Typically 'gnunet-service-arm' (but can be set to a
189 * specific service by 'GNUNET_TESTING_service_run' if 189 * specific service by 'GNUNET_TESTING_service_run' if
190 * necessary). 190 * necessary).
191 */ 191 */
192 char *main_binary; 192 char *main_binary;
193 char *args; 193 char *args;
194 194
195 /** 195 /**
196 * Handle to the running binary of the service, NULL if the 196 * Handle to the running binary of the service, NULL if the
197 * peer/service is currently not running. 197 * peer/service is currently not running.
@@ -215,14 +215,14 @@ struct GNUNET_TESTING_Peer
215 215
216 /** 216 /**
217 * The callback to call asynchronously when a peer is stopped 217 * The callback to call asynchronously when a peer is stopped
218 */ 218 */
219 GNUNET_TESTING_PeerStopCallback cb; 219 GNUNET_TESTING_PeerStopCallback cb;
220 220
221 /** 221 /**
222 * The closure for the above callback 222 * The closure for the above callback
223 */ 223 */
224 void *cb_cls; 224 void *cb_cls;
225 225
226 /** 226 /**
227 * The cached identity of this peer. Will be populated on call to 227 * The cached identity of this peer. Will be populated on call to
228 * GNUNET_TESTING_peer_get_identity() 228 * GNUNET_TESTING_peer_get_identity()
@@ -260,7 +260,7 @@ struct GNUNET_TESTING_Peer
260static int 260static int
261hostkeys_load (struct GNUNET_TESTING_System *system) 261hostkeys_load (struct GNUNET_TESTING_System *system)
262{ 262{
263 uint64_t fs; 263 uint64_t fs;
264 char *data_dir; 264 char *data_dir;
265 char *filename; 265 char *filename;
266 struct GNUNET_DISK_FileHandle *fd; 266 struct GNUNET_DISK_FileHandle *fd;
@@ -268,7 +268,7 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
268 GNUNET_assert (NULL == system->hostkeys_data); 268 GNUNET_assert (NULL == system->hostkeys_data);
269 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); 269 data_dir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
270 GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir); 270 GNUNET_asprintf (&filename, "%s/testing_hostkeys.ecc", data_dir);
271 GNUNET_free (data_dir); 271 GNUNET_free (data_dir);
272 272
273 if (GNUNET_YES != GNUNET_DISK_file_test (filename)) 273 if (GNUNET_YES != GNUNET_DISK_file_test (filename))
274 { 274 {
@@ -278,7 +278,7 @@ hostkeys_load (struct GNUNET_TESTING_System *system)
278 return GNUNET_SYSERR; 278 return GNUNET_SYSERR;
279 } 279 }
280 /* Check hostkey file size, read entire thing into memory */ 280 /* Check hostkey file size, read entire thing into memory */
281 if (GNUNET_OK != 281 if (GNUNET_OK !=
282 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) 282 GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES))
283 fs = 0; 283 fs = 0;
284 if (0 == fs) 284 if (0 == fs)
@@ -558,7 +558,7 @@ GNUNET_TESTING_system_destroy (struct GNUNET_TESTING_System *system,
558 * @param system system to use for reservation tracking 558 * @param system system to use for reservation tracking
559 * @return 0 if no free port was available 559 * @return 0 if no free port was available
560 */ 560 */
561uint16_t 561uint16_t
562GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system) 562GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
563{ 563{
564 struct GNUNET_NETWORK_Handle *socket; 564 struct GNUNET_NETWORK_Handle *socket;
@@ -576,7 +576,7 @@ GNUNET_TESTING_reserve_port (struct GNUNET_TESTING_System *system)
576 /* 576 /*
577 FIXME: Instead of using getaddrinfo we should try to determine the port 577 FIXME: Instead of using getaddrinfo we should try to determine the port
578 status by the following heurestics. 578 status by the following heurestics.
579 579
580 On systems which support both IPv4 and IPv6, only ports open on both 580 On systems which support both IPv4 and IPv6, only ports open on both
581 address families are considered open. 581 address families are considered open.
582 On system with either IPv4 or IPv6. A port is considered open if it's 582 On system with either IPv4 or IPv6. A port is considered open if it's
@@ -683,7 +683,7 @@ GNUNET_TESTING_release_port (struct GNUNET_TESTING_System *system,
683 * faster peer startup. This function can be used to 683 * faster peer startup. This function can be used to
684 * access the n-th key of those pre-created hostkeys; note 684 * access the n-th key of those pre-created hostkeys; note
685 * that these keys are ONLY useful for testing and not 685 * that these keys are ONLY useful for testing and not
686 * secure as the private keys are part of the public 686 * secure as the private keys are part of the public
687 * GNUnet source code. 687 * GNUnet source code.
688 * 688 *
689 * This is primarily a helper function used internally 689 * This is primarily a helper function used internally
@@ -699,9 +699,9 @@ struct GNUNET_CRYPTO_EccPrivateKey *
699GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system, 699GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
700 uint32_t key_number, 700 uint32_t key_number,
701 struct GNUNET_PeerIdentity *id) 701 struct GNUNET_PeerIdentity *id)
702{ 702{
703 struct GNUNET_CRYPTO_EccPrivateKey *private_key; 703 struct GNUNET_CRYPTO_EccPrivateKey *private_key;
704 704
705 if ((NULL == id) || (NULL == system->hostkeys_data)) 705 if ((NULL == id) || (NULL == system->hostkeys_data))
706 return NULL; 706 return NULL;
707 if (key_number >= system->total_hostkeys) 707 if (key_number >= system->total_hostkeys)
@@ -709,13 +709,13 @@ GNUNET_TESTING_hostkey_get (const struct GNUNET_TESTING_System *system,
709 LOG (GNUNET_ERROR_TYPE_ERROR, 709 LOG (GNUNET_ERROR_TYPE_ERROR,
710 _("Key number %u does not exist\n"), key_number); 710 _("Key number %u does not exist\n"), key_number);
711 return NULL; 711 return NULL;
712 } 712 }
713 private_key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey); 713 private_key = GNUNET_new (struct GNUNET_CRYPTO_EccPrivateKey);
714 memcpy (private_key, 714 memcpy (private_key,
715 system->hostkeys_data + 715 system->hostkeys_data +
716 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE), 716 (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
717 GNUNET_TESTING_HOSTKEYFILESIZE); 717 GNUNET_TESTING_HOSTKEYFILESIZE);
718 GNUNET_CRYPTO_ecc_key_get_public_for_signature (private_key, 718 GNUNET_CRYPTO_ecc_key_get_public_for_signature (private_key,
719 &id->public_key); 719 &id->public_key);
720 return private_key; 720 return private_key;
721} 721}
@@ -731,7 +731,7 @@ struct UpdateContext
731 * The system for which we are building configurations 731 * The system for which we are building configurations
732 */ 732 */
733 struct GNUNET_TESTING_System *system; 733 struct GNUNET_TESTING_System *system;
734 734
735 /** 735 /**
736 * The configuration we are building 736 * The configuration we are building
737 */ 737 */
@@ -865,7 +865,7 @@ static void
865update_config_sections (void *cls, 865update_config_sections (void *cls,
866 const char *section) 866 const char *section)
867{ 867{
868 struct UpdateContext *uc = cls; 868 struct UpdateContext *uc = cls;
869 char **ikeys; 869 char **ikeys;
870 char *val; 870 char *val;
871 char *ptr; 871 char *ptr;
@@ -874,7 +874,7 @@ update_config_sections (void *cls,
874 char *ACCEPT_FROM_key; 874 char *ACCEPT_FROM_key;
875 uint16_t ikeys_cnt; 875 uint16_t ikeys_cnt;
876 uint16_t key; 876 uint16_t key;
877 877
878 ikeys_cnt = 0; 878 ikeys_cnt = 0;
879 val = NULL; 879 val = NULL;
880 /* Ignore certain options from sections. See 880 /* Ignore certain options from sections. See
@@ -882,8 +882,8 @@ update_config_sections (void *cls,
882 if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section, 882 if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section,
883 "TESTING_IGNORE_KEYS")) 883 "TESTING_IGNORE_KEYS"))
884 { 884 {
885 GNUNET_assert 885 GNUNET_assert
886 (GNUNET_YES == 886 (GNUNET_YES ==
887 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, 887 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section,
888 "TESTING_IGNORE_KEYS", &val)); 888 "TESTING_IGNORE_KEYS", &val));
889 ptr = val; 889 ptr = val;
@@ -915,10 +915,10 @@ update_config_sections (void *cls,
915 (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section, 915 (GNUNET_YES == GNUNET_CONFIGURATION_have_value (uc->cfg, section,
916 "ADVERTISED_PORT"))) 916 "ADVERTISED_PORT")))
917 { 917 {
918 if (GNUNET_OK == 918 if (GNUNET_OK ==
919 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "PORT", &ptr)) 919 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, "PORT", &ptr))
920 { 920 {
921 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, 921 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section,
922 "ADVERTISED_PORT", ptr); 922 "ADVERTISED_PORT", ptr);
923 GNUNET_free (ptr); 923 GNUNET_free (ptr);
924 } 924 }
@@ -935,11 +935,11 @@ update_config_sections (void *cls,
935 GNUNET_free (ikeys); 935 GNUNET_free (ikeys);
936 } 936 }
937 GNUNET_free_non_null (val); 937 GNUNET_free_non_null (val);
938 ACCEPT_FROM_key = "ACCEPT_FROM"; 938 ACCEPT_FROM_key = "ACCEPT_FROM";
939 if ((NULL != uc->system->trusted_ip) && 939 if ((NULL != uc->system->trusted_ip) &&
940 (NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */ 940 (NULL != strstr (uc->system->trusted_ip, ":"))) /* IPv6 in use */
941 ACCEPT_FROM_key = "ACCEPT_FROM6"; 941 ACCEPT_FROM_key = "ACCEPT_FROM6";
942 if (GNUNET_OK != 942 if (GNUNET_OK !=
943 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, ACCEPT_FROM_key, 943 GNUNET_CONFIGURATION_get_value_string (uc->cfg, section, ACCEPT_FROM_key,
944 &orig_allowed_hosts)) 944 &orig_allowed_hosts))
945 { 945 {
@@ -953,7 +953,7 @@ update_config_sections (void *cls,
953 GNUNET_free (orig_allowed_hosts); 953 GNUNET_free (orig_allowed_hosts);
954 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, ACCEPT_FROM_key, 954 GNUNET_CONFIGURATION_set_value_string (uc->cfg, section, ACCEPT_FROM_key,
955 allowed_hosts); 955 allowed_hosts);
956 GNUNET_free (allowed_hosts); 956 GNUNET_free (allowed_hosts);
957} 957}
958 958
959static struct SharedServiceInstance * 959static struct SharedServiceInstance *
@@ -969,9 +969,9 @@ associate_shared_service (struct GNUNET_TESTING_System *system,
969 ss->n_peers++; 969 ss->n_peers++;
970 if ( ((0 == ss->share) && (NULL == ss->instances)) 970 if ( ((0 == ss->share) && (NULL == ss->instances))
971 || 971 ||
972 ( (0 != ss->share) 972 ( (0 != ss->share)
973 && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) ) 973 && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) )
974 { 974 {
975 i = GNUNET_malloc (sizeof (struct SharedServiceInstance)); 975 i = GNUNET_malloc (sizeof (struct SharedServiceInstance));
976 i->ss = ss; 976 i->ss = ss;
977 (void) GNUNET_asprintf (&service_home, "%s/shared/%s/%u", 977 (void) GNUNET_asprintf (&service_home, "%s/shared/%s/%u",
@@ -1009,7 +1009,7 @@ associate_shared_service (struct GNUNET_TESTING_System *system,
1009 GNUNET_assert (0 < ss->n_instances); 1009 GNUNET_assert (0 < ss->n_instances);
1010 i = ss->instances[ss->n_instances - 1]; 1010 i = ss->instances[ss->n_instances - 1];
1011 } 1011 }
1012 GNUNET_CONFIGURATION_iterate_section_values(ss->cfg, ss->sname, 1012 GNUNET_CONFIGURATION_iterate_section_values(ss->cfg, ss->sname,
1013 &cfg_copy_iterator, cfg); 1013 &cfg_copy_iterator, cfg);
1014 GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "UNIXPATH", 1014 GNUNET_CONFIGURATION_set_value_string (cfg, ss->sname, "UNIXPATH",
1015 i->unix_sock); 1015 i->unix_sock);
@@ -1044,7 +1044,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system,
1044 unsigned int *nports) 1044 unsigned int *nports)
1045{ 1045{
1046 struct UpdateContext uc; 1046 struct UpdateContext uc;
1047 char *default_config; 1047 char *default_config;
1048 1048
1049 uc.system = system; 1049 uc.system = system;
1050 uc.cfg = cfg; 1050 uc.cfg = cfg;
@@ -1066,7 +1066,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system,
1066 /* allow connections to services from system trusted_ip host */ 1066 /* allow connections to services from system trusted_ip host */
1067 GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc); 1067 GNUNET_CONFIGURATION_iterate_sections (cfg, &update_config_sections, &uc);
1068 /* enable loopback-based connections between peers */ 1068 /* enable loopback-based connections between peers */
1069 GNUNET_CONFIGURATION_set_value_string (cfg, 1069 GNUNET_CONFIGURATION_set_value_string (cfg,
1070 "nat", 1070 "nat",
1071 "USE_LOCALADDR", "YES"); 1071 "USE_LOCALADDR", "YES");
1072 GNUNET_free (uc.service_home); 1072 GNUNET_free (uc.service_home);
@@ -1107,14 +1107,14 @@ GNUNET_TESTING_configuration_create (struct GNUNET_TESTING_System *system,
1107 1107
1108/** 1108/**
1109 * Configure a GNUnet peer. GNUnet must be installed on the local 1109 * Configure a GNUnet peer. GNUnet must be installed on the local
1110 * system and available in the PATH. 1110 * system and available in the PATH.
1111 * 1111 *
1112 * @param system system to use to coordinate resource usage 1112 * @param system system to use to coordinate resource usage
1113 * @param cfg configuration to use; will be UPDATED (to reflect needed 1113 * @param cfg configuration to use; will be UPDATED (to reflect needed
1114 * changes in port numbers and paths) 1114 * changes in port numbers and paths)
1115 * @param key_number number of the hostkey to use for the peer 1115 * @param key_number number of the hostkey to use for the peer
1116 * @param id identifier for the daemon, will be set, can be NULL 1116 * @param id identifier for the daemon, will be set, can be NULL
1117 * @param emsg set to freshly allocated error message (set to NULL on success), 1117 * @param emsg set to freshly allocated error message (set to NULL on success),
1118 * can be NULL 1118 * can be NULL
1119 * @return handle to the peer, NULL on error 1119 * @return handle to the peer, NULL on error
1120 */ 1120 */
@@ -1136,7 +1136,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1136 struct SharedService *ss; 1136 struct SharedService *ss;
1137 struct SharedServiceInstance **ss_instances; 1137 struct SharedServiceInstance **ss_instances;
1138 unsigned int cnt; 1138 unsigned int cnt;
1139 unsigned int nports; 1139 unsigned int nports;
1140 1140
1141 ports = NULL; 1141 ports = NULL;
1142 nports = 0; 1142 nports = 0;
@@ -1147,7 +1147,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1147 { 1147 {
1148 GNUNET_asprintf (&emsg_, 1148 GNUNET_asprintf (&emsg_,
1149 _("You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"), 1149 _("You attempted to create a testbed with more than %u hosts. Please precompute more hostkeys first.\n"),
1150 (unsigned int) system->total_hostkeys); 1150 (unsigned int) system->total_hostkeys);
1151 goto err_ret; 1151 goto err_ret;
1152 } 1152 }
1153 pk = NULL; 1153 pk = NULL;
@@ -1158,13 +1158,13 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1158 _("Failed to initialize hostkey for peer %u\n"), 1158 _("Failed to initialize hostkey for peer %u\n"),
1159 (unsigned int) key_number); 1159 (unsigned int) key_number);
1160 goto err_ret; 1160 goto err_ret;
1161 } 1161 }
1162 if (NULL != pk) 1162 if (NULL != pk)
1163 GNUNET_free (pk); 1163 GNUNET_free (pk);
1164 if (GNUNET_NO == 1164 if (GNUNET_NO ==
1165 GNUNET_CONFIGURATION_have_value (cfg, "PEER", "PRIVATE_KEY")) 1165 GNUNET_CONFIGURATION_have_value (cfg, "PEER", "PRIVATE_KEY"))
1166 { 1166 {
1167 GNUNET_asprintf (&emsg_, 1167 GNUNET_asprintf (&emsg_,
1168 _("PRIVATE_KEY option in PEER section missing in configuration\n")); 1168 _("PRIVATE_KEY option in PEER section missing in configuration\n"));
1169 goto err_ret; 1169 goto err_ret;
1170 } 1170 }
@@ -1182,13 +1182,13 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1182 "(not enough free ports?)\n")); 1182 "(not enough free ports?)\n"));
1183 goto err_ret; 1183 goto err_ret;
1184 } 1184 }
1185 GNUNET_assert (GNUNET_OK == 1185 GNUNET_assert (GNUNET_OK ==
1186 GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", 1186 GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER",
1187 "PRIVATE_KEY", 1187 "PRIVATE_KEY",
1188 &hostkey_filename)); 1188 &hostkey_filename));
1189 fd = GNUNET_DISK_file_open (hostkey_filename, 1189 fd = GNUNET_DISK_file_open (hostkey_filename,
1190 GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE, 1190 GNUNET_DISK_OPEN_CREATE | GNUNET_DISK_OPEN_WRITE,
1191 GNUNET_DISK_PERM_USER_READ 1191 GNUNET_DISK_PERM_USER_READ
1192 | GNUNET_DISK_PERM_USER_WRITE); 1192 | GNUNET_DISK_PERM_USER_WRITE);
1193 if (NULL == fd) 1193 if (NULL == fd)
1194 { 1194 {
@@ -1199,7 +1199,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1199 } 1199 }
1200 GNUNET_free (hostkey_filename); 1200 GNUNET_free (hostkey_filename);
1201 if (GNUNET_TESTING_HOSTKEYFILESIZE != 1201 if (GNUNET_TESTING_HOSTKEYFILESIZE !=
1202 GNUNET_DISK_file_write (fd, system->hostkeys_data 1202 GNUNET_DISK_file_write (fd, system->hostkeys_data
1203 + (key_number * GNUNET_TESTING_HOSTKEYFILESIZE), 1203 + (key_number * GNUNET_TESTING_HOSTKEYFILESIZE),
1204 GNUNET_TESTING_HOSTKEYFILESIZE)) 1204 GNUNET_TESTING_HOSTKEYFILESIZE))
1205 { 1205 {
@@ -1219,17 +1219,17 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system,
1219 ss_instances[cnt] = associate_shared_service (system, ss, cfg); 1219 ss_instances[cnt] = associate_shared_service (system, ss, cfg);
1220 if (NULL == ss_instances[cnt]) 1220 if (NULL == ss_instances[cnt])
1221 goto err_ret; 1221 goto err_ret;
1222 } 1222 }
1223 GNUNET_assert (GNUNET_OK == 1223 GNUNET_assert (GNUNET_OK ==
1224 GNUNET_CONFIGURATION_get_value_string 1224 GNUNET_CONFIGURATION_get_value_string
1225 (cfg, "PATHS", "DEFAULTCONFIG", &config_filename)); 1225 (cfg, "PATHS", "DEFAULTCONFIG", &config_filename));
1226 if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename)) 1226 if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config_filename))
1227 { 1227 {
1228 GNUNET_asprintf (&emsg_, 1228 GNUNET_asprintf (&emsg_,
1229 _("Failed to write configuration file `%s' for peer %u: %s\n"), 1229 _("Failed to write configuration file `%s' for peer %u: %s\n"),
1230 config_filename, 1230 config_filename,
1231 (unsigned int) key_number, 1231 (unsigned int) key_number,
1232 STRERROR (errno)); 1232 STRERROR (errno));
1233 GNUNET_free (config_filename); 1233 GNUNET_free (config_filename);
1234 goto err_ret; 1234 goto err_ret;
1235 } 1235 }
@@ -1289,7 +1289,7 @@ GNUNET_TESTING_peer_get_identity (struct GNUNET_TESTING_Peer *peer,
1289 1289
1290 1290
1291/** 1291/**
1292 * Start the peer. 1292 * Start the peer.
1293 * 1293 *
1294 * @param peer peer to start 1294 * @param peer peer to start
1295 * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running) 1295 * @return GNUNET_OK on success, GNUNET_SYSERR on error (i.e. peer already running)
@@ -1304,7 +1304,7 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
1304 { 1304 {
1305 GNUNET_break (0); 1305 GNUNET_break (0);
1306 return GNUNET_SYSERR; 1306 return GNUNET_SYSERR;
1307 } 1307 }
1308 GNUNET_assert (NULL != peer->cfgfile); 1308 GNUNET_assert (NULL != peer->cfgfile);
1309 for (cnt = 0; cnt < peer->system->n_shared_services; cnt++) 1309 for (cnt = 0; cnt < peer->system->n_shared_services; cnt++)
1310 { 1310 {
@@ -1314,7 +1314,7 @@ GNUNET_TESTING_peer_start (struct GNUNET_TESTING_Peer *peer)
1314 return GNUNET_SYSERR; 1314 return GNUNET_SYSERR;
1315 i->n_refs++; 1315 i->n_refs++;
1316 } 1316 }
1317 peer->main_process = GNUNET_OS_start_process (PIPE_CONTROL, 1317 peer->main_process = GNUNET_OS_start_process (PIPE_CONTROL,
1318 GNUNET_OS_INHERIT_STD_OUT_AND_ERR, 1318 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
1319 NULL, NULL, 1319 NULL, NULL,
1320 peer->main_binary, 1320 peer->main_binary,
@@ -1377,7 +1377,7 @@ GNUNET_TESTING_peer_service_start (struct GNUNET_TESTING_Peer *peer,
1377 * @return GNUNET_OK upon successfully queuing the service stop request; 1377 * @return GNUNET_OK upon successfully queuing the service stop request;
1378 * GNUNET_SYSERR upon error 1378 * GNUNET_SYSERR upon error
1379 */ 1379 */
1380int 1380int
1381GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer, 1381GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
1382 const char *service_name, 1382 const char *service_name,
1383 struct GNUNET_TIME_Relative timeout, 1383 struct GNUNET_TIME_Relative timeout,
@@ -1386,13 +1386,13 @@ GNUNET_TESTING_peer_service_stop (struct GNUNET_TESTING_Peer *peer,
1386{ 1386{
1387 if (NULL == peer->ah) 1387 if (NULL == peer->ah)
1388 return GNUNET_SYSERR; 1388 return GNUNET_SYSERR;
1389 GNUNET_ARM_request_service_stop (peer->ah, 1389 GNUNET_ARM_request_service_stop (peer->ah,
1390 service_name, 1390 service_name,
1391 timeout, 1391 timeout,
1392 cont, cont_cls); 1392 cont, cont_cls);
1393 return GNUNET_OK; 1393 return GNUNET_OK;
1394} 1394}
1395 1395
1396 1396
1397/** 1397/**
1398 * Sends SIGTERM to the peer's main process 1398 * Sends SIGTERM to the peer's main process
@@ -1451,7 +1451,7 @@ GNUNET_TESTING_peer_wait (struct GNUNET_TESTING_Peer *peer)
1451 1451
1452 1452
1453/** 1453/**
1454 * Stop the peer. 1454 * Stop the peer.
1455 * 1455 *
1456 * @param peer peer to stop 1456 * @param peer peer to stop
1457 * @return GNUNET_OK on success, GNUNET_SYSERR on error 1457 * @return GNUNET_OK on success, GNUNET_SYSERR on error
@@ -1475,7 +1475,7 @@ GNUNET_TESTING_peer_stop (struct GNUNET_TESTING_Peer *peer)
1475 * GNUNET_SYSERR on error. 1475 * GNUNET_SYSERR on error.
1476 */ 1476 */
1477static void 1477static void
1478disconn_status (void *cls, 1478disconn_status (void *cls,
1479 int connected) 1479 int connected)
1480{ 1480{
1481 struct GNUNET_TESTING_Peer *peer = cls; 1481 struct GNUNET_TESTING_Peer *peer = cls;
@@ -1514,7 +1514,7 @@ GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer,
1514 void *cb_cls) 1514 void *cb_cls)
1515{ 1515{
1516 if (NULL == peer->main_process) 1516 if (NULL == peer->main_process)
1517 return GNUNET_SYSERR; 1517 return GNUNET_SYSERR;
1518 peer->ah = GNUNET_ARM_connect (peer->cfg, &disconn_status, peer); 1518 peer->ah = GNUNET_ARM_connect (peer->cfg, &disconn_status, peer);
1519 if (NULL == peer->ah) 1519 if (NULL == peer->ah)
1520 return GNUNET_SYSERR; 1520 return GNUNET_SYSERR;
@@ -1535,7 +1535,7 @@ GNUNET_TESTING_peer_stop_async (struct GNUNET_TESTING_Peer *peer,
1535 */ 1535 */
1536void 1536void
1537GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer) 1537GNUNET_TESTING_peer_stop_async_cancel (struct GNUNET_TESTING_Peer *peer)
1538{ 1538{
1539 GNUNET_assert (NULL != peer->ah); 1539 GNUNET_assert (NULL != peer->ah);
1540 GNUNET_ARM_disconnect_and_free (peer->ah); 1540 GNUNET_ARM_disconnect_and_free (peer->ah);
1541 peer->ah = NULL; 1541 peer->ah = NULL;
@@ -1618,7 +1618,7 @@ struct ServiceContext
1618 * Callback to signal service startup 1618 * Callback to signal service startup
1619 */ 1619 */
1620 GNUNET_TESTING_TestMain tm; 1620 GNUNET_TESTING_TestMain tm;
1621 1621
1622 /** 1622 /**
1623 * The peer in which the service is run. 1623 * The peer in which the service is run.
1624 */ 1624 */
@@ -1719,7 +1719,7 @@ GNUNET_TESTING_service_run (const char *testdir,
1719 GNUNET_free (libexec_binary); 1719 GNUNET_free (libexec_binary);
1720 GNUNET_free (binary); 1720 GNUNET_free (binary);
1721 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer)) 1721 if (GNUNET_OK != GNUNET_TESTING_peer_start (peer))
1722 { 1722 {
1723 GNUNET_TESTING_peer_destroy (peer); 1723 GNUNET_TESTING_peer_destroy (peer);
1724 GNUNET_CONFIGURATION_destroy (cfg); 1724 GNUNET_CONFIGURATION_destroy (cfg);
1725 GNUNET_TESTING_system_destroy (system, GNUNET_YES); 1725 GNUNET_TESTING_system_destroy (system, GNUNET_YES);
@@ -1749,14 +1749,14 @@ GNUNET_TESTING_service_run (const char *testdir,
1749 * Sometimes we use the binary name to determine which specific 1749 * Sometimes we use the binary name to determine which specific
1750 * test to run. In those cases, the string after the last "_" 1750 * test to run. In those cases, the string after the last "_"
1751 * in 'argv[0]' specifies a string that determines the configuration 1751 * in 'argv[0]' specifies a string that determines the configuration
1752 * file or plugin to use. 1752 * file or plugin to use.
1753 * 1753 *
1754 * This function returns the respective substring, taking care 1754 * This function returns the respective substring, taking care
1755 * of issues such as binaries ending in '.exe' on W32. 1755 * of issues such as binaries ending in '.exe' on W32.
1756 * 1756 *
1757 * @param argv0 the name of the binary 1757 * @param argv0 the name of the binary
1758 * @return string between the last '_' and the '.exe' (or the end of the string), 1758 * @return string between the last '_' and the '.exe' (or the end of the string),
1759 * NULL if argv0 has no '_' 1759 * NULL if argv0 has no '_'
1760 */ 1760 */
1761char * 1761char *
1762GNUNET_TESTING_get_testname_from_underscore (const char *argv0) 1762GNUNET_TESTING_get_testname_from_underscore (const char *argv0)