aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_topology_blacklist.c
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
committerNathan S. Evans <evans@in.tum.de>2010-11-05 18:21:50 +0000
commit75a33a1499cf60ea4364c9aa673816629a6c1413 (patch)
tree0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/testing/test_testing_topology_blacklist.c
parent7217c601ad30760872823193d62307e7a335d226 (diff)
downloadgnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz
gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/testing/test_testing_topology_blacklist.c')
-rw-r--r--src/testing/test_testing_topology_blacklist.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c
index 8f9a469e5..13df683e9 100644
--- a/src/testing/test_testing_topology_blacklist.c
+++ b/src/testing/test_testing_topology_blacklist.c
@@ -57,8 +57,6 @@ static unsigned long long peers_left;
57 57
58static struct GNUNET_TESTING_PeerGroup *pg; 58static struct GNUNET_TESTING_PeerGroup *pg;
59 59
60static struct GNUNET_SCHEDULER_Handle *sched;
61
62const struct GNUNET_CONFIGURATION_Handle *main_cfg; 60const struct GNUNET_CONFIGURATION_Handle *main_cfg;
63 61
64GNUNET_SCHEDULER_TaskIdentifier die_task; 62GNUNET_SCHEDULER_TaskIdentifier die_task;
@@ -213,25 +211,22 @@ topology_callback (void *cls,
213 total_connections); 211 total_connections);
214#endif 212#endif
215 213
216 GNUNET_SCHEDULER_cancel (sched, die_task); 214 GNUNET_SCHEDULER_cancel (die_task);
217 die_task = GNUNET_SCHEDULER_NO_TASK; 215 die_task = GNUNET_SCHEDULER_NO_TASK;
218 die_task = GNUNET_SCHEDULER_add_now (sched, 216 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many successful connections)");
219 &end_badly, "from topology_callback (too many successful connections)");
220 } 217 }
221 else if (total_connections + failed_connections == expected_connections) 218 else if (total_connections + failed_connections == expected_connections)
222 { 219 {
223 if ((failed_connections == expected_failed_connections) && (total_connections == expected_connections - expected_failed_connections)) 220 if ((failed_connections == expected_failed_connections) && (total_connections == expected_connections - expected_failed_connections))
224 { 221 {
225 GNUNET_SCHEDULER_cancel (sched, die_task); 222 GNUNET_SCHEDULER_cancel (die_task);
226 die_task = GNUNET_SCHEDULER_NO_TASK; 223 die_task = GNUNET_SCHEDULER_NO_TASK;
227 die_task = GNUNET_SCHEDULER_add_now (sched, 224 die_task = GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
228 &finish_testing, NULL);
229 } 225 }
230 else 226 else
231 { 227 {
232 GNUNET_SCHEDULER_cancel (sched, die_task); 228 GNUNET_SCHEDULER_cancel (die_task);
233 die_task = GNUNET_SCHEDULER_add_now (sched, 229 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (wrong number of failed connections)");
234 &end_badly, "from topology_callback (wrong number of failed connections)");
235 } 230 }
236 } 231 }
237 else 232 else
@@ -257,15 +252,13 @@ connect_topology ()
257#endif 252#endif
258 } 253 }
259 254
260 GNUNET_SCHEDULER_cancel (sched, die_task); 255 GNUNET_SCHEDULER_cancel (die_task);
261 if (expected_connections == GNUNET_SYSERR) 256 if (expected_connections == GNUNET_SYSERR)
262 { 257 {
263 die_task = GNUNET_SCHEDULER_add_now (sched, 258 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)");
264 &end_badly, "from connect topology (bad return)");
265 } 259 }
266 260
267 die_task = GNUNET_SCHEDULER_add_delayed (sched, 261 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
268 TEST_TIMEOUT,
269 &end_badly, "from connect topology (timeout)"); 262 &end_badly, "from connect topology (timeout)");
270} 263}
271 264
@@ -283,13 +276,11 @@ create_topology ()
283 } 276 }
284 else 277 else
285 { 278 {
286 GNUNET_SCHEDULER_cancel (sched, die_task); 279 GNUNET_SCHEDULER_cancel (die_task);
287 die_task = GNUNET_SCHEDULER_add_now (sched, 280 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)");
288 &end_badly, "from create topology (bad return)");
289 } 281 }
290 GNUNET_SCHEDULER_cancel (sched, die_task); 282 GNUNET_SCHEDULER_cancel (die_task);
291 die_task = GNUNET_SCHEDULER_add_delayed (sched, 283 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
292 TEST_TIMEOUT,
293 &end_badly, "from continue startup (timeout)"); 284 &end_badly, "from continue startup (timeout)");
294} 285}
295 286
@@ -319,11 +310,10 @@ peers_started_callback (void *cls,
319 "All %d daemons started, now creating topology!\n", 310 "All %d daemons started, now creating topology!\n",
320 num_peers); 311 num_peers);
321#endif 312#endif
322 GNUNET_SCHEDULER_cancel (sched, die_task); 313 GNUNET_SCHEDULER_cancel (die_task);
323 /* Set up task in case topology creation doesn't finish 314 /* Set up task in case topology creation doesn't finish
324 * within a reasonable amount of time */ 315 * within a reasonable amount of time */
325 die_task = GNUNET_SCHEDULER_add_delayed (sched, 316 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
326 GNUNET_TIME_relative_multiply
327 (GNUNET_TIME_UNIT_MINUTES, 5), 317 (GNUNET_TIME_UNIT_MINUTES, 5),
328 &end_badly, "from peers_started_callback"); 318 &end_badly, "from peers_started_callback");
329 connect_topology (); 319 connect_topology ();
@@ -362,21 +352,19 @@ void hostkey_callback (void *cls,
362 "All %d hostkeys created, now creating topology!\n", 352 "All %d hostkeys created, now creating topology!\n",
363 num_peers); 353 num_peers);
364#endif 354#endif
365 GNUNET_SCHEDULER_cancel (sched, die_task); 355 GNUNET_SCHEDULER_cancel (die_task);
366 /* Set up task in case topology creation doesn't finish 356 /* Set up task in case topology creation doesn't finish
367 * within a reasonable amount of time */ 357 * within a reasonable amount of time */
368 die_task = GNUNET_SCHEDULER_add_delayed (sched, 358 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
369 GNUNET_TIME_relative_multiply
370 (GNUNET_TIME_UNIT_MINUTES, 5), 359 (GNUNET_TIME_UNIT_MINUTES, 5),
371 &end_badly, "from hostkey_callback"); 360 &end_badly, "from hostkey_callback");
372 GNUNET_SCHEDULER_add_now(sched, &create_topology, NULL); 361 GNUNET_SCHEDULER_add_now(&create_topology, NULL);
373 ok = 0; 362 ok = 0;
374 } 363 }
375} 364}
376 365
377static void 366static void
378run (void *cls, 367run (void *cls,
379 struct GNUNET_SCHEDULER_Handle *s,
380 char *const *args, 368 char *const *args,
381 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 369 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
382{ 370{
@@ -385,7 +373,6 @@ run (void *cls,
385 unsigned long long blacklist_topology_num; 373 unsigned long long blacklist_topology_num;
386 unsigned long long connect_topology_option_num; 374 unsigned long long connect_topology_option_num;
387 char *connect_topology_option_modifier_string; 375 char *connect_topology_option_modifier_string;
388 sched = s;
389 ok = 1; 376 ok = 1;
390 377
391 dotOutFile = fopen (dotOutFileName, "w"); 378 dotOutFile = fopen (dotOutFileName, "w");
@@ -483,12 +470,11 @@ run (void *cls,
483 470
484 471
485 /* Set up a task to end testing if peer start fails */ 472 /* Set up a task to end testing if peer start fails */
486 die_task = GNUNET_SCHEDULER_add_delayed (sched, 473 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
487 GNUNET_TIME_relative_multiply
488 (GNUNET_TIME_UNIT_MINUTES, 5), 474 (GNUNET_TIME_UNIT_MINUTES, 5),
489 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 475 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
490 476
491 pg = GNUNET_TESTING_daemons_start (sched, cfg, 477 pg = GNUNET_TESTING_daemons_start (cfg,
492 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL, 478 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL,
493 &topology_callback, NULL, NULL); 479 &topology_callback, NULL, NULL);
494 480