GNUnet  0.11.x
Macros | Functions | Variables
gnunet-testing.c File Reference

tool to use testing functionality from cmd line More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_lib.h"
Include dependency graph for gnunet-testing.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "gnunet-testing", __VA_ARGS__)
 

Functions

static int create_unique_cfgs (const char *template, const unsigned int no)
 
static int create_hostkeys (const unsigned int no)
 
static void cleanup (void *cls)
 Cleanup called by signal handlers and when stdin is closed. More...
 
static void stdin_cb (void *cls)
 Called whenever we can read stdin non-blocking. More...
 
static void testing_main (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
 Main function called by the testing library. More...
 
static void run_no_scheduler (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be running without scheduler. More...
 
int main (int argc, char *const *argv)
 The main function. More...
 

Variables

static int ret
 Final status code. More...
 
static char * create_hostkey
 Filename of the hostkey file we should write, null if we should not write a hostkey file. More...
 
static int create_cfg
 Non-zero if we should create config files. More...
 
static unsigned int create_no
 Number of config files to create. More...
 
static char * create_cfg_template
 Filename of the config template to be written. More...
 
static char * run_service_name
 Service we are supposed to run. More...
 
static struct GNUNET_DISK_FileHandlefh
 File handle to STDIN, for reading restart/quit commands. More...
 
static char * tmpfilename
 Temporary filename, used with '-r' to write the configuration to. More...
 
static struct GNUNET_SCHEDULER_Tasktid
 Task identifier of the task that waits for stdin. More...
 
static struct GNUNET_TESTING_Peermy_peer
 Peer started for '-r'. More...
 

Detailed Description

tool to use testing functionality from cmd line

Author
Christian Grothoff

Definition in file gnunet-testing.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "gnunet-testing", __VA_ARGS__)

Definition at line 31 of file gnunet-testing.c.

Referenced by stdin_cb().

Function Documentation

◆ create_unique_cfgs()

static int create_unique_cfgs ( const char *  template,
const unsigned int  no 
)
static

Definition at line 87 of file gnunet-testing.c.

References create_cfg_template, GNUNET_asprintf(), GNUNET_CONFIGURATION_create(), GNUNET_CONFIGURATION_destroy(), GNUNET_CONFIGURATION_dup(), GNUNET_CONFIGURATION_load(), GNUNET_CONFIGURATION_write(), GNUNET_DISK_file_test(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_NO, GNUNET_OK, GNUNET_TESTING_configuration_create(), GNUNET_TESTING_system_create(), GNUNET_TESTING_system_destroy(), and GNUNET_YES.

Referenced by run_no_scheduler().

88 {
89  struct GNUNET_TESTING_System *system;
90  int fail;
91  unsigned int cur;
92  char *cur_file;
93  struct GNUNET_CONFIGURATION_Handle *cfg_new;
94  struct GNUNET_CONFIGURATION_Handle *cfg_tmpl;
95 
96  if (GNUNET_NO == GNUNET_DISK_file_test (template))
97  {
99  "Configuration template `%s': file not found\n",
101  return 1;
102  }
103  cfg_tmpl = GNUNET_CONFIGURATION_create ();
104 
105  /* load template */
106  if ((create_cfg_template != NULL) &&
108  {
110  "Could not load template `%s'\n",
112  GNUNET_CONFIGURATION_destroy (cfg_tmpl);
113 
114  return 1;
115  }
116  /* load defaults */
117  if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg_tmpl, NULL))
118  {
120  "Could not load template `%s'\n",
122  GNUNET_CONFIGURATION_destroy (cfg_tmpl);
123  return 1;
124  }
125 
126  fail = GNUNET_NO;
127  system =
128  GNUNET_TESTING_system_create ("testing", NULL /* controller */, NULL, NULL);
129  for (cur = 0; cur < no; cur++)
130  {
132  "Creating configuration no. %u \n",
133  cur);
134  if (create_cfg_template != NULL)
135  GNUNET_asprintf (&cur_file, "%04u-%s", cur, create_cfg_template);
136  else
137  GNUNET_asprintf (&cur_file, "%04u%s", cur, ".conf");
138 
139  cfg_new = GNUNET_CONFIGURATION_dup (cfg_tmpl);
140  if (GNUNET_OK != GNUNET_TESTING_configuration_create (system, cfg_new))
141  {
143  "Could not create another configuration\n");
145  fail = GNUNET_YES;
146  break;
147  }
149  "Writing configuration no. %u to file `%s' \n",
150  cur,
151  cur_file);
152  if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg_new, cur_file))
153  {
155  "Failed to write configuration no. %u \n",
156  cur);
157  fail = GNUNET_YES;
158  }
160  GNUNET_free (cur_file);
161  if (GNUNET_YES == fail)
162  break;
163  }
164  GNUNET_CONFIGURATION_destroy (cfg_tmpl);
166  if (GNUNET_YES == fail)
167  return 1;
168  return 0;
169 }
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:544
int GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_create(void)
Create a new configuration object.
int GNUNET_TESTING_configuration_create(struct GNUNET_TESTING_System *system, struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new configuration using the given configuration as a template; ports and paths will be modif...
Definition: testing.c:1145
int GNUNET_CONFIGURATION_load(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Load configuration.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char * create_cfg_template
Filename of the config template to be written.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
Definition: testing.c:453
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:534
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:97
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
configuration data
Definition: configuration.c:85
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_hostkeys()

static int create_hostkeys ( const unsigned int  no)
static

Definition at line 173 of file gnunet-testing.c.

References _, create_hostkey, create_no, GNUNET_DISK_FileHandle::fd, GNUNET_assert, GNUNET_DISK_directory_create_for_file(), GNUNET_DISK_file_close(), GNUNET_DISK_file_open(), GNUNET_DISK_file_write(), GNUNET_DISK_OPEN_CREATE, GNUNET_DISK_OPEN_READWRITE, GNUNET_DISK_PERM_USER_READ, GNUNET_DISK_PERM_USER_WRITE, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log_from, GNUNET_OK, GNUNET_TESTING_hostkey_get(), GNUNET_TESTING_system_create(), GNUNET_TESTING_system_destroy(), GNUNET_YES, pk, and ret.

Referenced by run_no_scheduler().

174 {
175  struct GNUNET_TESTING_System *system;
176  struct GNUNET_PeerIdentity id;
177  struct GNUNET_DISK_FileHandle *fd;
179 
180  system = GNUNET_TESTING_system_create ("testing", NULL, NULL, NULL);
181  pk = GNUNET_TESTING_hostkey_get (system, create_no, &id);
182  if (NULL == pk)
183  {
184  fprintf (stderr,
185  _ ("Could not extract hostkey %u (offset too large?)\n"),
186  create_no);
188  return 1;
189  }
191  fd =
196  GNUNET_assert (fd != NULL);
198  pk,
199  sizeof(struct GNUNET_CRYPTO_EddsaPrivateKey));
202  "transport-testing",
203  "Wrote hostkey to file: `%s'\n",
205  GNUNET_free (pk);
207  return 0;
208 }
Create file if it doesn&#39;t exist.
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_TESTING_hostkey_get(const struct GNUNET_TESTING_System *system, uint32_t key_number, struct GNUNET_PeerIdentity *id)
Testing includes a number of pre-created hostkeys for faster peer startup.
Definition: testing.c:710
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:684
static struct GNUNET_IDENTITY_Handle * id
Handle to identity service.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static char * create_hostkey
Filename of the hostkey file we should write, null if we should not write a hostkey file...
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
Definition: disk.c:820
static unsigned int create_no
Number of config files to create.
struct GNUNET_TESTING_System * GNUNET_TESTING_system_create(const char *testdir, const char *trusted_ip, const char *hostname, const struct GNUNET_TESTING_SharedService *shared_services)
Create a system handle.
Definition: testing.c:453
void GNUNET_TESTING_system_destroy(struct GNUNET_TESTING_System *system, int remove_paths)
Free system resources.
Definition: testing.c:534
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:97
Private ECC key encoded for transmission.
The identity of the host (wraps the signing key of the peer).
Open the file for both reading and writing.
static int ret
Final status code.
#define GNUNET_YES
Definition: gnunet_common.h:77
int fd
File handle on Unix-like systems.
#define GNUNET_log_from(kind, comp,...)
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
Definition: disk.c:1268
Handle used to access files (and pipes).
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

static void cleanup ( void *  cls)
static

Cleanup called by signal handlers and when stdin is closed.

Removes the temporary file.

Parameters
clsunused

Definition at line 218 of file gnunet-testing.c.

References GNUNET_DISK_file_close(), GNUNET_ERROR_TYPE_WARNING, GNUNET_log_strerror_file, GNUNET_SCHEDULER_cancel(), and tmpfilename.

Referenced by testing_main().

219 {
220  if (NULL != tmpfilename)
221  {
222  if (0 != unlink (tmpfilename))
224  "unlink",
225  tmpfilename);
226  }
227  if (NULL != tid)
228  {
230  tid = NULL;
231  }
232  if (NULL != fh)
233  {
235  fh = NULL;
236  }
237 }
int GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
Definition: disk.c:1345
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static struct GNUNET_SCHEDULER_Task * tid
Task identifier of the task that waits for stdin.
static char * tmpfilename
Temporary filename, used with &#39;-r&#39; to write the configuration to.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stdin_cb()

static void stdin_cb ( void *  cls)
static

Called whenever we can read stdin non-blocking.

Parameters
clsunused

Definition at line 246 of file gnunet-testing.c.

References _, GNUNET_ERROR_TYPE_ERROR, GNUNET_OK, GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_shutdown(), GNUNET_TESTING_peer_start(), GNUNET_TESTING_peer_stop(), GNUNET_TIME_UNIT_FOREVER_REL, and LOG.

Referenced by testing_main().

247 {
248  int c;
249 
250  tid = NULL;
251  c = getchar ();
252  switch (c)
253  {
254  case EOF:
255  case 'q':
257  return;
258 
259  case 'r':
261  LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to stop the peer\n");
263  LOG (GNUNET_ERROR_TYPE_ERROR, "Failed to start the peer\n");
264  printf ("restarted\n");
265  fflush (stdout);
266  break;
267 
268  case '\n':
269  case '\r':
270  /* ignore whitespace */
271  break;
272 
273  default:
274  fprintf (stderr,
275  _ ("Unknown command, use 'q' to quit or 'r' to restart peer\n"));
276  break;
277  }
279  fh,
280  &stdin_cb,
281  NULL);
282 }
static void stdin_cb(void *cls)
Called whenever we can read stdin non-blocking.
int GNUNET_TESTING_peer_start(struct GNUNET_TESTING_Peer *peer)
Start the peer.
Definition: testing.c:1359
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1636
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1464
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static struct GNUNET_SCHEDULER_Task * tid
Task identifier of the task that waits for stdin.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
#define LOG(kind,...)
static struct GNUNET_TESTING_Peer * my_peer
Peer started for &#39;-r&#39;.
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ testing_main()

static void testing_main ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_TESTING_Peer peer 
)
static

Main function called by the testing library.

Executed inside a running scheduler.

Parameters
clsunused
cfgconfiguration of the peer that was started
peerhandle to the peer

Definition at line 294 of file gnunet-testing.c.

References cleanup(), GNUNET_break, GNUNET_CONFIGURATION_write(), GNUNET_DISK_get_handle_from_native(), GNUNET_DISK_mktemp(), GNUNET_SCHEDULER_add_read_file(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, GNUNET_TIME_UNIT_FOREVER_REL, peer, stdin_cb(), and tmpfilename.

Referenced by run_no_scheduler().

297 {
298  my_peer = peer;
299  if (NULL == (tmpfilename = GNUNET_DISK_mktemp ("gnunet-testing")))
300  {
301  GNUNET_break (0);
303  return;
304  }
305  if (GNUNET_SYSERR ==
307  tmpfilename))
308  {
309  GNUNET_break (0);
310  return;
311  }
312  printf ("ok\n%s\n", tmpfilename);
313  fflush (stdout);
317  fh,
318  &stdin_cb,
319  NULL);
320 }
int GNUNET_CONFIGURATION_write(struct GNUNET_CONFIGURATION_Handle *cfg, const char *filename)
Write configuration file.
static void stdin_cb(void *cls)
Called whenever we can read stdin non-blocking.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1300
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_read_file(struct GNUNET_TIME_Relative delay, const struct GNUNET_DISK_FileHandle *rfd, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay or when the specified file descriptor is ready f...
Definition: scheduler.c:1636
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:526
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
char * GNUNET_DISK_mktemp(const char *t)
Create an (empty) temporary file on disk.
Definition: disk.c:468
static struct GNUNET_SCHEDULER_Task * tid
Task identifier of the task that waits for stdin.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static struct GNUNET_TESTING_Peer * my_peer
Peer started for &#39;-r&#39;.
configuration data
Definition: configuration.c:85
static char * tmpfilename
Temporary filename, used with &#39;-r&#39; to write the configuration to.
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_native(FILE *fd)
Get a handle from a native FD.
Definition: disk.c:1397
static void cleanup(void *cls)
Cleanup called by signal handlers and when stdin is closed.
static struct GNUNET_DISK_FileHandle * fh
File handle to STDIN, for reading restart/quit commands.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run_no_scheduler()

static void run_no_scheduler ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be running without scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 332 of file gnunet-testing.c.

References create_cfg, create_cfg_template, create_hostkey, create_hostkeys(), create_no, create_unique_cfgs(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free_non_null, GNUNET_log, GNUNET_TESTING_service_run(), GNUNET_YES, ret, run_service_name, and testing_main().

Referenced by main().

336 {
337  if (NULL != run_service_name)
338  {
339  ret = GNUNET_TESTING_service_run ("gnunet_service_test",
341  cfgfile,
342  &testing_main,
343  NULL);
344  return;
345  }
346 
347  if (GNUNET_YES == create_cfg)
348  {
349  if (create_no > 0)
350  {
352  "Creating %u configuration files based on template `%s'\n",
353  create_no,
356  }
357  else
358  {
359  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Missing arguments! \n");
360  ret = 1;
361  }
362  }
363  if (NULL != create_hostkey)
364  {
365  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Extracting hostkey %u\n", create_no);
367  }
369 }
static void testing_main(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TESTING_Peer *peer)
Main function called by the testing library.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
static char * create_hostkey
Filename of the hostkey file we should write, null if we should not write a hostkey file...
int GNUNET_TESTING_service_run(const char *testdir, const char *service_name, const char *cfgfilename, GNUNET_TESTING_TestMain tm, void *tm_cls)
Start a single service (no ARM, except of course if the given service name is &#39;arm&#39;) and run a test u...
Definition: testing.c:1670
static char * create_cfg_template
Filename of the config template to be written.
static unsigned int create_no
Number of config files to create.
static char * run_service_name
Service we are supposed to run.
static int create_unique_cfgs(const char *template, const unsigned int no)
static int create_hostkeys(const unsigned int no)
#define GNUNET_log(kind,...)
static int ret
Final status code.
#define GNUNET_YES
Definition: gnunet_common.h:77
static int create_cfg
Non-zero if we should create config files.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

The main function.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 380 of file gnunet-testing.c.

References create_cfg, create_cfg_template, create_hostkey, create_no, gettext_noop, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_OK, GNUNET_PROGRAM_run2(), GNUNET_STRINGS_get_utf8_args(), GNUNET_YES, ret, run_no_scheduler(), and run_service_name.

381 {
384  "cfg",
385  gettext_noop (
386  "create unique configuration files"),
387  &create_cfg),
389  'k',
390  "key",
391  "FILENAME",
392  gettext_noop ("extract hostkey file from pre-computed hostkey list"),
393  &create_hostkey),
394 
396  'n',
397  "number",
398  "NUMBER",
399  gettext_noop (
400  "number of unique configuration files to create, or number of the hostkey to extract"),
401  &create_no),
402 
403 
405  "template",
406  "FILENAME",
407  gettext_noop ("configuration template"),
409 
411  'r',
412  "run",
413  "SERVICE",
414  gettext_noop (
415  "run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"),
418 
419  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
420  return 2;
421 
422  /* Run without scheduler, because we may want to call
423  * GNUNET_TESTING_service_run, which starts the scheduler on its own.
424  * Furthermore, the other functionality currently does not require the scheduler, too,
425  * but beware when extending gnunet-testing. */
426  ret =
427  (GNUNET_OK ==
428  GNUNET_PROGRAM_run2 (argc,
429  argv,
430  "gnunet-testing",
431  gettext_noop (
432  "Command line tool to access the testing library"),
433  options,
435  NULL,
436  GNUNET_YES))
437  ? ret
438  : 1;
439  GNUNET_free ((void *) argv);
440  return ret;
441 }
int GNUNET_PROGRAM_run2(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls, int run_without_scheduler)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:141
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1438
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Definition of a command line option.
static char * create_hostkey
Filename of the hostkey file we should write, null if we should not write a hostkey file...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
static char * create_cfg_template
Filename of the config template to be written.
static unsigned int create_no
Number of config files to create.
static char * run_service_name
Service we are supposed to run.
static void run_no_scheduler(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be running without scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
static int ret
Final status code.
#define GNUNET_YES
Definition: gnunet_common.h:77
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
static int create_cfg
Non-zero if we should create config files.
#define GNUNET_free(ptr)
Wrapper around free.
#define gettext_noop(String)
Definition: gettext.h:69
Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Final status code.

Definition at line 37 of file gnunet-testing.c.

Referenced by create_hostkeys(), main(), and run_no_scheduler().

◆ create_hostkey

char* create_hostkey
static

Filename of the hostkey file we should write, null if we should not write a hostkey file.

Definition at line 43 of file gnunet-testing.c.

Referenced by create_hostkeys(), main(), and run_no_scheduler().

◆ create_cfg

int create_cfg
static

Non-zero if we should create config files.

Definition at line 48 of file gnunet-testing.c.

Referenced by main(), and run_no_scheduler().

◆ create_no

unsigned int create_no
static

Number of config files to create.

Definition at line 53 of file gnunet-testing.c.

Referenced by create_hostkeys(), main(), and run_no_scheduler().

◆ create_cfg_template

char* create_cfg_template
static

Filename of the config template to be written.

Definition at line 58 of file gnunet-testing.c.

Referenced by create_unique_cfgs(), main(), and run_no_scheduler().

◆ run_service_name

char* run_service_name
static

Service we are supposed to run.

Definition at line 63 of file gnunet-testing.c.

Referenced by main(), and run_no_scheduler().

◆ fh

struct GNUNET_DISK_FileHandle* fh
static

File handle to STDIN, for reading restart/quit commands.

Definition at line 68 of file gnunet-testing.c.

◆ tmpfilename

char* tmpfilename
static

Temporary filename, used with '-r' to write the configuration to.

Definition at line 73 of file gnunet-testing.c.

Referenced by cleanup(), and testing_main().

◆ tid

struct GNUNET_SCHEDULER_Task* tid
static

Task identifier of the task that waits for stdin.

Definition at line 78 of file gnunet-testing.c.

Referenced by write_benchmark_data().

◆ my_peer

struct GNUNET_TESTING_Peer* my_peer
static

Peer started for '-r'.

Definition at line 83 of file gnunet-testing.c.