aboutsummaryrefslogtreecommitdiff
path: root/src/testing/gnunet-testing.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-12-07 15:34:26 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-07 15:34:26 +0000
commit81f52a300c6569a292db1137690347b0986fe953 (patch)
treeade90606789541153e90af872c290741fd559e41 /src/testing/gnunet-testing.c
parentc2565e9520ced234dcf2615a0f215cf8ac7db2f6 (diff)
downloadgnunet-81f52a300c6569a292db1137690347b0986fe953.tar.gz
gnunet-81f52a300c6569a292db1137690347b0986fe953.zip
Diffstat (limited to 'src/testing/gnunet-testing.c')
-rw-r--r--src/testing/gnunet-testing.c46
1 files changed, 45 insertions, 1 deletions
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;
43static int 43static int
44create_unique_cfgs (const char * template, const unsigned int no) 44create_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/**