diff options
Diffstat (limited to 'src/testing/testing_api_cmd_block_until_all_peers_started.c')
-rw-r--r-- | src/testing/testing_api_cmd_block_until_all_peers_started.c | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/testing/testing_api_cmd_block_until_all_peers_started.c b/src/testing/testing_api_cmd_block_until_all_peers_started.c deleted file mode 100644 index 763713e15..000000000 --- a/src/testing/testing_api_cmd_block_until_all_peers_started.c +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
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 | |||
30 | /** | ||
31 | * Generic logging shortcut | ||
32 | */ | ||
33 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
34 | |||
35 | /** | ||
36 | * Struct with information for callbacks. | ||
37 | * | ||
38 | */ | ||
39 | struct BlockState | ||
40 | { | ||
41 | /** | ||
42 | * Context for our asynchronous completion. | ||
43 | */ | ||
44 | struct GNUNET_TESTING_AsyncContext ac; | ||
45 | |||
46 | /** | ||
47 | * Flag to indicate if all peers have started. | ||
48 | * | ||
49 | */ | ||
50 | unsigned int *all_peers_started; | ||
51 | }; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
56 | * | ||
57 | */ | ||
58 | static void | ||
59 | block_until_all_peers_started_cleanup (void *cls) | ||
60 | { | ||
61 | struct BlockState *bs = cls; | ||
62 | |||
63 | GNUNET_free (bs); | ||
64 | } | ||
65 | |||
66 | |||
67 | /** | ||
68 | * This function does nothing but to start the cmd. | ||
69 | * | ||
70 | */ | ||
71 | static void | ||
72 | block_until_all_peers_started_run (void *cls, | ||
73 | struct GNUNET_TESTING_Interpreter *is) | ||
74 | { | ||
75 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
76 | "block_until_all_peers_started_run!\n"); | ||
77 | } | ||
78 | |||
79 | |||
80 | /** | ||
81 | * Create command. | ||
82 | * | ||
83 | * @param label name for command. | ||
84 | * @param all_peers_started Flag which will be set from outside. | ||
85 | * @return command. | ||
86 | */ | ||
87 | struct GNUNET_TESTING_Command | ||
88 | GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label, | ||
89 | unsigned int * | ||
90 | all_peers_started) | ||
91 | { | ||
92 | struct BlockState *bs; | ||
93 | |||
94 | bs = GNUNET_new (struct BlockState); | ||
95 | bs->all_peers_started = all_peers_started; | ||
96 | { | ||
97 | struct GNUNET_TESTING_Command cmd = { | ||
98 | .cls = bs, | ||
99 | .label = label, | ||
100 | .run = &block_until_all_peers_started_run, | ||
101 | .ac = &bs->ac, | ||
102 | .cleanup = &block_until_all_peers_started_cleanup | ||
103 | }; | ||
104 | |||
105 | return cmd; | ||
106 | } | ||
107 | } | ||