diff options
author | t3sserakt <t3ss@posteo.de> | 2021-04-15 15:35:28 +0200 |
---|---|---|
committer | t3sserakt <t3ss@posteo.de> | 2021-04-15 15:35:28 +0200 |
commit | 925c210d978cd0e3dfc718d9e4c65ad713a817b9 (patch) | |
tree | b769182d686220816a387336d525f37124dbad72 /src/include | |
parent | a785d16b7f49947458782f65f344036a848f4ac7 (diff) | |
download | gnunet-925c210d978cd0e3dfc718d9e4c65ad713a817b9.tar.gz gnunet-925c210d978cd0e3dfc718d9e4c65ad713a817b9.zip |
- added handling of asynchronous task to testing ng. added testbed commands for setting up test invironment (atm wihtout the use of the ne async handling)
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_testbed_ng_service.h | 35 | ||||
-rw-r--r-- | src/include/gnunet_testing_ng_lib.h | 104 |
2 files changed, 44 insertions, 95 deletions
diff --git a/src/include/gnunet_testbed_ng_service.h b/src/include/gnunet_testbed_ng_service.h index a6f30889f..370617e68 100644 --- a/src/include/gnunet_testbed_ng_service.h +++ b/src/include/gnunet_testbed_ng_service.h | |||
@@ -38,33 +38,7 @@ | |||
38 | #include "gnunet_util_lib.h" | 38 | #include "gnunet_util_lib.h" |
39 | #include "gnunet_testing_ng_lib.h" | 39 | #include "gnunet_testing_ng_lib.h" |
40 | 40 | ||
41 | struct ServiceState | 41 | struct TngState; |
42 | { | ||
43 | /** | ||
44 | * Handle to operation | ||
45 | */ | ||
46 | struct GNUNET_TESTBED_Operation *operation; | ||
47 | |||
48 | /** | ||
49 | * Flag indicating if service is ready. | ||
50 | */ | ||
51 | int service_ready; | ||
52 | |||
53 | /** | ||
54 | * Abort task identifier | ||
55 | */ | ||
56 | struct GNUNET_SCHEDULER_Task *abort_task; | ||
57 | |||
58 | /** | ||
59 | * Label of peer command. | ||
60 | */ | ||
61 | const char *peer_label; | ||
62 | |||
63 | /** | ||
64 | * Name of service to start. | ||
65 | */ | ||
66 | const char *servicename; | ||
67 | }; | ||
68 | 42 | ||
69 | struct PeerCmdState | 43 | struct PeerCmdState |
70 | { | 44 | { |
@@ -111,11 +85,6 @@ struct PeerCmdState | |||
111 | struct GNUNET_SCHEDULER_Task *abort_task; | 85 | struct GNUNET_SCHEDULER_Task *abort_task; |
112 | 86 | ||
113 | /** | 87 | /** |
114 | * Handle for host registration | ||
115 | */ | ||
116 | struct GNUNET_TESTBED_HostRegistrationHandle *reg_handle; | ||
117 | |||
118 | /** | ||
119 | * Flag indicating if peer is ready. | 88 | * Flag indicating if peer is ready. |
120 | */ | 89 | */ |
121 | int peer_ready; | 90 | int peer_ready; |
@@ -242,6 +211,6 @@ void | |||
242 | GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps); | 211 | GNUNET_TESTBED_shutdown_peer (struct PeerCmdState *ps); |
243 | 212 | ||
244 | void | 213 | void |
245 | GNUNET_TESTBED_shutdown_service (struct ServiceState *ss); | 214 | GNUNET_TESTBED_shutdown_service (struct TngState *ss); |
246 | 215 | ||
247 | #endif | 216 | #endif |
diff --git a/src/include/gnunet_testing_ng_lib.h b/src/include/gnunet_testing_ng_lib.h index 0bc516614..001d92aad 100644 --- a/src/include/gnunet_testing_ng_lib.h +++ b/src/include/gnunet_testing_ng_lib.h | |||
@@ -51,46 +51,7 @@ | |||
51 | * Global state of the interpreter, used by a command | 51 | * Global state of the interpreter, used by a command |
52 | * to access information about other commands. | 52 | * to access information about other commands. |
53 | */ | 53 | */ |
54 | // SUGGESTION: consider making this struct opaque (only known inside of libgnunettesting, | 54 | struct GNUNET_TESTING_Interpreter; |
55 | // say main loop and a few select commands, like next/fail/batch); + helper | ||
56 | // function to access 'cfg'? | ||
57 | struct GNUNET_TESTING_Interpreter | ||
58 | { | ||
59 | |||
60 | /** | ||
61 | * Commands the interpreter will run. | ||
62 | */ | ||
63 | struct GNUNET_TESTING_Command *commands; | ||
64 | |||
65 | /** | ||
66 | * Interpreter task (if one is scheduled). | ||
67 | */ | ||
68 | struct GNUNET_SCHEDULER_Task *task; | ||
69 | |||
70 | /** | ||
71 | * Our configuration. | ||
72 | */ | ||
73 | const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
74 | |||
75 | /** | ||
76 | * Task run on timeout. | ||
77 | */ | ||
78 | struct GNUNET_SCHEDULER_Task *timeout_task; | ||
79 | |||
80 | /** | ||
81 | * Instruction pointer. Tells #interpreter_run() which instruction to run | ||
82 | * next. Need (signed) int because it gets -1 when rewinding the | ||
83 | * interpreter to the first CMD. | ||
84 | */ | ||
85 | int ip; | ||
86 | |||
87 | /** | ||
88 | * Result of the testcases, #GNUNET_OK on success | ||
89 | */ | ||
90 | int result; | ||
91 | |||
92 | }; | ||
93 | |||
94 | 55 | ||
95 | /** | 56 | /** |
96 | * A command to be run by the interpreter. | 57 | * A command to be run by the interpreter. |
@@ -131,21 +92,26 @@ struct GNUNET_TESTING_Command | |||
131 | 92 | ||
132 | /** | 93 | /** |
133 | * Wait for any asynchronous execution of @e run to conclude, | 94 | * Wait for any asynchronous execution of @e run to conclude, |
134 | * then call @a cont. Finish may only be called once per command. | 95 | * then call finish_cont. Finish may only be called once per command. |
135 | * | 96 | * |
136 | * This member may be NULL if this command is a synchronous command, | 97 | * This member may be NULL if this command is a synchronous command, |
137 | * and also should be set to NULL once the command has finished. | 98 | * and also should be set to NULL once the command has finished. |
138 | * | 99 | * |
100 | * @param cls closure | ||
139 | * @param cont function to call upon completion, can be NULL | 101 | * @param cont function to call upon completion, can be NULL |
140 | * @param cont_cls closure for @a cont | 102 | * @param cont_cls closure for @a cont |
141 | */ | 103 | */ |
142 | // SUGGESTION (NEW!) | 104 | bool |
143 | void | ||
144 | (*finish)(void *cls, | 105 | (*finish)(void *cls, |
145 | struct GNUNET_SCHEDULER_Task cont, | 106 | GNUNET_SCHEDULER_TaskCallback cont, |
146 | void *cont_cls); | 107 | void *cont_cls); |
147 | 108 | ||
148 | /** | 109 | /** |
110 | * Task for running the finish function. | ||
111 | */ | ||
112 | struct GNUNET_SCHEDULER_Task *finish_task; | ||
113 | |||
114 | /** | ||
149 | * Clean up after the command. Run during forced termination | 115 | * Clean up after the command. Run during forced termination |
150 | * (CTRL-C) or test failure or test success. | 116 | * (CTRL-C) or test failure or test success. |
151 | * | 117 | * |
@@ -206,7 +172,6 @@ struct GNUNET_TESTING_Command | |||
206 | * time, the interpreter will fail. Should be set generously to ensure | 172 | * time, the interpreter will fail. Should be set generously to ensure |
207 | * tests do not fail on slow systems. | 173 | * tests do not fail on slow systems. |
208 | */ | 174 | */ |
209 | // SUGGESTION (NEW): | ||
210 | struct GNUNET_TIME_Relative default_timeout; | 175 | struct GNUNET_TIME_Relative default_timeout; |
211 | 176 | ||
212 | /** | 177 | /** |
@@ -215,13 +180,39 @@ struct GNUNET_TESTING_Command | |||
215 | * #TALER_TESTING_cmd_finish() must be used | 180 | * #TALER_TESTING_cmd_finish() must be used |
216 | * to ensure that a command actually completed. | 181 | * to ensure that a command actually completed. |
217 | */ | 182 | */ |
218 | // SUGGESTION (NEW): | ||
219 | bool asynchronous_finish; | 183 | bool asynchronous_finish; |
220 | 184 | ||
221 | }; | 185 | }; |
222 | 186 | ||
223 | 187 | ||
224 | /** | 188 | /** |
189 | * Struct to use for command-specific context information closure of a command waiting | ||
190 | * for another command. | ||
191 | */ | ||
192 | struct SyncState | ||
193 | { | ||
194 | /** | ||
195 | * Closure for all commands with command-specific context information. | ||
196 | */ | ||
197 | void *cls; | ||
198 | |||
199 | /** | ||
200 | * The asynchronous command the synchronous command of this closure waits for. | ||
201 | */ | ||
202 | const struct GNUNET_TESTING_Command *async_cmd; | ||
203 | |||
204 | /** | ||
205 | * Task for running the finish method of the asynchronous task the command is waiting for. | ||
206 | */ | ||
207 | struct GNUNET_SCHEDULER_Task *finish_task; | ||
208 | |||
209 | /** | ||
210 | * When did the execution of this commands finish function start? | ||
211 | */ | ||
212 | struct GNUNET_TIME_Absolute start_finish_time; | ||
213 | }; | ||
214 | |||
215 | /** | ||
225 | * Lookup command by label. | 216 | * Lookup command by label. |
226 | * | 217 | * |
227 | * @param label label of the command to lookup. | 218 | * @param label label of the command to lookup. |
@@ -244,15 +235,6 @@ GNUNET_TESTING_interpreter_get_current_label ( | |||
244 | 235 | ||
245 | 236 | ||
246 | /** | 237 | /** |
247 | * Current command is done, run the next one. | ||
248 | * | ||
249 | * @param is interpreter state. | ||
250 | */ | ||
251 | void | ||
252 | GNUNET_TESTING_interpreter_next (struct GNUNET_TESTING_Interpreter *is); | ||
253 | |||
254 | |||
255 | /** | ||
256 | * Current command failed, clean up and fail the test case. | 238 | * Current command failed, clean up and fail the test case. |
257 | * | 239 | * |
258 | * @param is interpreter state. | 240 | * @param is interpreter state. |
@@ -271,14 +253,13 @@ GNUNET_TESTING_cmd_end (void); | |||
271 | 253 | ||
272 | 254 | ||
273 | /** | 255 | /** |
274 | * Turn synchronous command into asynchronous command. | 256 | * Turn asynchronous command into non blocking command by setting asynchronous_finish to true. |
275 | * | 257 | * |
276 | * @param cmd command to make synchronous. | 258 | * @param cmd command to make synchronous. |
277 | * @return a finish-command. | 259 | * @return a finish-command. |
278 | */ | 260 | */ |
279 | // SUGGESTION (NEW!) | ||
280 | const struct GNUNET_TESTING_Command | 261 | const struct GNUNET_TESTING_Command |
281 | TALER_TESTING_cmd_make_asynchronous (const struct GNUNET_TESTING_Command cmd); | 262 | GNUNET_TESTING_cmd_make_unblocking (const struct GNUNET_TESTING_Command cmd); |
282 | 263 | ||
283 | 264 | ||
284 | /** | 265 | /** |
@@ -292,11 +273,10 @@ TALER_TESTING_cmd_make_asynchronous (const struct GNUNET_TESTING_Command cmd); | |||
292 | * @param timeout how long to wait at most for @a cmd_ref to finish | 273 | * @param timeout how long to wait at most for @a cmd_ref to finish |
293 | * @return a finish-command. | 274 | * @return a finish-command. |
294 | */ | 275 | */ |
295 | // SUGGESTION (NEW!) | ||
296 | const struct GNUNET_TESTING_Command | 276 | const struct GNUNET_TESTING_Command |
297 | TALER_TESTING_cmd_finish (const char *finish_label, | 277 | GNUNET_TESTING_cmd_finish (const char *finish_label, |
298 | const char *cmd_ref, | 278 | const char *cmd_ref, |
299 | struct GNUNET_TIME_Relative timeout); | 279 | struct GNUNET_TIME_Relative timeout); |
300 | 280 | ||
301 | 281 | ||
302 | /** | 282 | /** |