diff options
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index c2033935d..a0d8e261b 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -103,7 +103,8 @@ struct GNUNET_TESTING_System | |||
103 | { | 103 | { |
104 | /** | 104 | /** |
105 | * Prefix (i.e. "/tmp/gnunet-testing/") we prepend to each | 105 | * Prefix (i.e. "/tmp/gnunet-testing/") we prepend to each |
106 | * SERVICEHOME. */ | 106 | * GNUNET_HOME. |
107 | */ | ||
107 | char *tmppath; | 108 | char *tmppath; |
108 | 109 | ||
109 | /** | 110 | /** |
@@ -747,7 +748,7 @@ struct UpdateContext | |||
747 | /** | 748 | /** |
748 | * The customized service home path for this peer | 749 | * The customized service home path for this peer |
749 | */ | 750 | */ |
750 | char *service_home; | 751 | char *gnunet_home; |
751 | 752 | ||
752 | /** | 753 | /** |
753 | * Array of ports currently allocated to this peer. These ports will be | 754 | * Array of ports currently allocated to this peer. These ports will be |
@@ -839,7 +840,7 @@ update_config (void *cls, const char *section, const char *option, | |||
839 | single_variable)) | 840 | single_variable)) |
840 | { | 841 | { |
841 | GNUNET_snprintf (uval, sizeof (uval), "%s/%s.sock", | 842 | GNUNET_snprintf (uval, sizeof (uval), "%s/%s.sock", |
842 | uc->service_home, section); | 843 | uc->gnunet_home, section); |
843 | value = uval; | 844 | value = uval; |
844 | } | 845 | } |
845 | else if ((GNUNET_YES == | 846 | else if ((GNUNET_YES == |
@@ -970,7 +971,7 @@ associate_shared_service (struct GNUNET_TESTING_System *system, | |||
970 | { | 971 | { |
971 | struct SharedServiceInstance *i; | 972 | struct SharedServiceInstance *i; |
972 | struct GNUNET_CONFIGURATION_Handle *temp; | 973 | struct GNUNET_CONFIGURATION_Handle *temp; |
973 | char *service_home; | 974 | char *gnunet_home; |
974 | uint32_t port; | 975 | uint32_t port; |
975 | 976 | ||
976 | ss->n_peers++; | 977 | ss->n_peers++; |
@@ -979,25 +980,25 @@ associate_shared_service (struct GNUNET_TESTING_System *system, | |||
979 | ( (0 != ss->share) | 980 | ( (0 != ss->share) |
980 | && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) ) | 981 | && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) ) |
981 | { | 982 | { |
982 | i = GNUNET_malloc (sizeof (struct SharedServiceInstance)); | 983 | i = GNUNET_new (struct SharedServiceInstance); |
983 | i->ss = ss; | 984 | i->ss = ss; |
984 | (void) GNUNET_asprintf (&service_home, "%s/shared/%s/%u", | 985 | (void) GNUNET_asprintf (&gnunet_home, "%s/shared/%s/%u", |
985 | system->tmppath, ss->sname, ss->n_instances); | 986 | system->tmppath, ss->sname, ss->n_instances); |
986 | (void) GNUNET_asprintf (&i->unix_sock, "%s/sock", service_home); | 987 | (void) GNUNET_asprintf (&i->unix_sock, "%s/sock", gnunet_home); |
987 | port = GNUNET_TESTING_reserve_port (system); | 988 | port = GNUNET_TESTING_reserve_port (system); |
988 | if (0 == port) | 989 | if (0 == port) |
989 | { | 990 | { |
990 | GNUNET_free (service_home); | 991 | GNUNET_free (gnunet_home); |
991 | cleanup_shared_service_instance (i); | 992 | cleanup_shared_service_instance (i); |
992 | return NULL; | 993 | return NULL; |
993 | } | 994 | } |
994 | GNUNET_array_append (ss->instances, ss->n_instances, i); | 995 | GNUNET_array_append (ss->instances, ss->n_instances, i); |
995 | temp = GNUNET_CONFIGURATION_dup (ss->cfg); | 996 | temp = GNUNET_CONFIGURATION_dup (ss->cfg); |
996 | (void) GNUNET_asprintf (&i->port_str, "%u", port); | 997 | (void) GNUNET_asprintf (&i->port_str, "%u", port); |
997 | (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", service_home); | 998 | (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", gnunet_home); |
998 | GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "SERVICEHOME", | 999 | GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "GNUNET_HOME", |
999 | service_home); | 1000 | gnunet_home); |
1000 | GNUNET_free (service_home); | 1001 | GNUNET_free (gnunet_home); |
1001 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH", | 1002 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH", |
1002 | i->unix_sock); | 1003 | i->unix_sock); |
1003 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT", | 1004 | GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT", |
@@ -1029,9 +1030,9 @@ associate_shared_service (struct GNUNET_TESTING_System *system, | |||
1029 | * Create a new configuration using the given configuration as a template; | 1030 | * Create a new configuration using the given configuration as a template; |
1030 | * ports and paths will be modified to select available ports on the local | 1031 | * ports and paths will be modified to select available ports on the local |
1031 | * system. The default configuration will be available in PATHS section under | 1032 | * system. The default configuration will be available in PATHS section under |
1032 | * the option DEFAULTCONFIG after the call. SERVICE_HOME is also set in PATHS | 1033 | * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS |
1033 | * section to the temporary directory specific to this configuration. If we run | 1034 | * section to the temporary directory specific to this configuration. If we run |
1034 | * out of "*port" numbers, return SYSERR. | 1035 | * out of "*port" numbers, return #GNUNET_SYSERR. |
1035 | * | 1036 | * |
1036 | * This is primarily a helper function used internally | 1037 | * This is primarily a helper function used internally |
1037 | * by 'GNUNET_TESTING_peer_configure'. | 1038 | * by 'GNUNET_TESTING_peer_configure'. |
@@ -1041,7 +1042,7 @@ associate_shared_service (struct GNUNET_TESTING_System *system, | |||
1041 | * @param ports array with port numbers used in the created configuration. | 1042 | * @param ports array with port numbers used in the created configuration. |
1042 | * Will be updated upon successful return. Can be NULL | 1043 | * Will be updated upon successful return. Can be NULL |
1043 | * @param nports the size of the `ports' array. Will be updated. | 1044 | * @param nports the size of the `ports' array. Will be updated. |
1044 | * @return GNUNET_OK on success, GNUNET_SYSERR on error - the configuration will | 1045 | * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - the configuration will |
1045 | * be incomplete and should not be used there upon | 1046 | * be incomplete and should not be used there upon |
1046 | */ | 1047 | */ |
1047 | static int | 1048 | static int |
@@ -1058,16 +1059,16 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system, | |||
1058 | uc.status = GNUNET_OK; | 1059 | uc.status = GNUNET_OK; |
1059 | uc.ports = NULL; | 1060 | uc.ports = NULL; |
1060 | uc.nports = 0; | 1061 | uc.nports = 0; |
1061 | GNUNET_asprintf (&uc.service_home, "%s/%u", system->tmppath, | 1062 | GNUNET_asprintf (&uc.gnunet_home, "%s/%u", system->tmppath, |
1062 | system->path_counter++); | 1063 | system->path_counter++); |
1063 | GNUNET_asprintf (&default_config, "%s/config", uc.service_home); | 1064 | GNUNET_asprintf (&default_config, "%s/config", uc.gnunet_home); |
1064 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", | 1065 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", |
1065 | default_config); | 1066 | default_config); |
1066 | GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", | 1067 | GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", |
1067 | default_config); | 1068 | default_config); |
1068 | GNUNET_free (default_config); | 1069 | GNUNET_free (default_config); |
1069 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "SERVICEHOME", | 1070 | GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "GNUNET_HOME", |
1070 | uc.service_home); | 1071 | uc.gnunet_home); |
1071 | /* make PORTs and UNIXPATHs unique */ | 1072 | /* make PORTs and UNIXPATHs unique */ |
1072 | GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc); | 1073 | GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc); |
1073 | /* allow connections to services from system trusted_ip host */ | 1074 | /* allow connections to services from system trusted_ip host */ |
@@ -1076,7 +1077,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system, | |||
1076 | GNUNET_CONFIGURATION_set_value_string (cfg, | 1077 | GNUNET_CONFIGURATION_set_value_string (cfg, |
1077 | "nat", | 1078 | "nat", |
1078 | "USE_LOCALADDR", "YES"); | 1079 | "USE_LOCALADDR", "YES"); |
1079 | GNUNET_free (uc.service_home); | 1080 | GNUNET_free (uc.gnunet_home); |
1080 | if ((NULL != ports) && (NULL != nports)) | 1081 | if ((NULL != ports) && (NULL != nports)) |
1081 | { | 1082 | { |
1082 | *ports = uc.ports; | 1083 | *ports = uc.ports; |
@@ -1092,7 +1093,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system, | |||
1092 | * Create a new configuration using the given configuration as a template; | 1093 | * Create a new configuration using the given configuration as a template; |
1093 | * ports and paths will be modified to select available ports on the local | 1094 | * ports and paths will be modified to select available ports on the local |
1094 | * system. The default configuration will be available in PATHS section under | 1095 | * system. The default configuration will be available in PATHS section under |
1095 | * the option DEFAULTCONFIG after the call. SERVICE_HOME is also set in PATHS | 1096 | * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS |
1096 | * section to the temporary directory specific to this configuration. If we run | 1097 | * section to the temporary directory specific to this configuration. If we run |
1097 | * out of "*port" numbers, return SYSERR. | 1098 | * out of "*port" numbers, return SYSERR. |
1098 | * | 1099 | * |