GNUnet  0.10.x
Macros | Functions | Variables
gnunet-testbed-profiler.c File Reference

Profiling driver for the testbed. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
#include "testbed_api_hosts.h"
Include dependency graph for gnunet-testbed-profiler.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log(kind, __VA_ARGS__)
 Generic loggins shorthand. More...
 

Functions

static void do_shutdown (void *cls)
 Shutdown nicely. More...
 
static void do_abort (void *cls)
 abort task to run on test timed out More...
 
static void print_overlay_links_summary ()
 Function to print summary about how many overlay links we have made and how many failed. More...
 
static void controller_event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
 Controller event callback. More...
 
static void test_run (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
 Signature of a main function for a testcase. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 Main function. More...
 

Variables

struct GNUNET_CONFIGURATION_Handlecfg
 Handle to global configuration. More...
 
struct GNUNET_TESTBED_Operationtopology_op
 Peer linking - topology operation. More...
 
static char * hosts_file
 Name of the file with the hosts to run the test over (configuration option). More...
 
static struct GNUNET_SCHEDULER_Taskabort_task
 Abort task identifier. More...
 
uint64_t event_mask
 Global event mask for all testbed events. More...
 
static unsigned int num_peers
 Number of peers to be started by the profiler. More...
 
static unsigned int num_cont_fails
 Number of timeout failures to tolerate. More...
 
static unsigned int cont_fails
 Continuous failures during overlay connect operations. More...
 
static unsigned int established_links
 Links which are successfully established. More...
 
static unsigned int failed_links
 Links which are not successfully established. More...
 
static int result
 Global testing status. More...
 
static int noninteractive
 Are we running non interactively. More...
 

Detailed Description

Profiling driver for the testbed.

Author
Sree Harsha Totakura sreeh.nosp@m.arsh.nosp@m.a@tot.nosp@m.akur.nosp@m.a.in

Definition in file gnunet-testbed-profiler.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log(kind, __VA_ARGS__)

Generic loggins shorthand.

Definition at line 35 of file gnunet-testbed-profiler.c.

Referenced by do_abort(), and run().

Function Documentation

◆ do_shutdown()

static void do_shutdown ( void *  cls)
static

Shutdown nicely.

Parameters
clsNULL

Definition at line 107 of file gnunet-testbed-profiler.c.

References GNUNET_CONFIGURATION_destroy(), and GNUNET_SCHEDULER_cancel().

Referenced by test_run().

108 {
109  if (NULL != abort_task)
110  {
112  abort_task = NULL;
113  }
114  if (NULL != cfg)
115  {
117  cfg = NULL;
118  }
119 }
static struct GNUNET_SCHEDULER_Task * abort_task
Abort task identifier.
void GNUNET_CONFIGURATION_destroy(struct GNUNET_CONFIGURATION_Handle *cfg)
Destroy configuration object.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to global configuration.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_abort()

static void do_abort ( void *  cls)
static

abort task to run on test timed out

Parameters
clsNULL

Definition at line 128 of file gnunet-testbed-profiler.c.

References GNUNET_ERROR_TYPE_WARNING, GNUNET_SCHEDULER_shutdown(), GNUNET_SYSERR, LOG, and result.

Referenced by run().

129 {
130  abort_task = NULL;
132  "Aborting\n");
135 }
#define LOG(kind,...)
Generic loggins shorthand.
static struct GNUNET_SCHEDULER_Task * abort_task
Abort task identifier.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
static int result
Global testing status.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_overlay_links_summary()

static void print_overlay_links_summary ( )
static

Function to print summary about how many overlay links we have made and how many failed.

Definition at line 143 of file gnunet-testbed-profiler.c.

References established_links, failed_links, and GNUNET_YES.

Referenced by controller_event_cb(), and test_run().

144 {
145  static int printed_already;
146 
147  if (GNUNET_YES == printed_already)
148  return;
149  printed_already = GNUNET_YES;
150  printf("%u links succeeded\n", established_links);
151  printf("%u links failed due to timeouts\n", failed_links);
152 }
static unsigned int failed_links
Links which are not successfully established.
static unsigned int established_links
Links which are successfully established.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the caller graph for this function:

◆ controller_event_cb()

static void controller_event_cb ( void *  cls,
const struct GNUNET_TESTBED_EventInformation event 
)
static

Controller event callback.

Parameters
clsNULL
eventthe controller event

Definition at line 162 of file gnunet-testbed-profiler.c.

References cont_fails, GNUNET_TESTBED_EventInformation::details, established_links, failed_links, GNUNET_break, GNUNET_SCHEDULER_shutdown(), GNUNET_TESTBED_ET_CONNECT, GNUNET_TESTBED_ET_OPERATION_FINISHED, num_cont_fails, GNUNET_TESTBED_EventInformation::operation_finished, print_overlay_links_summary(), and GNUNET_TESTBED_EventInformation::type.

Referenced by run().

164 {
165  switch (event->type)
166  {
168  /* Control reaches here when a peer linking operation fails */
169  if (NULL != event->details.operation_finished.emsg)
170  {
171  printf("F");
172  fflush(stdout);
173  failed_links++;
174  if (++cont_fails > num_cont_fails)
175  {
176  printf("\nAborting due to very high failure rate\n");
179  return;
180  }
181  }
182  break;
183 
185  {
186  if (0 != cont_fails)
187  cont_fails--;
188  if (0 == established_links)
189  printf("Establishing links. Please wait\n");
190  printf(".");
191  fflush(stdout);
193  }
194  break;
195 
196  default:
197  GNUNET_break(0);
198  }
199 }
static unsigned int failed_links
Links which are not successfully established.
enum GNUNET_TESTBED_EventType type
Type of the event.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
static void print_overlay_links_summary()
Function to print summary about how many overlay links we have made and how many failed.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static unsigned int established_links
Links which are successfully established.
A requested testbed operation has been completed.
struct GNUNET_TESTBED_EventInformation::@58::@63 operation_finished
Details about an operation finished event.
static unsigned int cont_fails
Continuous failures during overlay connect operations.
union GNUNET_TESTBED_EventInformation::@58 details
Details about the event.
A connection between two peers was established.
static unsigned int num_cont_fails
Number of timeout failures to tolerate.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_run()

static void test_run ( void *  cls,
struct GNUNET_TESTBED_RunHandle h,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  peers,
unsigned int  links_succeeded,
unsigned int  links_failed 
)
static

Signature of a main function for a testcase.

Parameters
clsclosure
hthe run handle
num_peersnumber of peers in 'peers'
peershandle to peers run in the testbed
links_succeededthe number of overlay link connection attempts that succeeded
links_failedthe number of overlay link

Definition at line 214 of file gnunet-testbed-profiler.c.

References do_shutdown(), GNUNET_OK, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_cancel(), GNUNET_SCHEDULER_shutdown(), noninteractive, print_overlay_links_summary(), and result.

Referenced by run().

219 {
220  result = GNUNET_OK;
221  fprintf(stdout, "\n");
224  if (noninteractive)
225  {
227  abort_task = NULL;
228  return;
229  }
230 #if (!ENABLE_SUPERMUC)
231  fprintf(stdout, "Testbed running, waiting for keystroke to shut down\n");
232  fflush(stdout);
233  (void)getc(stdin);
234 #endif
235  fprintf(stdout, "Shutting down. Please wait\n");
236  fflush(stdout);
238 }
static int noninteractive
Are we running non interactively.
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:1284
static struct GNUNET_SCHEDULER_Task * abort_task
Abort task identifier.
#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:517
static void print_overlay_links_summary()
Function to print summary about how many overlay links we have made and how many failed.
static int result
Global testing status.
static void do_shutdown(void *cls)
Shutdown nicely.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle config 
)
static

Main function that will be run by the scheduler.

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

Definition at line 250 of file gnunet-testbed-profiler.c.

References _, controller_event_cb(), do_abort(), event_mask, GNUNET_CONFIGURATION_dup(), GNUNET_ERROR_TYPE_ERROR, GNUNET_SCHEDULER_add_shutdown(), GNUNET_TESTBED_ET_CONNECT, GNUNET_TESTBED_ET_OPERATION_FINISHED, GNUNET_TESTBED_run(), hosts_file, LOG, num_peers, and test_run().

Referenced by main().

252 {
253  if (0 == num_peers)
254  {
255  LOG(GNUNET_ERROR_TYPE_ERROR, _("Exiting as the number of peers is %u\n"),
256  num_peers);
257  return;
258  }
259  cfg = GNUNET_CONFIGURATION_dup(config);
260  event_mask = 0;
264  &controller_event_cb, NULL,
265  &test_run, NULL);
266  abort_task =
268  NULL);
269 }
#define LOG(kind,...)
Generic loggins shorthand.
static void controller_event_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event)
Controller event callback.
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:1284
static struct GNUNET_SCHEDULER_Task * abort_task
Abort task identifier.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
A requested testbed operation has been completed.
static unsigned int num_peers
Number of peers to be started by the profiler.
static void do_abort(void *cls)
abort task to run on test timed out
void GNUNET_TESTBED_run(const char *host_filename, const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int num_peers, uint64_t event_mask, GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, GNUNET_TESTBED_TestMaster test_master, void *test_master_cls)
Convenience method for running a testbed with a single call.
uint64_t event_mask
Global event mask for all testbed events.
A connection between two peers was established.
struct GNUNET_CONFIGURATION_Handle * GNUNET_CONFIGURATION_dup(const struct GNUNET_CONFIGURATION_Handle *cfg)
Duplicate an existing configuration object.
struct GNUNET_CONFIGURATION_Handle * cfg
Handle to global configuration.
static void test_run(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
static char * hosts_file
Name of the file with the hosts to run the test over (configuration option).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

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

Main function.

Returns
0 on success

Definition at line 278 of file gnunet-testbed-profiler.c.

References gettext_noop, GNUNET_free, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_flag(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_OK, GNUNET_PROGRAM_run(), GNUNET_STRINGS_get_utf8_args(), GNUNET_SYSERR, hosts_file, noninteractive, num_cont_fails, num_peers, result, ret, and run().

279 {
282  "num-peers",
283  "COUNT",
284  gettext_noop("create COUNT number of peers"),
285  &num_peers),
287  "num-errors",
288  "COUNT",
289  gettext_noop("tolerate COUNT number of continious timeout failures"),
290  &num_cont_fails),
292  "non-interactive",
293  gettext_noop("run profiler in non-interactive mode where upon "
294  "testbed setup the profiler does not wait for a "
295  "keystroke but continues to run until a termination "
296  "signal is received"),
297  &noninteractive),
298 #if !ENABLE_SUPERMUC
300  "hosts",
301  "FILENAME",
302  gettext_noop("name of the file with the login information for the testbed"),
303  &hosts_file),
304 #endif
306  };
307  const char *binaryHelp = "gnunet-testbed-profiler [OPTIONS]";
308  int ret;
309 
310  unsetenv("XDG_DATA_HOME");
311  unsetenv("XDG_CONFIG_HOME");
312  if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args(argc, argv, &argc, &argv))
313  return 2;
315  ret =
316  GNUNET_PROGRAM_run(argc, argv, "gnunet-testbed-profiler", binaryHelp,
317  options, &run, NULL);
318  GNUNET_free((void *)argv);
319  if (GNUNET_OK != ret)
320  return ret;
321  if (GNUNET_OK != result)
322  return 1;
323  return 0;
324 }
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *config)
Main function that will be run by the scheduler.
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
static int noninteractive
Are we running non interactively.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
Definition: strings.c:1439
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Definition of a command line option.
static int ret
Final status code.
Definition: gnunet-arm.c:89
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 int result
Global testing status.
static unsigned int num_peers
Number of peers to be started by the profiler.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
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 char * hosts_file
Name of the file with the hosts to run the test over (configuration option).
static unsigned int num_cont_fails
Number of timeout failures to tolerate.
int GNUNET_PROGRAM_run(int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration, parse options).
Definition: program.c:367
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.
#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

◆ cfg

Handle to global configuration.

Handle to our configuration.

Definition at line 42 of file gnunet-testbed-profiler.c.

◆ topology_op

struct GNUNET_TESTBED_Operation* topology_op

Peer linking - topology operation.

Definition at line 47 of file gnunet-testbed-profiler.c.

◆ hosts_file

char* hosts_file
static

Name of the file with the hosts to run the test over (configuration option).

It will be NULL if ENABLE_LL is set

Definition at line 53 of file gnunet-testbed-profiler.c.

Referenced by main(), and run().

◆ abort_task

struct GNUNET_SCHEDULER_Task* abort_task
static

Abort task identifier.

Definition at line 58 of file gnunet-testbed-profiler.c.

◆ event_mask

uint64_t event_mask

Global event mask for all testbed events.

Definition at line 63 of file gnunet-testbed-profiler.c.

Referenced by controller_status_cb(), GNUNET_ATS_TEST_create_topology(), GNUNET_TESTBED_controller_connect(), GNUNET_TESTBED_run(), and run().

◆ num_peers

unsigned int num_peers
static

Number of peers to be started by the profiler.

Definition at line 68 of file gnunet-testbed-profiler.c.

Referenced by main(), and run().

◆ num_cont_fails

unsigned int num_cont_fails
static

Number of timeout failures to tolerate.

Definition at line 73 of file gnunet-testbed-profiler.c.

Referenced by controller_event_cb(), and main().

◆ cont_fails

unsigned int cont_fails
static

Continuous failures during overlay connect operations.

Definition at line 78 of file gnunet-testbed-profiler.c.

Referenced by controller_event_cb().

◆ established_links

unsigned int established_links
static

Links which are successfully established.

Definition at line 83 of file gnunet-testbed-profiler.c.

Referenced by controller_event_cb(), and print_overlay_links_summary().

◆ failed_links

unsigned int failed_links
static

Links which are not successfully established.

Definition at line 88 of file gnunet-testbed-profiler.c.

Referenced by controller_event_cb(), and print_overlay_links_summary().

◆ result

int result
static

Global testing status.

Definition at line 93 of file gnunet-testbed-profiler.c.

Referenced by do_abort(), main(), and test_run().

◆ noninteractive

int noninteractive
static

Are we running non interactively.

Definition at line 98 of file gnunet-testbed-profiler.c.

Referenced by main(), and test_run().