GNUnet 0.21.1
testing_api_cmd_block_until_external_trigger.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"
28#include "testing_cmds.h"
32
36#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
37
38
43static void
45{
46 struct BlockState *bs = cls;
47
48 GNUNET_free (bs);
49}
50
51
52static int
54 const void **ret,
55 const char *trait,
56 unsigned int index)
57{
58 struct GNUNET_TESTING_BlockState *bs = cls;
59 struct GNUNET_TESTING_AsyncContext *ac = &bs->ac;
60 struct GNUNET_TESTING_Trait traits[] = {
64 };
65
66 return GNUNET_TESTING_get_trait (traits,
67 ret,
68 trait,
69 index);
70}
71
72
77static void
80{
81 struct GNUNET_TESTING_BlockState *bs = cls;
82 struct GNUNET_TESTING_Command *cmd =
84
86 "block %s running %u!\n",
87 bs->label,
90 {
92 "block %s running asynchronous!\n",
93 bs->label);
95 }
96}
97
98
107 const char *label)
108{
109 struct GNUNET_TESTING_BlockState *bs;
110
112 bs->label = label;
114 label,
118 &bs->ac);
119}
static int ret
Final status code.
Definition: gnunet-arm.c:94
struct GNUNET_TESTING_Interpreter * is
API to manage barriers.
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.
struct GNUNET_TESTING_Trait GNUNET_TESTING_trait_end(void)
"end" of traits array.
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait(const struct GNUNET_TESTING_Trait *traits, const void **ret, const char *trait, unsigned int index)
Obtain value of a trait from a command.
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_async_context(struct GNUNET_TESTING_AsyncContext *value)
struct GNUNET_TESTING_Trait GNUNET_TESTING_make_trait_block_state(struct GNUNET_TESTING_BlockState *value)
@ GNUNET_YES
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
State each asynchronous command must have in its closure.
Struct with information for callbacks.
struct GNUNET_TESTING_AsyncContext ac
Context for our asynchronous completion.
unsigned int asynchronous_finish
If this command will block.
const char * label
The label of this command.
A command to be run by the interpreter.
struct GNUNET_TESTING_CommandLabel label
Label for the command.
bool asynchronous_finish
If "true", the interpreter should not immediately call finish, even if finish is non-NULL.
Global state of the interpreter, used by a command to access information about other commands.
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
static void block_until_all_peers_started_cleanup(void *cls)
The cleanup function of this cmd frees resources the cmd allocated.
static int block_until_external_trigger_traits(void *cls, const void **ret, const char *trait, unsigned int index)
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_block_until_external_trigger(const char *label)
Create command.
#define LOG(kind,...)
Generic logging shortcut.
static void block_until_all_peers_started_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
This function does nothing but to start the cmd.
struct GNUNET_TESTING_Command * GNUNET_TESTING_interpreter_get_current_command(struct GNUNET_TESTING_Interpreter *is)
Returns the actual running command.
Message formats for communication between testing cmds helper and testcase plugins.