GNUnet  0.11.x
Data Structures | Functions
testing_api_cmd_system_create.c File Reference

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

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_lib.h"
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, const struct GNUNET_TESTING_Command *cmd, 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...
 
int GNUNET_TESTING_get_trait_test_system (const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_System **test_system)
 Function to get the trait with struct GNUNET_TESTING_System. More...
 
static void system_create_cleanup (void *cls, const struct GNUNET_TESTING_Command *cmd)
 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,
const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_Interpreter is 
)
static

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

Definition at line 48 of file testing_api_cmd_system_create.c.

51 {
52  struct TestSystemState *tss = cls;
53 
55  "system create\n");
56 
58  NULL,
59  NULL,
60  NULL);
62  "system created\n");
63 }
#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:448
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 71 of file testing_api_cmd_system_create.c.

75 {
76  struct TestSystemState *tss = cls;
78 
79  struct GNUNET_TESTING_Trait traits[] = {
80  {
81  .index = 0,
82  .trait_name = "test_system",
83  .ptr = (const void *) test_system,
84  },
86  };
87 
88  return GNUNET_TESTING_get_trait (traits,
89  ret,
90  trait,
91  index);
92 }
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_trait_end(void)
"end" trait.
int 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:93
unsigned int index
Index number associated with the trait.

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

Here is the call graph for this function:

◆ GNUNET_TESTING_get_trait_test_system()

int GNUNET_TESTING_get_trait_test_system ( const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_System **  test_system 
)

Function to get the trait with struct GNUNET_TESTING_System.

Parameters
[out]test_systemThe struct GNUNET_TESTING_System.
Returns
GNUNET_OK if no error occurred, GNUNET_SYSERR otherwise.

Definition at line 102 of file testing_api_cmd_system_create.c.

105 {
106  return cmd->traits (cmd->cls,
107  (const void **) test_system,
108  "test_system",
109  (unsigned int) 0);
110 }
int(* traits)(void *cls, const void **ret, const char *trait, unsigned int index)
Extract information from a command that is useful for other commands.
void * cls
Closure for all commands with command-specific context information.

References GNUNET_TESTING_Command::cls, test_system, and GNUNET_TESTING_Command::traits.

Referenced by connect_peers_run(), start_peer_run(), and system_destroy_run().

Here is the caller graph for this function:

◆ system_create_cleanup()

static void system_create_cleanup ( void *  cls,
const struct GNUNET_TESTING_Command cmd 
)
static

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

Definition at line 118 of file testing_api_cmd_system_create.c.

120 {
121  struct TestSystemState *tss = cls;
122 
123  GNUNET_free (tss);
124 }
#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.

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

Definition at line 118 of file testing_api_cmd_system_create.c.

137 {
138  struct TestSystemState *tss;
139 
140  tss = GNUNET_new (struct TestSystemState);
141  tss->testdir = testdir;
142 
143  struct GNUNET_TESTING_Command cmd = {
144  .cls = tss,
145  .label = label,
146  .run = &system_create_run,
147  .cleanup = &system_create_cleanup,
148  .traits = &system_create_traits
149  };
150 
151  return cmd;
152 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
A command to be run by the interpreter.
const char * label
Label for the command.
static void system_create_run(void *cls, const struct GNUNET_TESTING_Command *cmd, 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, const struct GNUNET_TESTING_Command *cmd)
The cleanup function of this cmd frees resources the cmd allocated.