aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index bf90ea4b0..2920594c5 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -313,8 +313,9 @@ uid_from_hash (const GNUNET_HashCode *hash, uint32_t *uid)
313struct UpdateContext 313struct UpdateContext
314{ 314{
315 struct GNUNET_CONFIGURATION_Handle *ret; 315 struct GNUNET_CONFIGURATION_Handle *ret;
316 unsigned int nport;
317 const char *hostname; 316 const char *hostname;
317 unsigned int nport;
318 unsigned int upnum;
318}; 319};
319 320
320 321
@@ -351,11 +352,25 @@ update_config (void *cls,
351 struct UpdateContext *ctx = cls; 352 struct UpdateContext *ctx = cls;
352 unsigned int ival; 353 unsigned int ival;
353 char cval[12]; 354 char cval[12];
355 char uval[128];
354 356
355 if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival))) 357 if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
356 { 358 {
357 GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++); 359 if (ival != 0)
358 value = cval; 360 {
361 GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++);
362 value = cval;
363 }
364 }
365
366 if (0 == strcmp (option, "UNIXPATH"))
367 {
368 GNUNET_snprintf (uval,
369 sizeof (uval),
370 "/tmp/test-service-%s-%u",
371 section,
372 ctx->upnum++);
373 value = uval;
359 } 374 }
360 375
361 if ((0 == strcmp (option, "HOSTNAME")) && (ctx->hostname != NULL)) 376 if ((0 == strcmp (option, "HOSTNAME")) && (ctx->hostname != NULL))
@@ -376,12 +391,16 @@ update_config (void *cls,
376 * @param cfg template configuration 391 * @param cfg template configuration
377 * @param port port numbers to use, update to reflect 392 * @param port port numbers to use, update to reflect
378 * port numbers that were used 393 * port numbers that were used
394 * @param upnum number to make unix domain socket names unique
379 * @param hostname hostname of the controlling host, to allow control connections from 395 * @param hostname hostname of the controlling host, to allow control connections from
380 * 396 *
381 * @return new configuration, NULL on error 397 * @return new configuration, NULL on error
382 */ 398 */
383static struct GNUNET_CONFIGURATION_Handle * 399static struct GNUNET_CONFIGURATION_Handle *
384make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t * port, const char *hostname) 400make_config (const struct GNUNET_CONFIGURATION_Handle *cfg,
401 uint16_t * port,
402 uint32_t * upnum,
403 const char *hostname)
385{ 404{
386 struct UpdateContext uc; 405 struct UpdateContext uc;
387 uint16_t orig; 406 uint16_t orig;
@@ -390,6 +409,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t * port, con
390 409
391 orig = *port; 410 orig = *port;
392 uc.nport = *port; 411 uc.nport = *port;
412 uc.upnum = *upnum;
393 uc.ret = GNUNET_CONFIGURATION_create (); 413 uc.ret = GNUNET_CONFIGURATION_create ();
394 uc.hostname = hostname; 414 uc.hostname = hostname;
395 415
@@ -420,6 +440,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint16_t * port, con
420 } 440 }
421 441
422 *port = (uint16_t) uc.nport; 442 *port = (uint16_t) uc.nport;
443 *upnum = uc.upnum;
423 return uc.ret; 444 return uc.ret;
424} 445}
425 446
@@ -2499,13 +2520,14 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2499 unsigned int off; 2520 unsigned int off;
2500 unsigned int hostcnt; 2521 unsigned int hostcnt;
2501 uint16_t minport; 2522 uint16_t minport;
2523 uint32_t upnum;
2502 2524
2503 if (0 == total) 2525 if (0 == total)
2504 { 2526 {
2505 GNUNET_break (0); 2527 GNUNET_break (0);
2506 return NULL; 2528 return NULL;
2507 } 2529 }
2508 2530 upnum = 0;
2509 pg = GNUNET_malloc (sizeof (struct GNUNET_TESTING_PeerGroup)); 2531 pg = GNUNET_malloc (sizeof (struct GNUNET_TESTING_PeerGroup));
2510 pg->sched = sched; 2532 pg->sched = sched;
2511 pg->cfg = cfg; 2533 pg->cfg = cfg;
@@ -2571,12 +2593,18 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2571 if (hostcnt > 0) 2593 if (hostcnt > 0)
2572 { 2594 {
2573 hostname = pg->hosts[off % hostcnt].hostname; 2595 hostname = pg->hosts[off % hostcnt].hostname;
2574 pcfg = make_config (cfg, &pg->hosts[off % hostcnt].minport, hostname); 2596 pcfg = make_config (cfg,
2597 &pg->hosts[off % hostcnt].minport,
2598 &upnum,
2599 hostname);
2575 } 2600 }
2576 else 2601 else
2577 { 2602 {
2578 hostname = NULL; 2603 hostname = NULL;
2579 pcfg = make_config (cfg, &minport, hostname); 2604 pcfg = make_config (cfg,
2605 &minport,
2606 &upnum,
2607 hostname);
2580 } 2608 }
2581 2609
2582 if (NULL == pcfg) 2610 if (NULL == pcfg)