diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-11 16:17:20 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-11 16:17:20 +0000 |
commit | 8af9412585b17289e8fa5ca905eaa33415927dc3 (patch) | |
tree | f4cc0ed3a8b745a04832157a173a9eefc8f28e89 /src/ats/test_ats_lib.h | |
parent | 567ca9a20a7afe3573cb1c11ad89c116a0650fe7 (diff) | |
download | gnunet-8af9412585b17289e8fa5ca905eaa33415927dc3.tar.gz gnunet-8af9412585b17289e8fa5ca905eaa33415927dc3.zip |
new testsuite, obsoleting (most of) the old one
Diffstat (limited to 'src/ats/test_ats_lib.h')
-rw-r--r-- | src/ats/test_ats_lib.h | 467 |
1 files changed, 467 insertions, 0 deletions
diff --git a/src/ats/test_ats_lib.h b/src/ats/test_ats_lib.h new file mode 100644 index 000000000..590aac750 --- /dev/null +++ b/src/ats/test_ats_lib.h | |||
@@ -0,0 +1,467 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | 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 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file ats/test_ats_lib.h | ||
22 | * @brief test ATS library with a generic interpreter for running ATS tests | ||
23 | * @author Christian Grothoff | ||
24 | */ | ||
25 | #ifndef TEST_ATS_LIB_H | ||
26 | #define TEST_ATS_LIB_H | ||
27 | |||
28 | #include "gnunet_util_lib.h" | ||
29 | #include "gnunet_ats_service.h" | ||
30 | #include "gnunet_testing_lib.h" | ||
31 | |||
32 | |||
33 | /** | ||
34 | * Commands for the interpreter. | ||
35 | */ | ||
36 | enum CommandCode | ||
37 | { | ||
38 | /** | ||
39 | * End the test (passing). | ||
40 | */ | ||
41 | CMD_END_PASS = 0, | ||
42 | |||
43 | /** | ||
44 | * Call #GNUNET_ATS_address_add(). | ||
45 | */ | ||
46 | CMD_ADD_ADDRESS, | ||
47 | |||
48 | /** | ||
49 | * Call #GNUNET_ATS_address_del(). | ||
50 | */ | ||
51 | CMD_DEL_ADDRESS, | ||
52 | |||
53 | /** | ||
54 | * Wait for ATS to suggest address. | ||
55 | */ | ||
56 | CMD_AWAIT_ADDRESS_SUGGESTION, | ||
57 | |||
58 | /** | ||
59 | * Wait for ATS to suggest disconnect. | ||
60 | */ | ||
61 | CMD_AWAIT_DISCONNECT_SUGGESTION, | ||
62 | |||
63 | /** | ||
64 | * Ask ATS to connect to a peer, using | ||
65 | * #GNUNET_ATS_connectivity_suggest(). | ||
66 | */ | ||
67 | CMD_REQUEST_CONNECTION_START, | ||
68 | |||
69 | /** | ||
70 | * Tell ATS we no longer need a connection to a peer, using | ||
71 | * #GNUNET_ATS_connectivity_suggest_cancel(). | ||
72 | */ | ||
73 | CMD_REQUEST_CONNECTION_STOP, | ||
74 | |||
75 | /** | ||
76 | * Wait for certain address information to be provided. | ||
77 | */ | ||
78 | CMD_AWAIT_ADDRESS_INFORMATION, | ||
79 | |||
80 | /** | ||
81 | * Update properties of an address, using | ||
82 | * #GNUNET_ATS_address_update(). | ||
83 | */ | ||
84 | CMD_UPDATE_ADDRESS, | ||
85 | |||
86 | /** | ||
87 | * Add session to an address, using | ||
88 | * #GNUNET_ATS_address_add_session(). | ||
89 | */ | ||
90 | CMD_ADD_SESSION, | ||
91 | |||
92 | /** | ||
93 | * Remove session from an address, using | ||
94 | * #GNUNET_ATS_address_del_session(). | ||
95 | */ | ||
96 | CMD_DEL_SESSION, | ||
97 | |||
98 | /** | ||
99 | * Change performance preferences for a peer, testing | ||
100 | * #GNUNET_ATS_performance_change_preference(). | ||
101 | */ | ||
102 | CMD_CHANGE_PREFERENCE, | ||
103 | |||
104 | /** | ||
105 | * Provide allocation quality feedback, testing | ||
106 | * #GNUNET_ATS_performance_give_feedback(). | ||
107 | */ | ||
108 | CMD_PROVIDE_FEEDBACK, | ||
109 | |||
110 | /** | ||
111 | * Obtain list of all addresses, testing | ||
112 | * #GNUNET_ATS_performance_list_addresses(). | ||
113 | */ | ||
114 | CMD_LIST_ADDRESSES | ||
115 | |||
116 | /* TODO: reserve bandwidth */ | ||
117 | |||
118 | }; | ||
119 | |||
120 | |||
121 | /** | ||
122 | * Details for the #CMD_ADD_ADDRESS command. | ||
123 | */ | ||
124 | struct CommandAddAddress | ||
125 | { | ||
126 | /** | ||
127 | * Number of the peer (used to generate PID). | ||
128 | */ | ||
129 | unsigned int pid; | ||
130 | |||
131 | /** | ||
132 | * Number of the address (used to generate binary address). | ||
133 | */ | ||
134 | unsigned int addr_num; | ||
135 | |||
136 | /** | ||
137 | * Session to supply, 0 for NULL. | ||
138 | */ | ||
139 | unsigned int session; | ||
140 | |||
141 | /** | ||
142 | * Flags to set for the address. | ||
143 | */ | ||
144 | enum GNUNET_HELLO_AddressInfo addr_flags; | ||
145 | |||
146 | /** | ||
147 | * Performance properties to supply. | ||
148 | */ | ||
149 | struct GNUNET_ATS_Properties properties; | ||
150 | |||
151 | /** | ||
152 | * Expect the operation to fail (duplicate). | ||
153 | */ | ||
154 | int expect_fail; | ||
155 | |||
156 | /** | ||
157 | * Here the result of the add address operation will be stored. | ||
158 | */ | ||
159 | struct GNUNET_ATS_AddressRecord *ar; | ||
160 | }; | ||
161 | |||
162 | |||
163 | /** | ||
164 | * Details for the #CMD_DEL_ADDRESS command. | ||
165 | */ | ||
166 | struct CommandDelAddress | ||
167 | { | ||
168 | /** | ||
169 | * Label of the corresponding #CMD_ADD_ADDRESS that | ||
170 | * we are now to remove. | ||
171 | */ | ||
172 | const char *add_label; | ||
173 | }; | ||
174 | |||
175 | |||
176 | /** | ||
177 | * Details for the #CMD_AWAIT_ADDRESS_SUGGESTION command. | ||
178 | */ | ||
179 | struct CommandAwaitAddressSuggestion | ||
180 | { | ||
181 | /** | ||
182 | * For which peer do we expect a suggestion? | ||
183 | */ | ||
184 | unsigned int pid; | ||
185 | |||
186 | /** | ||
187 | * If we expect the address suggested to match a particular | ||
188 | * addition, specify the label of the add operation here. Otherwise | ||
189 | * use NULL for "any" available address. | ||
190 | */ | ||
191 | const char *add_label; | ||
192 | |||
193 | }; | ||
194 | |||
195 | |||
196 | /** | ||
197 | * Details for the #CMD_AWAIT_DISCONNECT_SUGGESTION command. | ||
198 | */ | ||
199 | struct CommandAwaitDisconnectSuggestion | ||
200 | { | ||
201 | /** | ||
202 | * For which peer do we expect the disconnect? | ||
203 | */ | ||
204 | unsigned int pid; | ||
205 | |||
206 | }; | ||
207 | |||
208 | |||
209 | /** | ||
210 | * Details for the #CMD_REQUEST_CONNECTION_START command. | ||
211 | */ | ||
212 | struct CommandRequestConnectionStart | ||
213 | { | ||
214 | /** | ||
215 | * Identity of the peer we would like to connect to. | ||
216 | */ | ||
217 | unsigned int pid; | ||
218 | |||
219 | /** | ||
220 | * Location where we store the handle returned from | ||
221 | * #GNUNET_ATS_connectivity_suggest(). | ||
222 | */ | ||
223 | struct GNUNET_ATS_ConnectivitySuggestHandle *csh; | ||
224 | }; | ||
225 | |||
226 | |||
227 | /** | ||
228 | * Details for the #CMD_REQUEST_CONNECTION_STOP command. | ||
229 | */ | ||
230 | struct CommandRequestConnectionStop | ||
231 | { | ||
232 | /** | ||
233 | * Label of the corresponding #CMD_REQUEST_CONNECTION_START that | ||
234 | * we are now stopping. | ||
235 | */ | ||
236 | const char *connect_label; | ||
237 | }; | ||
238 | |||
239 | |||
240 | /** | ||
241 | * Details for the #CMD_AWAIT_ADDRESS_INFORMATION command. | ||
242 | */ | ||
243 | struct CommandAwaitAddressInformation | ||
244 | { | ||
245 | /** | ||
246 | * For which address do we expect information? | ||
247 | * The address is identified by the respective | ||
248 | * label of the corresponding add operation. | ||
249 | */ | ||
250 | const char *add_label; | ||
251 | |||
252 | /** | ||
253 | * Label of a possible update operation that may | ||
254 | * have modified the properties. NULL to use | ||
255 | * the properties from the @e add_label. | ||
256 | */ | ||
257 | const char *update_label; | ||
258 | |||
259 | }; | ||
260 | |||
261 | |||
262 | /** | ||
263 | * Details for the #CMD_UPDATE_ADDRESS command. | ||
264 | */ | ||
265 | struct CommandUpdateAddress | ||
266 | { | ||
267 | /** | ||
268 | * Label of the addresses's add operation. | ||
269 | */ | ||
270 | const char *add_label; | ||
271 | |||
272 | /** | ||
273 | * Performance properties to supply. | ||
274 | */ | ||
275 | struct GNUNET_ATS_Properties properties; | ||
276 | |||
277 | }; | ||
278 | |||
279 | |||
280 | /** | ||
281 | * Details for the #CMD_ADD_SESSION command. | ||
282 | */ | ||
283 | struct CommandAddSession | ||
284 | { | ||
285 | /** | ||
286 | * Label of the addresses's add operation. | ||
287 | */ | ||
288 | const char *add_label; | ||
289 | |||
290 | /** | ||
291 | * Session to supply. | ||
292 | */ | ||
293 | unsigned int session; | ||
294 | |||
295 | }; | ||
296 | |||
297 | |||
298 | /** | ||
299 | * Details for the #CMD_DEL_SESSION command. | ||
300 | */ | ||
301 | struct CommandDelSession | ||
302 | { | ||
303 | /** | ||
304 | * Label of the addresses's add operation. | ||
305 | */ | ||
306 | const char *add_session_label; | ||
307 | |||
308 | }; | ||
309 | |||
310 | |||
311 | /** | ||
312 | * Details for the #CMD_CHANGE_PREFERENCE command. | ||
313 | */ | ||
314 | struct CommandChangePreference | ||
315 | { | ||
316 | /** | ||
317 | * Identity of the peer we have a preference change towards. | ||
318 | */ | ||
319 | unsigned int pid; | ||
320 | |||
321 | /* FIXME: preference details! */ | ||
322 | |||
323 | }; | ||
324 | |||
325 | |||
326 | /** | ||
327 | * Details for the #CMD_PROVIDE_FEEDBACK command. | ||
328 | */ | ||
329 | struct CommandProvideFeedback | ||
330 | { | ||
331 | /** | ||
332 | * Identity of the peer we have a feedback for. | ||
333 | */ | ||
334 | unsigned int pid; | ||
335 | |||
336 | /** | ||
337 | * Over which timeframe does the feedback apply? | ||
338 | */ | ||
339 | struct GNUNET_TIME_Relative scope; | ||
340 | |||
341 | /* FIXME: feedback details! */ | ||
342 | }; | ||
343 | |||
344 | |||
345 | /** | ||
346 | * Details for the #CMD_LIST_ADDRESSES command. | ||
347 | */ | ||
348 | struct CommandListAddresses | ||
349 | { | ||
350 | /** | ||
351 | * Identity of the peer we want a list for. | ||
352 | */ | ||
353 | unsigned int pid; | ||
354 | |||
355 | /** | ||
356 | * All addresses or just active? | ||
357 | */ | ||
358 | int all; | ||
359 | |||
360 | /** | ||
361 | * Minimum number of addresses the callback may report. | ||
362 | */ | ||
363 | unsigned int min_calls; | ||
364 | |||
365 | /** | ||
366 | * Maximum number of addresses the callback may report. | ||
367 | */ | ||
368 | unsigned int max_calls; | ||
369 | |||
370 | /** | ||
371 | * Minimum number of active addresses the callback may report. | ||
372 | */ | ||
373 | unsigned int min_active_calls; | ||
374 | |||
375 | /** | ||
376 | * Maximum number of active addresses the callback may report. | ||
377 | */ | ||
378 | unsigned int max_active_calls; | ||
379 | |||
380 | /** | ||
381 | * Number of calls the command invoked the callback with | ||
382 | * an address marked as active. (Set by command). | ||
383 | */ | ||
384 | unsigned int active_calls; | ||
385 | |||
386 | /** | ||
387 | * Number of calls the command invoked the callback with | ||
388 | * any address marked as available to ATS. (Set by command). | ||
389 | */ | ||
390 | unsigned int calls; | ||
391 | |||
392 | /** | ||
393 | * Location where we store the return value from | ||
394 | * #GNUNET_ATS_performance_list_addresses(). | ||
395 | */ | ||
396 | struct GNUNET_ATS_AddressListHandle *alh; | ||
397 | |||
398 | }; | ||
399 | |||
400 | |||
401 | /** | ||
402 | * A command for the test case interpreter. | ||
403 | */ | ||
404 | struct Command | ||
405 | { | ||
406 | /** | ||
407 | * Command code to run. | ||
408 | */ | ||
409 | enum CommandCode code; | ||
410 | |||
411 | /** | ||
412 | * Commands can be given a label so we can reference them later. | ||
413 | */ | ||
414 | const char *label; | ||
415 | |||
416 | /** | ||
417 | * Additional arguments to commands, if any. | ||
418 | */ | ||
419 | union { | ||
420 | |||
421 | struct CommandAddAddress add_address; | ||
422 | |||
423 | struct CommandDelAddress del_address; | ||
424 | |||
425 | struct CommandAwaitAddressSuggestion await_address_suggestion; | ||
426 | |||
427 | struct CommandAwaitDisconnectSuggestion await_disconnect_suggestion; | ||
428 | |||
429 | struct CommandRequestConnectionStart request_connection_start; | ||
430 | |||
431 | struct CommandRequestConnectionStop request_connection_stop; | ||
432 | |||
433 | struct CommandAwaitAddressInformation await_address_information; | ||
434 | |||
435 | struct CommandUpdateAddress update_address; | ||
436 | |||
437 | struct CommandAddSession add_session; | ||
438 | |||
439 | struct CommandDelSession del_session; | ||
440 | |||
441 | struct CommandChangePreference change_preference; | ||
442 | |||
443 | struct CommandProvideFeedback provide_feedback; | ||
444 | |||
445 | struct CommandListAddresses list_addresses; | ||
446 | |||
447 | } details; | ||
448 | |||
449 | }; | ||
450 | |||
451 | |||
452 | /** | ||
453 | * Run ATS test. | ||
454 | * | ||
455 | * @param argc length of @a argv | ||
456 | * @param argv command line | ||
457 | * @param cmds commands to run with the interpreter | ||
458 | * @param timeout how long is the test allowed to take? | ||
459 | * @return 0 on success | ||
460 | */ | ||
461 | int | ||
462 | TEST_ATS_run (int argc, | ||
463 | char *argv[], | ||
464 | struct Command *cmds, | ||
465 | struct GNUNET_TIME_Relative timeout); | ||
466 | |||
467 | #endif | ||