GNUnet  0.11.x
Data Structures | Functions
testing_api_cmd_netjail_stop_testsystem_v2.c File Reference
#include "platform.h"
#include "gnunet_testing_ng_lib.h"
#include "testing_cmds.h"
Include dependency graph for testing_api_cmd_netjail_stop_testsystem_v2.c:

Go to the source code of this file.

Data Structures

struct  StopHelperState
 Struct to store information handed over to callbacks. More...
 

Functions

static void stop_testing_system_cleanup (void *cls, const struct GNUNET_TESTING_Command *cmd)
 Code to clean up resource this cmd used. More...
 
static int stop_testing_system_traits (void *cls, const void **ret, const char *trait, unsigned int index)
 Trait function of this cmd does nothing. More...
 
static void stop_testing_system_run (void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
 This function stops the helper process for each node. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_testing_system_v2 (const char *label, const char *helper_start_label, const char *topology_config)
 Create command. More...
 

Function Documentation

◆ stop_testing_system_cleanup()

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

Code to clean up resource this cmd used.

Parameters
clsclosure
cmdcurrent CMD being cleaned up.

Definition at line 58 of file testing_api_cmd_netjail_stop_testsystem_v2.c.

60 {
61 
62 }

◆ stop_testing_system_traits()

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

Trait function of this cmd does nothing.

Definition at line 70 of file testing_api_cmd_netjail_stop_testsystem_v2.c.

74 {
75  return GNUNET_OK;
76 }
@ GNUNET_OK
Definition: gnunet_common.h:95

References GNUNET_OK.

◆ stop_testing_system_run()

static void stop_testing_system_run ( void *  cls,
const struct GNUNET_TESTING_Command cmd,
struct GNUNET_TESTING_Interpreter is 
)
static

This function stops the helper process for each node.

Parameters
clsclosure.
cmdCMD being run.
isinterpreter state.

Definition at line 87 of file testing_api_cmd_netjail_stop_testsystem_v2.c.

90 {
91  struct StopHelperState *shs = cls;
92  struct GNUNET_HELPER_Handle **helper;
93  const struct GNUNET_TESTING_Command *start_helper_cmd;
94 
96  shs->helper_start_label);
98  &helper);
99 
100  for (int i = 1; i <= shs->global_n; i++)
101  {
102  for (int j = 1; j <= shs->local_m; j++)
103  {
104  GNUNET_HELPER_stop (helper[(i - 1) * shs->local_m + j - 1],
105  GNUNET_YES);
106  }
107  }
108 }
@ GNUNET_YES
Definition: gnunet_common.h:97
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(const char *label)
Lookup command by label.
int GNUNET_TESTING_get_trait_helper_handles(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_HELPER_Handle ***helper)
Offer handles to testing cmd helper from trait.
void GNUNET_HELPER_stop(struct GNUNET_HELPER_Handle *h, int soft_kill)
Kills the helper, closes the pipe, frees the handle and calls wait() on the helper process.
Definition: helper.c:567
The handle to a helper process.
Definition: helper.c:79
A command to be run by the interpreter.
Struct to store information handed over to callbacks.

References StopHelperState::global_n, GNUNET_HELPER_stop(), GNUNET_TESTING_get_trait_helper_handles(), GNUNET_TESTING_interpreter_lookup_command(), GNUNET_YES, StopHelperState::helper_start_label, and StopHelperState::local_m.

Here is the call graph for this function:

◆ GNUNET_TESTING_cmd_stop_testing_system_v2()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_testing_system_v2 ( const char *  label,
const char *  helper_start_label,
const char *  topology_config 
)

Create command.

Parameters
labelname for command.
helper_start_labellabel of the cmd to start the test system.
topology_configConfiguration file for the test topology.
Returns
command.

Definition at line 87 of file testing_api_cmd_netjail_stop_testsystem_v2.c.

123 {
124  struct StopHelperState *shs;
125 
127  GNUNET_TESTING_get_topo_from_file (topology_config);
128 
129  shs = GNUNET_new (struct StopHelperState);
130  shs->helper_start_label = helper_start_label;
131  shs->local_m = topology->nodes_m;
132  shs->global_n = topology->namespaces_n;
133 
134  struct GNUNET_TESTING_Command cmd = {
135  .cls = shs,
136  .label = label,
137  .run = &stop_testing_system_run,
138  .cleanup = &stop_testing_system_cleanup,
139  .traits = &stop_testing_system_traits
140  };
141 
142  return cmd;
143 }
enum GNUNET_TESTBED_TopologyOption topology
The topology to generate.
struct GNUNET_TESTING_NetjailTopology * GNUNET_TESTING_get_topo_from_file(const char *filename)
Getting the topology from file.
Definition: testing.c:1898
#define GNUNET_new(type)
Allocate a struct or union of the given type.
const char * label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
Toplogy of our netjail setup.
static void stop_testing_system_cleanup(void *cls, const struct GNUNET_TESTING_Command *cmd)
Code to clean up resource this cmd used.
static void stop_testing_system_run(void *cls, const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Interpreter *is)
This function stops the helper process for each node.
static int stop_testing_system_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.