GNUnet  0.20.0
testing_api_cmd_system_create.c File Reference

cmd to create a testing system handle. More...

Include dependency graph for testing_api_cmd_system_create.c:

Go to the source code of this file.

Data Structures

struct  TestSystemState
 Struct to hold information for callbacks. More...
 

Functions

static void system_create_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 The run method of this cmd will setup a test environment for a node. More...
 
static int system_create_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 This function prepares an array with traits. More...
 
static void system_create_cleanup (void *cls)
 The cleanup function of this cmd frees resources the cmd allocated. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_create (const char *label, const char *testdir)
 Create command. More...
 

Detailed Description

cmd to create a testing system handle.

Author
t3sserakt

Definition in file testing_api_cmd_system_create.c.

Function Documentation

◆ system_create_run()

static void system_create_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

The run method of this cmd will setup a test environment for a node.

Definition at line 50 of file testing_api_cmd_system_create.c.

52 {
53  struct TestSystemState *tss = cls;
54 
56  "system create\n");
57 
59  NULL,
60  NULL,
61  NULL);
63  "system created\n");
64 }
#define GNUNET_log(kind,...)
@ GNUNET_ERROR_TYPE_DEBUG
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:477
Struct to hold information for callbacks.
struct GNUNET_TESTING_System * test_system

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_TESTING_system_create(), TestSystemState::test_system, and TestSystemState::testdir.

Here is the call graph for this function:

◆ system_create_traits()

static int system_create_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)
static

This function prepares an array with traits.

Definition at line 72 of file testing_api_cmd_system_create.c.

76 {
77  struct TestSystemState *tss = cls;
79 
80  struct GNUNET_TESTING_Trait traits[] = {
83  };
84 
85  return GNUNET_TESTING_get_trait (traits,
86  ret,
87  trait,
88  index);
89 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static struct GNUNET_TESTING_System * test_system
Handle to the testing system.
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_test_system(const struct GNUNET_TESTING_System *value)
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" trait.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Extract a trait.
Handle for a system on which GNUnet peers are executed; a system is used for reserving unique paths a...
Definition: testing.c:122
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.

References GNUNET_TESTING_get_trait(), GNUNET_TESTING_make_trait_test_system(), GNUNET_TESTING_trait_end(), GNUNET_TESTING_Trait::index, ret, test_system, and TestSystemState::test_system.

Here is the call graph for this function:

◆ system_create_cleanup()

static void system_create_cleanup ( void *  cls)
static

The cleanup function of this cmd frees resources the cmd allocated.

Definition at line 97 of file testing_api_cmd_system_create.c.

98 {
99  struct TestSystemState *tss = cls;
100 
101  GNUNET_free (tss);
102 }
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free.

◆ GNUNET_TESTING_cmd_system_create()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_system_create ( const char *  label,
const char *  testdir 
)

Create command.

This command is setting up a test environment for a peer to start.

Parameters
labelname for command.
labelname for the test environment directory.
Returns
command.

Definition at line 97 of file testing_api_cmd_system_create.c.

115 {
116  struct TestSystemState *tss;
117 
118  tss = GNUNET_new (struct TestSystemState);
119  tss->testdir = testdir;
120 
121  return GNUNET_TESTING_command_new (tss, label, &system_create_run,
123  &system_create_traits, NULL);
124 }
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void system_create_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will setup a test environment for a node.
static int system_create_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static void system_create_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.