diff options
Diffstat (limited to 'src/testing/testing_api_cmd_local_test_finished.c')
-rw-r--r-- | src/testing/testing_api_cmd_local_test_finished.c | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c deleted file mode 100644 index 383de4c10..000000000 --- a/src/testing/testing_api_cmd_local_test_finished.c +++ /dev/null | |||
@@ -1,151 +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 | #include "testing_cmds.h" | ||
30 | |||
31 | /** | ||
32 | * Generic logging shortcut | ||
33 | */ | ||
34 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | ||
35 | |||
36 | |||
37 | /** | ||
38 | * Struct to hold information for callbacks. | ||
39 | * | ||
40 | */ | ||
41 | struct LocalFinishedState | ||
42 | { | ||
43 | /** | ||
44 | * Callback to write messages to the master loop. | ||
45 | * | ||
46 | */ | ||
47 | TESTING_CMD_HELPER_write_cb write_message; | ||
48 | |||
49 | /** | ||
50 | * The message send back to the master loop. | ||
51 | * | ||
52 | */ | ||
53 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
54 | }; | ||
55 | |||
56 | |||
57 | /** | ||
58 | * Trait function of this cmd does nothing. | ||
59 | * | ||
60 | */ | ||
61 | static int | ||
62 | local_test_finished_traits (void *cls, | ||
63 | const void **ret, | ||
64 | const char *trait, | ||
65 | unsigned int index) | ||
66 | { | ||
67 | return GNUNET_OK; | ||
68 | } | ||
69 | |||
70 | |||
71 | /** | ||
72 | * The cleanup function of this cmd frees resources the cmd allocated. | ||
73 | * | ||
74 | */ | ||
75 | static void | ||
76 | local_test_finished_cleanup (void *cls, | ||
77 | const struct GNUNET_TESTING_Command *cmd) | ||
78 | { | ||
79 | struct LocalFinishedState *lfs = cls; | ||
80 | |||
81 | GNUNET_free (lfs->reply); | ||
82 | GNUNET_free (lfs); | ||
83 | } | ||
84 | |||
85 | |||
86 | /** | ||
87 | * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop. | ||
88 | * | ||
89 | */ | ||
90 | static void | ||
91 | local_test_finished_run (void *cls, | ||
92 | const struct GNUNET_TESTING_Command *cmd, | ||
93 | struct GNUNET_TESTING_Interpreter *is) | ||
94 | { | ||
95 | struct LocalFinishedState *lfs = cls; | ||
96 | |||
97 | struct GNUNET_CMDS_LOCAL_FINISHED *reply; | ||
98 | size_t msg_length; | ||
99 | |||
100 | msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); | ||
101 | reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); | ||
102 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); | ||
103 | reply->header.size = htons ((uint16_t) msg_length); | ||
104 | lfs->reply = reply; | ||
105 | lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); | ||
106 | } | ||
107 | |||
108 | |||
109 | /** | ||
110 | * This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method. | ||
111 | * | ||
112 | */ | ||
113 | static int | ||
114 | local_test_finished_finish (void *cls, | ||
115 | GNUNET_SCHEDULER_TaskCallback cont, | ||
116 | void *cont_cls) | ||
117 | { | ||
118 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
119 | "Stopping local loop\n"); | ||
120 | return GNUNET_YES; | ||
121 | } | ||
122 | |||
123 | |||
124 | /** | ||
125 | * Create command. | ||
126 | * | ||
127 | * @param label name for command. | ||
128 | * @param write_message Callback to write messages to the master loop. | ||
129 | * @return command. | ||
130 | */ | ||
131 | struct GNUNET_TESTING_Command | ||
132 | GNUNET_TESTING_cmd_local_test_finished (const char *label, | ||
133 | TESTING_CMD_HELPER_write_cb | ||
134 | write_message) | ||
135 | { | ||
136 | struct LocalFinishedState *lfs; | ||
137 | |||
138 | lfs = GNUNET_new (struct LocalFinishedState); | ||
139 | lfs->write_message = write_message; | ||
140 | |||
141 | struct GNUNET_TESTING_Command cmd = { | ||
142 | .cls = lfs, | ||
143 | .label = label, | ||
144 | .run = &local_test_finished_run, | ||
145 | .finish = &local_test_finished_finish, | ||
146 | .cleanup = &local_test_finished_cleanup, | ||
147 | .traits = &local_test_finished_traits | ||
148 | }; | ||
149 | |||
150 | return cmd; | ||
151 | } | ||