aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-05 16:16:46 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-05 16:16:46 +0000
commit69a23725d6937db68fc8ca2fd1e8490220edc7de (patch)
treeb4a4060dfb25ccf18254e0b726120c9b6bef9ee5 /src/testing
parentcf96e25a7a3c3864bb936b1b82fd086ca8d16a5e (diff)
downloadgnunet-69a23725d6937db68fc8ca2fd1e8490220edc7de.tar.gz
gnunet-69a23725d6937db68fc8ca2fd1e8490220edc7de.zip
UNIX domain socket support
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_testing_connect_peer1.conf6
-rw-r--r--src/testing/test_testing_connect_peer2.conf6
-rw-r--r--src/testing/testing_group.c42
3 files changed, 47 insertions, 7 deletions
diff --git a/src/testing/test_testing_connect_peer1.conf b/src/testing/test_testing_connect_peer1.conf
index 76e5ee536..9b240c855 100644
--- a/src/testing/test_testing_connect_peer1.conf
+++ b/src/testing/test_testing_connect_peer1.conf
@@ -4,10 +4,12 @@ DEFAULTCONFIG = test_testing_connect_peer1.conf
4 4
5[resolver] 5[resolver]
6PORT = 12564 6PORT = 12564
7UNIXPATH = /tmp/gnunet-p1-service-resolver.sock
7HOSTNAME = localhost 8HOSTNAME = localhost
8 9
9[transport] 10[transport]
10PORT = 12565 11PORT = 12565
12UNIXPATH = /tmp/gnunet-p1-service-transport.sock
11HOSTNAME = localhost 13HOSTNAME = localhost
12PLUGINS = tcp 14PLUGINS = tcp
13#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args 15#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args
@@ -15,12 +17,14 @@ PLUGINS = tcp
15 17
16[arm] 18[arm]
17PORT = 12566 19PORT = 12566
20UNIXPATH = /tmp/gnunet-p1-service-arm.sock
18HOSTNAME = localhost 21HOSTNAME = localhost
19DEFAULTSERVICES = 22DEFAULTSERVICES =
20#DEBUG = YES 23#DEBUG = YES
21 24
22[statistics] 25[statistics]
23PORT = 12567 26PORT = 12567
27UNIXPATH = /tmp/gnunet-p1-service-statistics.sock
24HOSTNAME = localhost 28HOSTNAME = localhost
25 29
26[transport-tcp] 30[transport-tcp]
@@ -28,10 +32,12 @@ PORT = 12568
28 32
29[peerinfo] 33[peerinfo]
30PORT = 12569 34PORT = 12569
35UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock
31HOSTNAME = localhost 36HOSTNAME = localhost
32 37
33[core] 38[core]
34PORT = 12570 39PORT = 12570
40UNIXPATH = /tmp/gnunet-p1-service-core.sock
35HOSTNAME = localhost 41HOSTNAME = localhost
36#DEBUG = YES 42#DEBUG = YES
37 43
diff --git a/src/testing/test_testing_connect_peer2.conf b/src/testing/test_testing_connect_peer2.conf
index 5e8ae7a18..5d4237343 100644
--- a/src/testing/test_testing_connect_peer2.conf
+++ b/src/testing/test_testing_connect_peer2.conf
@@ -4,10 +4,12 @@ DEFAULTCONFIG = test_testing_connect_peer2.conf
4 4
5[resolver] 5[resolver]
6PORT = 22564 6PORT = 22564
7UNIXPATH = /tmp/gnunet-p2-service-resolver.sock
7HOSTNAME = localhost 8HOSTNAME = localhost
8 9
9[transport] 10[transport]
10PORT = 22565 11PORT = 22565
12UNIXPATH = /tmp/gnunet-p2-service-transport.sock
11HOSTNAME = localhost 13HOSTNAME = localhost
12PLUGINS = tcp 14PLUGINS = tcp
13#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args 15#PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args
@@ -15,12 +17,14 @@ PLUGINS = tcp
15 17
16[arm] 18[arm]
17PORT = 22566 19PORT = 22566
20UNIXPATH = /tmp/gnunet-p2-service-arm.sock
18DEFAULTSERVICES = 21DEFAULTSERVICES =
19HOSTNAME = localhost 22HOSTNAME = localhost
20#DEBUG = YES 23#DEBUG = YES
21 24
22[statistics] 25[statistics]
23PORT = 22567 26PORT = 22567
27UNIXPATH = /tmp/gnunet-p2-service-statistics.sock
24HOSTNAME = localhost 28HOSTNAME = localhost
25 29
26[transport-tcp] 30[transport-tcp]
@@ -28,10 +32,12 @@ PORT = 22568
28 32
29[peerinfo] 33[peerinfo]
30PORT = 22569 34PORT = 22569
35UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock
31HOSTNAME = localhost 36HOSTNAME = localhost
32 37
33[core] 38[core]
34PORT = 22570 39PORT = 22570
40UNIXPATH = /tmp/gnunet-p2-service-core.sock
35HOSTNAME = localhost 41HOSTNAME = localhost
36#DEBUG = YES 42#DEBUG = YES
37 43
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)