diff options
-rw-r--r-- | src/include/gnunet_testing_lib.h | 23 | ||||
-rw-r--r-- | src/testing/gnunet-testing.c | 46 | ||||
-rw-r--r-- | src/testing/testing_group.c | 11 |
3 files changed, 74 insertions, 6 deletions
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h index e3e10ce45..711d676a2 100644 --- a/src/include/gnunet_testing_lib.h +++ b/src/include/gnunet_testing_lib.h | |||
@@ -614,6 +614,29 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
614 | int delete_files, int allow_restart); | 614 | int delete_files, int allow_restart); |
615 | 615 | ||
616 | 616 | ||
617 | |||
618 | /** | ||
619 | * Create a new configuration using the given configuration | ||
620 | * as a template; however, each PORT in the existing cfg | ||
621 | * must be renumbered by incrementing "*port". If we run | ||
622 | * out of "*port" numbers, return NULL. | ||
623 | * | ||
624 | * @param cfg template configuration | ||
625 | * @param off the current peer offset | ||
626 | * @param port port numbers to use, update to reflect | ||
627 | * port numbers that were used | ||
628 | * @param upnum number to make unix domain socket names unique | ||
629 | * @param hostname hostname of the controlling host, to allow control connections from | ||
630 | * @param fdnum number used to offset the unix domain socket for grouped processes | ||
631 | * (such as statistics or peerinfo, which can be shared among others) | ||
632 | * | ||
633 | * @return new configuration, NULL on error | ||
634 | */ | ||
635 | struct GNUNET_CONFIGURATION_Handle * | ||
636 | GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, | ||
637 | uint16_t * port, uint32_t * upnum, const char *hostname, | ||
638 | uint32_t * fdnum); | ||
639 | |||
617 | /** | 640 | /** |
618 | * Changes the configuration of a GNUnet daemon. | 641 | * Changes the configuration of a GNUnet daemon. |
619 | * | 642 | * |
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c index a65e19d6f..e0d5d4f28 100644 --- a/src/testing/gnunet-testing.c +++ b/src/testing/gnunet-testing.c | |||
@@ -43,12 +43,56 @@ static char * create_cfg_template; | |||
43 | static int | 43 | static int |
44 | create_unique_cfgs (const char * template, const unsigned int no) | 44 | create_unique_cfgs (const char * template, const unsigned int no) |
45 | { | 45 | { |
46 | int fail = GNUNET_NO; | ||
47 | |||
48 | uint16_t port = 20000; | ||
49 | uint32_t upnum = 1; | ||
50 | uint32_t fdnum = 1; | ||
51 | |||
46 | if (GNUNET_NO == GNUNET_DISK_file_test(template)) | 52 | if (GNUNET_NO == GNUNET_DISK_file_test(template)) |
47 | { | 53 | { |
48 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template); | 54 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template); |
49 | return 1; | 55 | return 1; |
50 | } | 56 | } |
51 | return 0; | 57 | |
58 | int cur = 0; | ||
59 | char * cur_file; | ||
60 | struct GNUNET_CONFIGURATION_Handle *cfg_tmpl = GNUNET_CONFIGURATION_create(); | ||
61 | struct GNUNET_CONFIGURATION_Handle *cfg_new = NULL; | ||
62 | |||
63 | if (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template)) | ||
64 | { | ||
65 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template); | ||
66 | GNUNET_CONFIGURATION_destroy(cfg_tmpl); | ||
67 | |||
68 | return 1; | ||
69 | } | ||
70 | |||
71 | while (cur < no) | ||
72 | { | ||
73 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Creating configuration no. %u \n", cur); | ||
74 | GNUNET_asprintf(&cur_file,"%04u-%s",cur, create_cfg_template); | ||
75 | cfg_new = GNUNET_TESTING_create_cfg(cfg_tmpl, cur, &port, &upnum, NULL, &fdnum); | ||
76 | |||
77 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Writing configuration no. %u to file `%s' \n", cur, cur_file); | ||
78 | if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg_new, cur_file)) | ||
79 | { | ||
80 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to write configuration no. %u \n", cur); | ||
81 | fail = GNUNET_YES; | ||
82 | } | ||
83 | |||
84 | |||
85 | GNUNET_free (cur_file); | ||
86 | if (fail == GNUNET_YES) | ||
87 | break; | ||
88 | cur ++; | ||
89 | } | ||
90 | |||
91 | GNUNET_CONFIGURATION_destroy(cfg_tmpl); | ||
92 | if (fail == GNUNET_NO) | ||
93 | return 0; | ||
94 | else | ||
95 | return 1; | ||
52 | } | 96 | } |
53 | 97 | ||
54 | /** | 98 | /** |
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index 26aac5e7c..f56c51381 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c | |||
@@ -1435,8 +1435,8 @@ update_config (void *cls, const char *section, const char *option, | |||
1435 | * | 1435 | * |
1436 | * @return new configuration, NULL on error | 1436 | * @return new configuration, NULL on error |
1437 | */ | 1437 | */ |
1438 | static struct GNUNET_CONFIGURATION_Handle * | 1438 | struct GNUNET_CONFIGURATION_Handle * |
1439 | make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, | 1439 | GNUNET_TESTING_create_cfg (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, |
1440 | uint16_t * port, uint32_t * upnum, const char *hostname, | 1440 | uint16_t * port, uint32_t * upnum, const char *hostname, |
1441 | uint32_t * fdnum) | 1441 | uint32_t * fdnum) |
1442 | { | 1442 | { |
@@ -1540,6 +1540,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, | |||
1540 | } | 1540 | } |
1541 | else | 1541 | else |
1542 | { | 1542 | { |
1543 | |||
1543 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp", | 1544 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-tcp", |
1544 | "USE_LOCALADDR", "YES"); | 1545 | "USE_LOCALADDR", "YES"); |
1545 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp", | 1546 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport-udp", |
@@ -1550,7 +1551,7 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off, | |||
1550 | "127.0.0.1"); | 1551 | "127.0.0.1"); |
1551 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "EXTERNAL_ADDRESS", | 1552 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "EXTERNAL_ADDRESS", |
1552 | "127.0.0.1"); | 1553 | "127.0.0.1"); |
1553 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "disablev6", "BINDTO", | 1554 | GNUNET_CONFIGURATION_set_value_string (uc.ret, "nat", "disablev6", |
1554 | "YES"); | 1555 | "YES"); |
1555 | } | 1556 | } |
1556 | 1557 | ||
@@ -6159,7 +6160,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
6159 | username = pg->hosts[off % hostcnt].username; | 6160 | username = pg->hosts[off % hostcnt].username; |
6160 | sshport = pg->hosts[off % hostcnt].sshport; | 6161 | sshport = pg->hosts[off % hostcnt].sshport; |
6161 | pcfg = | 6162 | pcfg = |
6162 | make_config (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum, | 6163 | GNUNET_TESTING_create_cfg (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum, |
6163 | hostname, &fdnum); | 6164 | hostname, &fdnum); |
6164 | } | 6165 | } |
6165 | else | 6166 | else |
@@ -6167,7 +6168,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
6167 | hostname = NULL; | 6168 | hostname = NULL; |
6168 | username = NULL; | 6169 | username = NULL; |
6169 | sshport = 0; | 6170 | sshport = 0; |
6170 | pcfg = make_config (cfg, off, &minport, &upnum, hostname, &fdnum); | 6171 | pcfg = GNUNET_TESTING_create_cfg (cfg, off, &minport, &upnum, hostname, &fdnum); |
6171 | } | 6172 | } |
6172 | 6173 | ||
6173 | if (NULL == pcfg) | 6174 | if (NULL == pcfg) |