aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_cmd_block_until_all_peers_started.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_cmd_block_until_all_peers_started.c')
-rw-r--r--src/testbed/testbed_api_cmd_block_until_all_peers_started.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/testbed/testbed_api_cmd_block_until_all_peers_started.c b/src/testbed/testbed_api_cmd_block_until_all_peers_started.c
new file mode 100644
index 000000000..fc872311d
--- /dev/null
+++ b/src/testbed/testbed_api_cmd_block_until_all_peers_started.c
@@ -0,0 +1,102 @@
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
21/**
22 * @file testing_api_cmd_block_until_all_peers_started.c
23 * @brief cmd to block the interpreter loop until all peers started.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29
30struct BlockState
31{
32 unsigned int *all_peers_started;
33};
34
35
36static int
37block_until_all_peers_started_traits (void *cls,
38 const void **ret,
39 const char *trait,
40 unsigned int index)
41{
42 return GNUNET_OK;
43}
44
45
46static void
47block_until_all_peers_started_cleanup (void *cls,
48 const struct GNUNET_TESTING_Command *cmd)
49{
50 struct BlockState *bs = cls;
51
52 GNUNET_free (bs);
53}
54
55
56static void
57block_until_all_peers_started_run (void *cls,
58 const struct GNUNET_TESTING_Command *cmd,
59 struct GNUNET_TESTING_Interpreter *is)
60{
61}
62
63
64static int
65block_until_all_peers_started_finish (void *cls,
66 GNUNET_SCHEDULER_TaskCallback cont,
67 void *cont_cls)
68{
69 struct BlockState *bs = cls;
70 unsigned int *ret = bs->all_peers_started;
71
72 return *ret;
73}
74
75
76/**
77 * Create command.
78 *
79 * @param label name for command.
80 * @return command.
81 */
82struct GNUNET_TESTING_Command
83GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label,
84 unsigned int *
85 all_peers_started)
86{
87 struct BlockState *bs;
88
89 bs = GNUNET_new (struct BlockState);
90 bs->all_peers_started = all_peers_started;
91
92 struct GNUNET_TESTING_Command cmd = {
93 .cls = bs,
94 .label = label,
95 .run = &block_until_all_peers_started_run,
96 .finish = &block_until_all_peers_started_finish,
97 .cleanup = &block_until_all_peers_started_cleanup,
98 .traits = &block_until_all_peers_started_traits
99 };
100
101 return cmd;
102}