GNUnet 0.21.2
testing_api_cmd_barrier_create.c
Go to the documentation of this file.
1/*
2 This file is part of GNUnet
3 Copyright (C) 2022 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_testing_lib.h"
28#include "testing_api_barrier.h"
29#include "testing_api_loop.h"
30
31
42barrier_traits (void *cls,
43 const void **ret,
44 const char *trait,
45 unsigned int index)
46{
47 struct GNUNET_TESTING_Trait traits[] = {
49 };
50
52 ret,
53 trait,
54 index);
55}
56
57
64static void
65barrier_cleanup (void *cls)
66{
67 struct GNUNET_TESTING_Barrier *barrier = cls;
68
69 GNUNET_free (barrier);
70}
71
72
79static void
80barrier_run (void *cls,
82{
83 struct GNUNET_TESTING_Barrier *barrier = cls;
84
86 barrier);
87}
88
89
92 const char *label,
93 unsigned int number_to_be_reached)
94{
95 struct GNUNET_TESTING_Barrier *barrier;
96
97 barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
99 &barrier->barrier_id);
100 barrier->expected_reaches = number_to_be_reached;
101 return GNUNET_TESTING_command_new (barrier,
102 label,
106}
static int ret
Final status code.
Definition: gnunet-arm.c:94
static struct GNUNET_TESTING_Interpreter * is
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
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.
GNUNET_GenericReturnValue
Named constants for return values.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_free(ptr)
Wrapper around free.
An entry for a barrier list.
struct GNUNET_ShortHashCode barrier_id
unsigned int expected_reaches
Number of total commands expected to be reached by the barrier.
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.
A struct GNUNET_TESTING_Trait can be used to exchange data between cmds.
unsigned int index
Index number associated with the trait.
void GNUNET_TESTING_barrier_name_hash_(const char *barrier_name, struct GNUNET_ShortHashCode *bkey)
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_barrier_create(const char *label, unsigned int number_to_be_reached)
Command to create a barrier.
static enum GNUNET_GenericReturnValue barrier_traits(void *cls, const void **ret, const char *trait, unsigned int index)
Offer internal data from a "barrier" CMD, to other commands.
static void barrier_cleanup(void *cls)
Cleanup the state from a "barrier" CMD, and possibly cancel a pending operation thereof.
static void barrier_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run the command.
static enum GNUNET_GenericReturnValue traits(void *cls, const void **ret, const char *trait, unsigned int index)
This function prepares an array with traits.
void GNUNET_TESTING_add_barrier_(struct GNUNET_TESTING_Interpreter *is, struct GNUNET_TESTING_Barrier *barrier)
Add a barrier to the interpreter to share it with all children as an inherited barrier.