GNUnet 0.22.1
testing_api_cmd_signal.c File Reference

command(s) to send signals to processes. More...

#include "platform.h"
#include "gnunet_testing_lib.h"
Include dependency graph for testing_api_cmd_signal.c:

Go to the source code of this file.

Data Structures

struct  SignalState
 State for a "signal" CMD. More...
 

Functions

static void signal_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 Run the command. More...
 
static void signal_cleanup (void *cls)
 Cleanup the state from a "signal" CMD. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_signal (const char *label, const char *process_label, int signal)
 Create a "signal" CMD. More...
 

Detailed Description

command(s) to send signals to processes.

Author
Marcello Stanisci

Definition in file testing_api_cmd_signal.c.

Function Documentation

◆ signal_run()

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

Run the command.

Parameters
clsclosure.
cmdthe command to execute.
isthe interpreter state.

Definition at line 52 of file testing_api_cmd_signal.c.

54{
55 struct SignalState *ss = cls;
56 const struct GNUNET_TESTING_Command *pcmd;
58
59 pcmd
61 ss->process_label);
62 if (NULL == pcmd)
63 {
65 "Did not find command `%s'\n",
66 ss->process_label);
68 }
69 if (GNUNET_OK !=
71 &process))
73 GNUNET_break (0 ==
75 ss->signal));
77 "Signaling '%d'..\n",
78 ss->signal);
79}
static struct GNUNET_TESTING_Interpreter * is
#define GNUNET_TESTING_FAIL(is)
Print failing line number and trigger shutdown.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_process(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_OS_Process ***ret)
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
#define GNUNET_log(kind,...)
@ GNUNET_OK
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_INFO
int GNUNET_OS_process_kill(struct GNUNET_OS_Process *proc, int sig)
Sends a signal to the process.
Definition: os_priority.c:210
process($line, $c)
Definition: log.php:48
A command to be run by the interpreter.
State for a "signal" CMD.
const char * process_label
Label of the process to send the signal to.
int signal
The signal to send to the process.

References GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_OK, GNUNET_OS_process_kill(), GNUNET_TESTING_FAIL, GNUNET_TESTING_get_trait_process(), GNUNET_TESTING_interpreter_lookup_command(), is, process(), SignalState::process_label, and SignalState::signal.

Referenced by GNUNET_TESTING_cmd_signal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_cleanup()

static void signal_cleanup ( void *  cls)
static

Cleanup the state from a "signal" CMD.

Parameters
clsclosure.

Definition at line 88 of file testing_api_cmd_signal.c.

89{
90 struct SignalState *ss = cls;
91
92 GNUNET_free (ss);
93}
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free.

Referenced by GNUNET_TESTING_cmd_signal().

Here is the caller graph for this function:

◆ GNUNET_TESTING_cmd_signal()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_signal ( const char *  label,
const char *  process_label,
int  signal 
)

Create a "signal" CMD.

Parameters
labelcommand label.
processhandle to the process to signal.
signalsignal to send.
Returns
the command.

Definition at line 105 of file testing_api_cmd_signal.c.

109{
110 struct SignalState *ss;
111
112 ss = GNUNET_new (struct SignalState);
114 ss->signal = signal;
116 label,
117 &signal_run,
119 NULL);
120}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void signal_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the command.
static void signal_cleanup(void *cls)
Cleanup the state from a "signal" CMD.

References GNUNET_new, GNUNET_TESTING_command_new, SignalState::process_label, SignalState::signal, signal_cleanup(), and signal_run().

Here is the call graph for this function: