GNUnet 0.21.1
testing_api_cmd_stop_peer.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (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 GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
26#include "platform.h"
27#include "gnunet_util_lib.h"
30
34#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
35
36
42{
43 // Label of the cmd to start the peer.
44 const char *start_label;
45};
46
47
52static void
53stop_peer_run (void *cls,
55{
56 struct StopPeerState *stop_ps = cls;
57 const struct GNUNET_TESTING_StartPeerState *sps;
58 const struct GNUNET_TESTING_Command *start_cmd;
59
61 stop_ps->start_label);
63 &sps);
64
65 if (NULL != sps->peer)
66 {
67 if (GNUNET_OK !=
69 {
71 "Testing lib failed to stop peer %u (`%s')\n",
72 sps->no,
73 GNUNET_i2s (&sps->id));
74 }
76 }
77 if (NULL != sps->rh_task)
79}
80
81
86static void
88{
89 struct StopPeerState *sps = cls;
90
91 GNUNET_free (sps);
92}
93
94
99static int
101 const void **ret,
102 const char *trait,
103 unsigned int index)
104{
105 return GNUNET_OK;
106}
107
108
118 const char *start_label)
119{
120 struct StopPeerState *sps;
121
122 sps = GNUNET_new (struct StopPeerState);
124 return GNUNET_TESTING_command_new (sps,
125 label,
129 NULL);
130}
static int ret
Final status code.
Definition: gnunet-arm.c:94
struct GNUNET_TESTING_Interpreter * is
const struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_lookup_command(struct GNUNET_TESTING_Interpreter *is, const char *label)
Lookup command by label.
struct GNUNET_TESTING_Command GNUNET_TESTING_command_new(void *cls, const char *label, GNUNET_TESTING_CommandRunRoutine run, GNUNET_TESTING_CommandCleanupRoutine cleanup, GNUNET_TESTING_CommandGetTraits traits, struct GNUNET_TESTING_AsyncContext *ac)
Create a new command.
enum GNUNET_GenericReturnValue GNUNET_TRANSPORT_TESTING_get_trait_state(const struct GNUNET_TESTING_Command *cmd, const struct GNUNET_TESTING_StartPeerState **ret)
@ GNUNET_OK
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:981
int GNUNET_TESTING_peer_stop(struct GNUNET_TESTING_Peer *peer)
Stop the peer.
Definition: testing.c:1485
void GNUNET_TESTING_peer_destroy(struct GNUNET_TESTING_Peer *peer)
Destroy the peer.
Definition: testing.c:1566
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
void * cls
Closure for all commands with command-specific context information.
Global state of the interpreter, used by a command to access information about other commands.
struct GNUNET_PeerIdentity id
Peer identity.
unsigned int no
An unique number to identify the peer.
struct GNUNET_TESTING_Peer * peer
struct GNUNET_TESTING_Peer returned by GNUNET_TESTING_peer_configure.
struct GNUNET_SCHEDULER_Task * rh_task
Hello get task.
Struct to hold information for callbacks.
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stop_peer(const char *label, const char *start_label)
Create command.
static int stop_peer_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Trait function of this cmd does nothing.
static void stop_peer_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
#define LOG(kind,...)
Generic logging shortcut.
static void stop_peer_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
The run method of this cmd will stop all services of a peer which were used to test the transport ser...