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