aboutsummaryrefslogtreecommitdiff
path: root/src/testing/gnunet-testing.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-12-08 15:32:52 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-08 15:32:52 +0000
commit747c7710b9244744d9b94f67a0698b40ff129ebe (patch)
treec855e53071a7390b196336839e331d0adbef82c2 /src/testing/gnunet-testing.c
parent552bd66357207dce17ba7e4da082c9d8156e5afe (diff)
downloadgnunet-747c7710b9244744d9b94f67a0698b40ff129ebe.tar.gz
gnunet-747c7710b9244744d9b94f67a0698b40ff129ebe.zip
modified to create cfg with default without template
Diffstat (limited to 'src/testing/gnunet-testing.c')
-rw-r--r--src/testing/gnunet-testing.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c
index a6fb3735c..1c518fef9 100644
--- a/src/testing/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -68,15 +68,17 @@ create_unique_cfgs (const char * template, const unsigned int no)
68 struct GNUNET_CONFIGURATION_Handle *cfg_new = NULL; 68 struct GNUNET_CONFIGURATION_Handle *cfg_new = NULL;
69 struct GNUNET_CONFIGURATION_Handle *cfg_tmpl = GNUNET_CONFIGURATION_create(); 69 struct GNUNET_CONFIGURATION_Handle *cfg_tmpl = GNUNET_CONFIGURATION_create();
70 70
71 71 /* load template */
72 72 if ((create_cfg_template != NULL) && (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template)))
73 if (GNUNET_OK != GNUNET_CONFIGURATION_load(cfg_tmpl, create_cfg_template))
74 { 73 {
75 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template); 74 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not load template `%s'\n", create_cfg_template);
76 GNUNET_CONFIGURATION_destroy(cfg_tmpl); 75 GNUNET_CONFIGURATION_destroy(cfg_tmpl);
77 76
78 return 1; 77 return 1;
79 } 78 }
79 /* load defaults */
80 else
81 GNUNET_CONFIGURATION_load(cfg_tmpl, NULL);
80 82
81 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg_tmpl, "PATHS", "SERVICEHOME", &service_home)) 83 if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string(cfg_tmpl, "PATHS", "SERVICEHOME", &service_home))
82 { 84 {
@@ -92,7 +94,10 @@ create_unique_cfgs (const char * template, const unsigned int no)
92 while (cur < no) 94 while (cur < no)
93 { 95 {
94 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur); 96 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating configuration no. %u \n", cur);
95 GNUNET_asprintf (&cur_file,"%04u-%s",cur, create_cfg_template); 97 if (create_cfg_template != NULL)
98 GNUNET_asprintf (&cur_file,"%04u-%s",cur, create_cfg_template);
99 else
100 GNUNET_asprintf (&cur_file,"%04u%s",cur, ".conf");
96 101
97 102
98 GNUNET_asprintf (&cur_service_home, "%s-%04u%c",service_home, cur, DIR_SEPARATOR); 103 GNUNET_asprintf (&cur_service_home, "%s-%04u%c",service_home, cur, DIR_SEPARATOR);
@@ -219,22 +224,34 @@ run (void *cls, char *const *args, const char *cfgfile,
219 const struct GNUNET_CONFIGURATION_Handle *cfg) 224 const struct GNUNET_CONFIGURATION_Handle *cfg)
220{ 225{
221 /* main code here */ 226 /* main code here */
222 if ((create_cfg == GNUNET_YES) && 227 if (create_cfg == GNUNET_YES)
223 (create_no > 0) &&
224 (create_cfg_template != NULL))
225 {
226 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating %u configuration files based on template `%s'\n", create_no, create_cfg_template);
227 ret = create_unique_cfgs (create_cfg_template, create_no);
228 }
229 else if ((create_hostkey == GNUNET_YES) && (create_no > 0))
230 { 228 {
231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating %u hostkeys \n", create_no); 229 if (create_no > 0)
232 ret = create_hostkeys (create_no); 230 {
231 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating %u configuration files based on template `%s'\n", create_no, create_cfg_template);
232 ret = create_unique_cfgs (create_cfg_template, create_no);
233 }
234 else
235 {
236 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing arguments! \n");
237 ret = 1;
238 }
233 } 239 }
234 else 240
241 if (create_hostkey == GNUNET_YES)
235 { 242 {
236 ret = 1; 243 if (create_no > 0)
244 {
245 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating %u hostkeys \n", create_no);
246 ret = create_hostkeys (create_no);
247 }
248 else
249 {
250 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing arguments! \n");
251 ret = 1;
252 }
237 } 253 }
254
238 GNUNET_free_non_null (create_cfg_template); 255 GNUNET_free_non_null (create_cfg_template);
239} 256}
240 257