2 This file is part of GNUnet.
3 (C) 2001, 2002, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file template/gnunet-testing.c
23 * @brief tool to use testing functionality from cmd line
24 * @author Christian Grothoff
27 #include "gnunet_getopt_lib.h"
28 #include "gnunet_program_lib.h"
29 #include "gnunet_testing_lib.h"
36 unsigned int create_cfg;
40 static char * create_cfg_template;
44 create_unique_cfgs (const char * template, const unsigned int no)
46 if (GNUNET_NO == GNUNET_DISK_file_test(template))
48 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Configuration template `%s': file not found\n", create_cfg_template);
55 * Main function that will be run by the scheduler.
58 * @param args remaining command-line arguments
59 * @param cfgfile name of the configuration file used (for saving, can be NULL!)
60 * @param cfg configuration
63 run (void *cls, char *const *args, const char *cfgfile,
64 const struct GNUNET_CONFIGURATION_Handle *cfg)
67 if ((create_cfg == GNUNET_YES) &&
68 (create_cfg_no > 0) &&
69 (create_cfg_template != NULL))
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);
78 GNUNET_free_non_null (create_cfg_template);
85 * @param argc number of arguments from the command line
86 * @param argv command line arguments
87 * @return 0 ok, 1 on error
90 main (int argc, char *const *argv)
92 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
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},
99 GNUNET_GETOPT_OPTION_END
102 GNUNET_PROGRAM_run (argc, argv, "gnunet-testing",
103 gettext_noop ("Command line tool to access the testing library"), options, &run,
107 /* end of gnunet-testing.c */