diff options
Diffstat (limited to 'src/ats/test_ats_api_scheduling_block_and_reset.c')
-rw-r--r-- | src/ats/test_ats_api_scheduling_block_and_reset.c | 105 |
1 files changed, 66 insertions, 39 deletions
diff --git a/src/ats/test_ats_api_scheduling_block_and_reset.c b/src/ats/test_ats_api_scheduling_block_and_reset.c index b799a5de3..d5bd58031 100644 --- a/src/ats/test_ats_api_scheduling_block_and_reset.c +++ b/src/ats/test_ats_api_scheduling_block_and_reset.c | |||
@@ -150,44 +150,48 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
150 | if (3 == stage) | 150 | if (3 == stage) |
151 | { | 151 | { |
152 | /* Suggestion after resetting block interval */ | 152 | /* Suggestion after resetting block interval */ |
153 | reset_block_duration = GNUNET_TIME_absolute_get_difference(reset_block_start, GNUNET_TIME_absolute_get()); | 153 | reset_block_duration = GNUNET_TIME_absolute_get_difference (reset_block_start, |
154 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address suggestion after resetting blocking took about %llu ms!\n", | 154 | GNUNET_TIME_absolute_get()); |
155 | (long long unsigned int) reset_block_duration.rel_value); | 155 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
156 | if ((block_duration.rel_value <= (initial_duration.rel_value * 3)) || | 156 | "Address suggestion after resetting blocking took about %s!\n", |
157 | (initial_duration.rel_value <= (block_duration.rel_value * 3))) | 157 | GNUNET_STRINGS_relative_time_to_string (reset_block_duration, |
158 | GNUNET_YES)); | ||
159 | if ((block_duration.rel_value_us <= (initial_duration.rel_value_us * 3)) || | ||
160 | (initial_duration.rel_value_us <= (block_duration.rel_value_us * 3))) | ||
158 | { | 161 | { |
159 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 162 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
160 | "Address suggestion after resetting blocking (%llu ms) took about the same as initial suggestion (%llu ms)\n", | 163 | "Address suggestion after resetting blocking took about the same as initial suggestion (%s)\n", |
161 | (long long unsigned int) reset_block_duration.rel_value, | 164 | GNUNET_STRINGS_relative_time_to_string (initial_duration, |
162 | (long long unsigned int) initial_duration.rel_value); | 165 | GNUNET_YES)); |
163 | ret = 0; | 166 | ret = 0; |
164 | } | 167 | } |
165 | else | 168 | else |
166 | { | 169 | { |
167 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address suggestion after resetting blocking (%llu ms) has too big difference to initial suggestion (%llu ms)\n", | 170 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
168 | (long long unsigned int) reset_block_duration.rel_value, | 171 | "Address suggestion after resetting blocking has too big difference to initial suggestion (%s)\n", |
169 | (long long unsigned int) initial_duration.rel_value); | 172 | GNUNET_STRINGS_relative_time_to_string (initial_duration, |
173 | GNUNET_YES)); | ||
170 | ret = 1; | 174 | ret = 1; |
171 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 175 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
172 | GNUNET_SCHEDULER_add_now (&end, NULL); | 176 | GNUNET_SCHEDULER_add_now (&end, NULL); |
173 | return; | 177 | return; |
174 | } | 178 | } |
175 | 179 | ||
176 | if (((initial_duration.rel_value * 3) <= block_duration.rel_value ) && | 180 | if (((initial_duration.rel_value_us * 3) <= block_duration.rel_value_us) && |
177 | ((reset_block_duration.rel_value * 3) <= block_duration.rel_value)) | 181 | ((reset_block_duration.rel_value_us * 3) <= block_duration.rel_value_us)) |
178 | { | 182 | { |
179 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address suggestion after resetting blocking (%llu ms) and initial suggestion (%llu ms) much faster than with blocking (%llu ms)\n", | 183 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
180 | (long long unsigned int) reset_block_duration.rel_value, | 184 | "Address suggestion after resetting blocking and initial suggestion (%llu us) much faster than with blocking (%llu us)\n", |
181 | (long long unsigned int) initial_duration.rel_value, | 185 | (unsigned long long) initial_duration.rel_value_us, |
182 | (long long unsigned int) block_duration.rel_value); | 186 | (unsigned long long) block_duration.rel_value_us); |
183 | ret = 0; | 187 | ret = 0; |
184 | } | 188 | } |
185 | else | 189 | else |
186 | { | 190 | { |
187 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Address suggestion after resetting blocking (%llu ms) and initial suggestion (%llu ms) not faster than with blocking (%llu ms)\n", | 191 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
188 | (long long unsigned int) reset_block_duration.rel_value, | 192 | "Address suggestion after resetting blocking and initial suggestion (%llu us) not faster than with blocking (%llu us)\n", |
189 | (long long unsigned int) initial_duration.rel_value, | 193 | (unsigned long long) initial_duration.rel_value_us, |
190 | (long long unsigned int) block_duration.rel_value); | 194 | (unsigned long long) block_duration.rel_value_us); |
191 | ret = 1; | 195 | ret = 1; |
192 | } | 196 | } |
193 | 197 | ||
@@ -200,18 +204,22 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
200 | { | 204 | { |
201 | /* Suggestion after block*/ | 205 | /* Suggestion after block*/ |
202 | block_duration = GNUNET_TIME_absolute_get_difference(block_start, GNUNET_TIME_absolute_get()); | 206 | block_duration = GNUNET_TIME_absolute_get_difference(block_start, GNUNET_TIME_absolute_get()); |
203 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Address suggestion was blocked for about %llu ms!\n", | 207 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
204 | (long long unsigned int) block_duration.rel_value); | 208 | "Address suggestion was blocked for about %s!\n", |
209 | GNUNET_STRINGS_relative_time_to_string (block_duration, | ||
210 | GNUNET_YES)); | ||
205 | 211 | ||
206 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session)) | 212 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session)) |
207 | { | 213 | { |
208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", stage, | 214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
215 | "Stage %u: Callback with correct address `%s'\n", stage, | ||
209 | GNUNET_i2s (&address->peer)); | 216 | GNUNET_i2s (&address->peer)); |
210 | ret = 0; | 217 | ret = 0; |
211 | } | 218 | } |
212 | else | 219 | else |
213 | { | 220 | { |
214 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", stage, | 221 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
222 | "Stage %u: Callback with invalid address `%s'\n", stage, | ||
215 | GNUNET_i2s (&address->peer)); | 223 | GNUNET_i2s (&address->peer)); |
216 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 224 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
217 | GNUNET_SCHEDULER_add_now (&end, NULL); | 225 | GNUNET_SCHEDULER_add_now (&end, NULL); |
@@ -220,7 +228,8 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
220 | 228 | ||
221 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) | 229 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) |
222 | { | 230 | { |
223 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n"); | 231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
232 | "Stage %u: Callback with incorrect ats info \n"); | ||
224 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 233 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
225 | GNUNET_SCHEDULER_add_now (&end, NULL); | 234 | GNUNET_SCHEDULER_add_now (&end, NULL); |
226 | ret = 1; | 235 | ret = 1; |
@@ -237,13 +246,17 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
237 | /* Initial suggestion */ | 246 | /* Initial suggestion */ |
238 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session)) | 247 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session)) |
239 | { | 248 | { |
240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", stage, | 249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
250 | "Stage %u: Callback with correct address `%s'\n", | ||
251 | stage, | ||
241 | GNUNET_i2s (&address->peer)); | 252 | GNUNET_i2s (&address->peer)); |
242 | ret = 0; | 253 | ret = 0; |
243 | } | 254 | } |
244 | else | 255 | else |
245 | { | 256 | { |
246 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", stage, | 257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
258 | "Stage %u: Callback with invalid address `%s'\n", | ||
259 | stage, | ||
247 | GNUNET_i2s (&address->peer)); | 260 | GNUNET_i2s (&address->peer)); |
248 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 261 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
249 | GNUNET_SCHEDULER_add_now (&end, NULL); | 262 | GNUNET_SCHEDULER_add_now (&end, NULL); |
@@ -252,15 +265,20 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
252 | 265 | ||
253 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) | 266 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) |
254 | { | 267 | { |
255 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n"); | 268 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
269 | "Stage %u: Callback with incorrect ats info\n", | ||
270 | stage); | ||
256 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 271 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
257 | GNUNET_SCHEDULER_add_now (&end, NULL); | 272 | GNUNET_SCHEDULER_add_now (&end, NULL); |
258 | ret = 1; | 273 | ret = 1; |
259 | } | 274 | } |
260 | stage ++; | 275 | stage++; |
261 | initial_duration = GNUNET_TIME_absolute_get_difference(initial_start, GNUNET_TIME_absolute_get()); | 276 | initial_duration = GNUNET_TIME_absolute_get_difference(initial_start, GNUNET_TIME_absolute_get()); |
262 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %u: Initial suggestion took about %llu ms\n", stage, | 277 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
263 | (long long unsigned int) block_duration.rel_value); | 278 | "Stage %u: Initial suggestion took about %s\n", |
279 | stage, | ||
280 | GNUNET_STRINGS_relative_time_to_string (block_duration, | ||
281 | GNUNET_YES)); | ||
264 | 282 | ||
265 | block_start = GNUNET_TIME_absolute_get(); | 283 | block_start = GNUNET_TIME_absolute_get(); |
266 | wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &request_task, NULL); | 284 | wait_task = GNUNET_SCHEDULER_add_delayed (WAIT, &request_task, NULL); |
@@ -270,22 +288,28 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address, | |||
270 | /* Startup suggestion */ | 288 | /* Startup suggestion */ |
271 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session)) | 289 | if (GNUNET_OK == compare_addresses (address, session, &test_hello_address, test_session)) |
272 | { | 290 | { |
273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with correct address `%s'\n", stage, | 291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
292 | "Stage %u: Callback with correct address `%s'\n", | ||
293 | stage, | ||
274 | GNUNET_i2s (&address->peer)); | 294 | GNUNET_i2s (&address->peer)); |
275 | ret = 0; | 295 | ret = 0; |
276 | } | 296 | } |
277 | else | 297 | else |
278 | { | 298 | { |
279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stage %u: Callback with invalid address `%s'\n", stage, | 299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
300 | "Stage %u: Callback with invalid address `%s'\n", | ||
301 | stage, | ||
280 | GNUNET_i2s (&address->peer)); | 302 | GNUNET_i2s (&address->peer)); |
281 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 303 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
282 | GNUNET_SCHEDULER_add_now (&end, NULL); | 304 | GNUNET_SCHEDULER_add_now (&end, NULL); |
283 | ret = 1; | 305 | ret = 1; |
284 | } | 306 | } |
285 | 307 | ||
286 | if (GNUNET_OK != compare_ats(atsi, ats_count, test_ats_info, test_ats_count)) | 308 | if (GNUNET_OK != compare_ats (atsi, ats_count, test_ats_info, test_ats_count)) |
287 | { | 309 | { |
288 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %u: Callback with incorrect ats info \n"); | 310 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
311 | "Stage %u: Callback with incorrect ats info\n", | ||
312 | stage); | ||
289 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); | 313 | GNUNET_ATS_suggest_address_cancel (sched_ats, &p.id); |
290 | GNUNET_SCHEDULER_add_now (&end, NULL); | 314 | GNUNET_SCHEDULER_add_now (&end, NULL); |
291 | ret = 1; | 315 | ret = 1; |
@@ -312,7 +336,8 @@ run (void *cls, | |||
312 | sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL); | 336 | sched_ats = GNUNET_ATS_scheduling_init (cfg, &address_suggest_cb, NULL); |
313 | if (sched_ats == NULL) | 337 | if (sched_ats == NULL) |
314 | { | 338 | { |
315 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect to ATS scheduling!\n"); | 339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
340 | "Could not connect to ATS scheduling!\n"); | ||
316 | ret = 1; | 341 | ret = 1; |
317 | end (); | 342 | end (); |
318 | return; | 343 | return; |
@@ -321,14 +346,16 @@ run (void *cls, | |||
321 | /* Set up peer */ | 346 | /* Set up peer */ |
322 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) | 347 | if (GNUNET_SYSERR == GNUNET_CRYPTO_hash_from_string(PEERID0, &p.id.hashPubKey)) |
323 | { | 348 | { |
324 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not setup peer!\n"); | 349 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
350 | "Could not setup peer!\n"); | ||
325 | ret = GNUNET_SYSERR; | 351 | ret = GNUNET_SYSERR; |
326 | end (); | 352 | end (); |
327 | return; | 353 | return; |
328 | } | 354 | } |
329 | GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id))); | 355 | GNUNET_assert (0 == strcmp (PEERID0, GNUNET_i2s_full (&p.id))); |
330 | 356 | ||
331 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created peer `%s'\n", | 357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
358 | "Created peer `%s'\n", | ||
332 | GNUNET_i2s_full(&p.id)); | 359 | GNUNET_i2s_full(&p.id)); |
333 | 360 | ||
334 | /* Prepare ATS Information */ | 361 | /* Prepare ATS Information */ |