GNUnet 0.21.1
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.

Referenced by GNUNET_TESTING_cmd_system_create().

Here is the call graph for this function:
Here is the caller 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;
78 struct GNUNET_TESTING_System *test_system = tss->test_system;
79
80 struct GNUNET_TESTING_Trait traits[] = {
81 GNUNET_TESTING_make_trait_test_system ((const void *) test_system),
83 };
84
85 return GNUNET_TESTING_get_trait (traits,
86 ret,
87 trait,
88 index);
89}
static int ret
Final status code.
Definition: gnunet-arm.c:94
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Obtain value of a trait from a command.
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_test_system(const struct GNUNET_TESTING_System *value)
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, and TestSystemState::test_system.

Referenced by GNUNET_TESTING_cmd_system_create().

Here is the call graph for this function:
Here is the caller 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.

Referenced by GNUNET_TESTING_cmd_system_create().

Here is the caller graph for this function:

◆ 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 113 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
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.

References GNUNET_new, GNUNET_TESTING_command_new(), system_create_cleanup(), system_create_run(), system_create_traits(), and TestSystemState::testdir.

Here is the call graph for this function: