GNUnet  0.17.5
Macros | Functions
testing_api_cmd_local_test_prepared.c File Reference

cmd to block the interpreter loop until all peers started. More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
#include "gnunet_testing_netjail_lib.h"
#include "testing_cmds.h"
Include dependency graph for testing_api_cmd_local_test_prepared.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log (kind, __VA_ARGS__)
 Generic logging shortcut. More...
 

Functions

enum GNUNET_GenericReturnValue local_test_prepared_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 This function prepares an array with traits. More...
 
static void local_test_prepared_cleanup (void *cls)
 The cleanup function of this cmd frees resources the cmd allocated. More...
 
static void local_test_prepared_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_prepared (const char *label, TESTING_CMD_HELPER_write_cb write_message)
 Create command. More...
 

Detailed Description

cmd to block the interpreter loop until all peers started.

Author
t3sserakt

Definition in file testing_api_cmd_local_test_prepared.c.

Macro Definition Documentation

◆ LOG

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

Generic logging shortcut.

Definition at line 35 of file testing_api_cmd_local_test_prepared.c.

Function Documentation

◆ local_test_prepared_traits()

enum GNUNET_GenericReturnValue local_test_prepared_traits ( void *  cls,
const void **  ret,
const char *  trait,
unsigned int  index 
)

This function prepares an array with traits.

Definition at line 1 of file testing_api_cmd_local_test_prepared.c.

47 {
48  struct LocalPreparedState *lfs = cls;
49  struct GNUNET_TESTING_Trait traits[] = {
52  };
53  return GNUNET_TESTING_get_trait (traits,
54  ret,
55  trait,
56  index);
57 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_local_prepared_state(const struct LocalPreparedState *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.
unsigned int index
Index number associated with the trait.
Struct to hold information for callbacks.

◆ local_test_prepared_cleanup()

static void local_test_prepared_cleanup ( void *  cls)
static

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

Definition at line 65 of file testing_api_cmd_local_test_prepared.c.

66 {
67  struct LocalPreparedState *lfs = cls;
68 
69  GNUNET_free (lfs);
70 }
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free.

◆ local_test_prepared_run()

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

This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop.

Definition at line 78 of file testing_api_cmd_local_test_prepared.c.

80 {
81  struct LocalPreparedState *lfs = cls;
82 
83  struct GNUNET_CMDS_LOCAL_TEST_PREPARED *reply;
84  size_t msg_length;
85 
86  msg_length = sizeof(struct GNUNET_CMDS_LOCAL_TEST_PREPARED);
88  reply->header.type = htons (
90  reply->header.size = htons ((uint16_t) msg_length);
91  lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
92 }
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED.
Definition: testing_cmds.h:95
Header for all communications.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
TESTING_CMD_HELPER_write_cb write_message
Callback to write messages to the master loop.

References GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TEST_PREPARED, GNUNET_new, GNUNET_CMDS_LOCAL_TEST_PREPARED::header, GNUNET_MessageHeader::size, GNUNET_MessageHeader::type, and LocalPreparedState::write_message.

◆ GNUNET_TESTING_cmd_local_test_prepared()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_local_test_prepared ( const char *  label,
TESTING_CMD_HELPER_write_cb  write_message 
)

Create command.

Parameters
labelname for command.
write_messageCallback to write messages to the master loop.
all_local_tests_preparedFlag which will be set from outside.
Returns
command.

Definition at line 78 of file testing_api_cmd_local_test_prepared.c.

107 {
108  struct LocalPreparedState *lfs;
109 
110  lfs = GNUNET_new (struct LocalPreparedState);
112 
113  struct GNUNET_TESTING_Command cmd = {
114  .cls = lfs,
115  .label = label,
116  .run = &local_test_prepared_run,
117  .ac = &lfs->ac,
118  .cleanup = &local_test_prepared_cleanup,
119  .traits = &local_test_prepared_traits
120  };
121 
122  return cmd;
123 }
static int write_message(uint16_t message_type, const char *data, size_t data_length)
Write message to the master process.
A command to be run by the interpreter.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
static void local_test_prepared_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_TESTS_PREPARED message to the master loop...
enum GNUNET_GenericReturnValue local_test_prepared_traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
static void local_test_prepared_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.