GNUnet 0.21.2
testing_api_cmd_signal.c
Go to the documentation of this file.
1/*
2 This file is part of GNUNET
3 (C) 2018 GNUnet e.V.
4
5 GNUNET is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 3, or
8 (at your option) any later version.
9
10 GNUNET is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with GNUNET; see the file COPYING. If not, see
17 <http://www.gnu.org/licenses/>
18*/
24#include "platform.h"
25#include "gnunet_testing_lib.h"
26
27
32{
36 const char *process_label;
37
41 int signal;
42};
43
51static void
52signal_run (void *cls,
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}
80
81
87static void
88signal_cleanup (void *cls)
89{
90 struct SignalState *ss = cls;
91
92 GNUNET_free (ss);
93}
94
95
106 const char *label,
107 const char *process_label,
108 int signal)
109{
110 struct SignalState *ss;
111
112 ss = GNUNET_new (struct SignalState);
114 ss->signal = signal;
116 label,
117 &signal_run,
119 NULL);
120}
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_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.
#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
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
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.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
Global state of the interpreter, used by a command to access information about other commands.
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.
static void signal_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the command.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_signal(const char *label, const char *process_label, int signal)
Create a "signal" CMD.
static void signal_cleanup(void *cls)
Cleanup the state from a "signal" CMD.