diff options
Diffstat (limited to 'src/testing/test_testing_group_remote.c')
-rw-r--r-- | src/testing/test_testing_group_remote.c | 188 |
1 files changed, 92 insertions, 96 deletions
diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c index 58f3c4143..d43e7ed57 100644 --- a/src/testing/test_testing_group_remote.c +++ b/src/testing/test_testing_group_remote.c | |||
@@ -54,20 +54,20 @@ void | |||
54 | shutdown_callback (void *cls, const char *emsg) | 54 | shutdown_callback (void *cls, const char *emsg) |
55 | { | 55 | { |
56 | if (emsg != NULL) | 56 | if (emsg != NULL) |
57 | { | 57 | { |
58 | #if VERBOSE | 58 | #if VERBOSE |
59 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed (error %s)!\n", emsg); | 59 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
60 | "Shutdown of peers failed (error %s)!\n", emsg); | ||
60 | #endif | 61 | #endif |
61 | if (ok == 0) | 62 | if (ok == 0) |
62 | ok = 666; | 63 | ok = 666; |
63 | } | 64 | } |
64 | else | 65 | else |
65 | { | 66 | { |
66 | #if VERBOSE | 67 | #if VERBOSE |
67 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 68 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n"); |
68 | "All peers successfully shut down!\n"); | ||
69 | #endif | 69 | #endif |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
@@ -78,22 +78,22 @@ my_cb (void *cls, | |||
78 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 78 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
79 | { | 79 | { |
80 | if (emsg != NULL) | 80 | if (emsg != NULL) |
81 | { | 81 | { |
82 | peers_failed++; | 82 | peers_failed++; |
83 | } | 83 | } |
84 | 84 | ||
85 | peers_left--; | 85 | peers_left--; |
86 | if (peers_left == 0) | 86 | if (peers_left == 0) |
87 | { | 87 | { |
88 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 88 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
89 | ok = 0; | 89 | ok = 0; |
90 | } | 90 | } |
91 | else if (peers_failed == peers_left) | 91 | else if (peers_failed == peers_left) |
92 | { | 92 | { |
93 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 93 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
94 | "Too many peers failed, ending test!\n"); | 94 | "Too many peers failed, ending test!\n"); |
95 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); | 95 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | 99 | ||
@@ -111,6 +111,7 @@ run (void *cls, | |||
111 | char *data; | 111 | char *data; |
112 | int count; | 112 | int count; |
113 | int ret; | 113 | int ret; |
114 | |||
114 | ok = 1; | 115 | ok = 1; |
115 | #if VERBOSE | 116 | #if VERBOSE |
116 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); | 117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); |
@@ -130,93 +131,89 @@ run (void *cls, | |||
130 | hosts = NULL; | 131 | hosts = NULL; |
131 | data = NULL; | 132 | data = NULL; |
132 | if (hostfile != NULL) | 133 | if (hostfile != NULL) |
134 | { | ||
135 | if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) | ||
136 | GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ | ||
137 | | GNUNET_DISK_PERM_USER_WRITE); | ||
138 | if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) | ||
133 | { | 139 | { |
134 | if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) | 140 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
135 | GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ | 141 | "Could not open file specified for host list, ending test!"); |
136 | | GNUNET_DISK_PERM_USER_WRITE); | 142 | ok = 1119; |
137 | if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) | 143 | GNUNET_free (hostfile); |
138 | { | 144 | return; |
139 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 145 | } |
140 | "Could not open file specified for host list, ending test!"); | ||
141 | ok = 1119; | ||
142 | GNUNET_free (hostfile); | ||
143 | return; | ||
144 | } | ||
145 | 146 | ||
146 | data = GNUNET_malloc_large (frstat.st_size); | 147 | data = GNUNET_malloc_large (frstat.st_size); |
147 | GNUNET_assert (data != NULL); | 148 | GNUNET_assert (data != NULL); |
148 | if (frstat.st_size != | 149 | if (frstat.st_size != GNUNET_DISK_fn_read (hostfile, data, frstat.st_size)) |
149 | GNUNET_DISK_fn_read (hostfile, data, frstat.st_size)) | 150 | { |
150 | { | 151 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
151 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 152 | "Could not read file %s specified for host list, ending test!", |
152 | "Could not read file %s specified for host list, ending test!", | 153 | hostfile); |
153 | hostfile); | 154 | GNUNET_free (hostfile); |
154 | GNUNET_free (hostfile); | 155 | GNUNET_free (data); |
155 | GNUNET_free (data); | 156 | return; |
156 | return; | 157 | } |
157 | } | ||
158 | 158 | ||
159 | GNUNET_free_non_null (hostfile); | 159 | GNUNET_free_non_null (hostfile); |
160 | 160 | ||
161 | buf = data; | 161 | buf = data; |
162 | count = 0; | 162 | count = 0; |
163 | while (count < frstat.st_size) | 163 | while (count < frstat.st_size) |
164 | { | ||
165 | count++; | ||
166 | if (count >= frstat.st_size) | ||
167 | break; | ||
168 | |||
169 | /* if (((data[count] == '\n') || (data[count] == '\0')) && (buf != &data[count])) */ | ||
170 | if (((data[count] == '\n')) && (buf != &data[count])) | ||
171 | { | ||
172 | data[count] = '\0'; | ||
173 | temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); | ||
174 | ret = | ||
175 | sscanf (buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", | ||
176 | &temphost->username, &temphost->hostname, &temphost->port); | ||
177 | if (3 == ret) | ||
178 | { | ||
179 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
180 | "Successfully read host %s, port %d and user %s from file\n", | ||
181 | temphost->hostname, temphost->port, temphost->username); | ||
182 | } | ||
183 | else | ||
164 | { | 184 | { |
165 | count++; | 185 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
166 | if (count >= frstat.st_size) | 186 | "Error reading line `%s' in hostfile\n", buf); |
167 | break; | 187 | GNUNET_free (temphost); |
168 | 188 | buf = &data[count + 1]; | |
169 | /* if (((data[count] == '\n') || (data[count] == '\0')) && (buf != &data[count])) */ | 189 | continue; |
170 | if (((data[count] == '\n')) && (buf != &data[count])) | ||
171 | { | ||
172 | data[count] = '\0'; | ||
173 | temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); | ||
174 | ret = | ||
175 | sscanf (buf, "%a[a-zA-Z0-9]@%a[a-zA-Z0-9.]:%hd", | ||
176 | &temphost->username, &temphost->hostname, | ||
177 | &temphost->port); | ||
178 | if (3 == ret) | ||
179 | { | ||
180 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
181 | "Successfully read host %s, port %d and user %s from file\n", | ||
182 | temphost->hostname, temphost->port, | ||
183 | temphost->username); | ||
184 | } | ||
185 | else | ||
186 | { | ||
187 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
188 | "Error reading line `%s' in hostfile\n", buf); | ||
189 | GNUNET_free (temphost); | ||
190 | buf = &data[count + 1]; | ||
191 | continue; | ||
192 | } | ||
193 | /* temphost->hostname = buf; */ | ||
194 | temphost->next = hosts; | ||
195 | hosts = temphost; | ||
196 | buf = &data[count + 1]; | ||
197 | } | ||
198 | else if ((data[count] == '\n') || (data[count] == '\0')) | ||
199 | buf = &data[count + 1]; | ||
200 | } | 190 | } |
191 | /* temphost->hostname = buf; */ | ||
192 | temphost->next = hosts; | ||
193 | hosts = temphost; | ||
194 | buf = &data[count + 1]; | ||
195 | } | ||
196 | else if ((data[count] == '\n') || (data[count] == '\0')) | ||
197 | buf = &data[count + 1]; | ||
201 | } | 198 | } |
199 | } | ||
202 | 200 | ||
203 | peers_left = num_peers; | 201 | peers_left = num_peers; |
204 | pg = GNUNET_TESTING_daemons_start (cfg, | 202 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ |
205 | peers_left, /* Total number of peers */ | 203 | peers_left, /* Number of outstanding connections */ |
206 | peers_left, /* Number of outstanding connections */ | 204 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ |
207 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | ||
208 | TIMEOUT, | 205 | TIMEOUT, |
209 | NULL, | 206 | NULL, |
210 | NULL, &my_cb, NULL, NULL, NULL, hosts); | 207 | NULL, &my_cb, NULL, NULL, NULL, hosts); |
211 | hostpos = hosts; | 208 | hostpos = hosts; |
212 | while (hostpos != NULL) | 209 | while (hostpos != NULL) |
213 | { | 210 | { |
214 | temphost = hostpos->next; | 211 | temphost = hostpos->next; |
215 | GNUNET_free (hostpos->hostname); | 212 | GNUNET_free (hostpos->hostname); |
216 | GNUNET_free (hostpos->username); | 213 | GNUNET_free (hostpos->username); |
217 | GNUNET_free (hostpos); | 214 | GNUNET_free (hostpos); |
218 | hostpos = temphost; | 215 | hostpos = temphost; |
219 | } | 216 | } |
220 | GNUNET_free_non_null (data); | 217 | GNUNET_free_non_null (data); |
221 | GNUNET_assert (pg != NULL); | 218 | GNUNET_assert (pg != NULL); |
222 | 219 | ||
@@ -237,8 +234,7 @@ check () | |||
237 | GNUNET_GETOPT_OPTION_END | 234 | GNUNET_GETOPT_OPTION_END |
238 | }; | 235 | }; |
239 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 236 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
240 | argv, "test-testing-group", "nohelp", | 237 | argv, "test-testing-group", "nohelp", options, &run, &ok); |
241 | options, &run, &ok); | ||
242 | return ok; | 238 | return ok; |
243 | } | 239 | } |
244 | 240 | ||