aboutsummaryrefslogtreecommitdiff
path: root/src/testing/gnunet-testing.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-12-07 13:23:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-12-07 13:23:01 +0000
commit9d66be3547caed59bdb553ebef6368fba810d453 (patch)
tree28476f58d568e1555d6280d6311b7c32a98e8e44 /src/testing/gnunet-testing.c
parenta9d4cb8397cf2a981ccecdc01d1ec380b41e858e (diff)
downloadgnunet-9d66be3547caed59bdb553ebef6368fba810d453.tar.gz
gnunet-9d66be3547caed59bdb553ebef6368fba810d453.zip
Diffstat (limited to 'src/testing/gnunet-testing.c')
-rw-r--r--src/testing/gnunet-testing.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c
index 63756e502..a65e19d6f 100644
--- a/src/testing/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -26,12 +26,31 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_getopt_lib.h" 27#include "gnunet_getopt_lib.h"
28#include "gnunet_program_lib.h" 28#include "gnunet_program_lib.h"
29#include "gnunet_testing_lib.h"
29 30
30/** 31/**
31 * Final status code. 32 * Final status code.
32 */ 33 */
33static int ret; 34static int ret;
34 35
36unsigned int create_cfg;
37
38 int create_cfg_no;
39
40static char * create_cfg_template;
41
42
43static int
44create_unique_cfgs (const char * template, const unsigned int no)
45{
46 if (GNUNET_NO == GNUNET_DISK_file_test(template))
47 {
48 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template);
49 return 1;
50 }
51 return 0;
52}
53
35/** 54/**
36 * Main function that will be run by the scheduler. 55 * Main function that will be run by the scheduler.
37 * 56 *
@@ -45,6 +64,18 @@ run (void *cls, char *const *args, const char *cfgfile,
45 const struct GNUNET_CONFIGURATION_Handle *cfg) 64 const struct GNUNET_CONFIGURATION_Handle *cfg)
46{ 65{
47 /* main code here */ 66 /* main code here */
67 if ((create_cfg == GNUNET_YES) &&
68 (create_cfg_no > 0) &&
69 (create_cfg_template != NULL))
70 {
71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Creating %u configuration files based on template `%s'\n", create_cfg_no, create_cfg_template);
72 ret = create_unique_cfgs (create_cfg_template, create_cfg_no);
73 }
74 else
75 {
76 ret = 1;
77 }
78 GNUNET_free_non_null (create_cfg_template);
48} 79}
49 80
50 81
@@ -59,7 +90,12 @@ int
59main (int argc, char *const *argv) 90main (int argc, char *const *argv)
60{ 91{
61 static const struct GNUNET_GETOPT_CommandLineOption options[] = { 92 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
62 /* FIMXE: add options here */ 93 {'C', "create", NULL, gettext_noop ("create unique configuration files"),
94 GNUNET_NO, &GNUNET_GETOPT_set_one, &create_cfg},
95 {'n', "number", NULL, gettext_noop ("number of unique configuration files to create"),
96 GNUNET_YES, &GNUNET_GETOPT_set_uint, &create_cfg_no},
97 {'t', "template", NULL, gettext_noop ("configuration template"),
98 GNUNET_YES, &GNUNET_GETOPT_set_string, &create_cfg_template},
63 GNUNET_GETOPT_OPTION_END 99 GNUNET_GETOPT_OPTION_END
64 }; 100 };
65 return (GNUNET_OK == 101 return (GNUNET_OK ==