aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_testing_barrier.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_testing_barrier.h')
-rw-r--r--src/include/gnunet_testing_barrier.h122
1 files changed, 122 insertions, 0 deletions
diff --git a/src/include/gnunet_testing_barrier.h b/src/include/gnunet_testing_barrier.h
new file mode 100644
index 000000000..b0f4e1c03
--- /dev/null
+++ b/src/include/gnunet_testing_barrier.h
@@ -0,0 +1,122 @@
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
21/**
22 * @file include/gnunet_testing_barrier.h
23 * @brief API to manage barriers.
24 * @author t3sserakt
25 */
26
27#ifndef GNUNET_TESTING_BARRIER_LIB_H
28#define GNUNET_TESTING_BARRIER_LIB_H
29
30#include "gnunet_testing_plugin.h"
31
32
33struct GNUNET_TESTING_Barrier;
34
35
36#define GNUNET_TESTING_BARRIER_MAX 32
37
38/**
39 * An entry for a barrier list
40 * FIXME: why is this in the public API!??!
41 */
42struct GNUNET_TESTING_BarrierListEntry
43{
44 /* DLL */
45 struct GNUNET_TESTING_BarrierListEntry *next;
46
47 /* DLL */
48 struct GNUNET_TESTING_BarrierListEntry *prev;
49
50 /* The barrier name*/
51 char *barrier_name;
52
53 /**
54 * Number of commands attached to the barrier.
55 */
56 unsigned int expected_reaches;
57 };
58
59/**
60 * A list to hold barriers provided by plugins
61 * FIXME: why is this in the public API!??!
62 */
63struct GNUNET_TESTING_BarrierList
64{
65 /** List head **/
66 struct GNUNET_TESTING_BarrierListEntry *head;
67
68 /** List tail **/
69 struct GNUNET_TESTING_BarrierListEntry *tail;
70};
71
72
73/**
74 * Command to create a barrier.
75 *
76 * FIXME: high-level it is baffling how we need both the GNUNET_TESTING_Barrier
77 * and the Command that creates barriers. Conceptually this seems to be
78 * very much separate. Can we move _Barrier completely into testing as private?
79 *
80 * @param label The label of this command.
81 * @param percentage_to_be_reached If this percentage of processes reached
82 * this barrier, all processes waiting at
83 * this barrier can pass it. Must not be
84 * used together with number_to_be_reached.
85 * @param number_to_be_reached If this number of processes reached
86 * this barrier, all processes waiting at
87 * this barrier can pass it. Must not be
88 * used together with percentage_to_be_reached.
89 */
90struct GNUNET_TESTING_Command
91GNUNET_TESTING_cmd_barrier_create (
92 const char *label,
93 double percentage_to_be_reached,
94 unsigned int number_to_be_reached);
95
96
97/**
98 * If this command is executed the the process is signaling the master process
99 * that it reached a barrier. If this command is synchronous it will block.
100 *
101 * FIXME: Now this, as it returns a Command, seems to me like it should be
102 * part of the public API?
103 *
104 * @param label name for command.
105 * @param barrier_label The name of the barrier we waited for and which was reached.
106 * @param asynchronous_finish If #GNUNET_YES this command will not block.
107 * @param node_number The global number of the node the cmd runs on.
108 * @param running_on_master Is this cmd running on the master loop?
109 * @param write_message Callback to write messages to the master loop.
110 * @return command.
111 */
112struct GNUNET_TESTING_Command
113GNUNET_TESTING_cmd_barrier_reached (
114 const char *label,
115 const char *barrier_label,
116 unsigned int asynchronous_finish, /* FIXME: why not a bool? */
117 unsigned int node_number,
118 unsigned int running_on_master, /* FIXME: why not a bool? */
119 GNUNET_TESTING_cmd_helper_write_cb write_message); /* FIXME: no 'cls' closure argument!? */
120
121#endif
122/* end of testing_barrier.h */