2 This file is part of GNUnet.
3 Copyright (C) 2010-2015 GNUnet e.V.
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.
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.
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/>.
19 * @file ats/test_ats_lib.h
20 * @brief test ATS library with a generic interpreter for running ATS tests
21 * @author Christian Grothoff
23 #ifndef TEST_ATS_LIB_H
24 #define TEST_ATS_LIB_H
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"
33 // * Commands for the interpreter.
38 // * End the test (passing).
43 // * Call #GNUNET_ATS_address_add().
48 // * Call #GNUNET_ATS_address_del().
53 // * Wait for ATS to suggest address.
55 // CMD_AWAIT_ADDRESS_SUGGESTION,
58 // * Wait for ATS to suggest disconnect.
60 // CMD_AWAIT_DISCONNECT_SUGGESTION,
63 // * Ask ATS to connect to a peer, using
64 // * #GNUNET_ATS_connectivity_suggest().
66 // CMD_REQUEST_CONNECTION_START,
69 // * Tell ATS we no longer need a connection to a peer, using
70 // * #GNUNET_ATS_connectivity_suggest_cancel().
72 // CMD_REQUEST_CONNECTION_STOP,
75 // * Wait for certain address information to be provided.
77 // CMD_AWAIT_ADDRESS_INFORMATION,
80 // * Update properties of an address, using
81 // * #GNUNET_ATS_address_update().
83 // CMD_UPDATE_ADDRESS,
86 // * Add session to an address, using
87 // * #GNUNET_ATS_address_add_session().
92 // * Remove session from an address, using
93 // * #GNUNET_ATS_address_del_session().
98 // * Change performance preferences for a peer, testing
99 // * #GNUNET_ATS_performance_change_preference().
101 // CMD_CHANGE_PREFERENCE,
104 // * Provide allocation quality feedback, testing
105 // * #GNUNET_ATS_performance_give_feedback().
107 // CMD_PROVIDE_FEEDBACK,
110 // * Obtain list of all addresses, testing
111 // * #GNUNET_ATS_performance_list_addresses().
113 // CMD_LIST_ADDRESSES,
116 // * Reserve bandwidth, testing
117 // * #GNUNET_ATS_reserve_bandwidth().
119 // CMD_RESERVE_BANDWIDTH,
130 // * Details for the #CMD_ADD_ADDRESS command.
132 //struct CommandAddAddress
135 // * Number of the peer (used to generate PID).
140 // * Number of the address (used to generate binary address).
142 // unsigned int addr_num;
145 // * Session to supply, 0 for NULL.
147 // unsigned int session;
150 // * Flags to set for the address.
152 // enum GNUNET_HELLO_AddressInfo addr_flags;
155 // * Performance properties to supply.
157 // struct GNUNET_ATS_Properties properties;
160 // * Expect the operation to fail (duplicate).
165 // * Here the result of the add address operation will be stored.
167 // struct GNUNET_ATS_AddressRecord *ar;
172 // * Details for the #CMD_DEL_ADDRESS command.
174 //struct CommandDelAddress
177 // * Label of the corresponding #CMD_ADD_ADDRESS that
178 // * we are now to remove.
180 // const char *add_label;
185 // * Details for the #CMD_AWAIT_ADDRESS_SUGGESTION command.
187 //struct CommandAwaitAddressSuggestion
190 // * For which peer do we expect a suggestion?
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.
199 // const char *add_label;
205 // * Details for the #CMD_AWAIT_DISCONNECT_SUGGESTION command.
207 //struct CommandAwaitDisconnectSuggestion
210 // * For which peer do we expect the disconnect?
218 // * Details for the #CMD_REQUEST_CONNECTION_START command.
220 //struct CommandRequestConnectionStart
223 // * Identity of the peer we would like to connect to.
228 // * Location where we store the handle returned from
229 // * #GNUNET_ATS_connectivity_suggest().
231 // struct GNUNET_ATS_ConnectivitySuggestHandle *csh;
236 // * Details for the #CMD_REQUEST_CONNECTION_STOP command.
238 //struct CommandRequestConnectionStop
241 // * Label of the corresponding #CMD_REQUEST_CONNECTION_START that
242 // * we are now stopping.
244 // const char *connect_label;
249 // * Details for the #CMD_AWAIT_ADDRESS_INFORMATION command.
251 //struct CommandAwaitAddressInformation
254 // * For which address do we expect information?
255 // * The address is identified by the respective
256 // * label of the corresponding add operation.
258 // const char *add_label;
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.
265 // const char *update_label;
271 // * Details for the #CMD_UPDATE_ADDRESS command.
273 //struct CommandUpdateAddress
276 // * Label of the addresses's add operation.
278 // const char *add_label;
281 // * Performance properties to supply.
283 // struct GNUNET_ATS_Properties properties;
289 // * Details for the #CMD_ADD_SESSION command.
291 //struct CommandAddSession
294 // * Label of the addresses's add operation.
296 // const char *add_label;
299 // * Session to supply.
301 // unsigned int session;
307 // * Details for the #CMD_DEL_SESSION command.
309 //struct CommandDelSession
312 // * Label of the addresses's add operation.
314 // const char *add_session_label;
320 // * Details for the #CMD_CHANGE_PREFERENCE command.
322 //struct CommandChangePreference
325 // * Identity of the peer we have a preference change towards.
329 // /* FIXME: preference details! */
335 // * Details for the #CMD_PROVIDE_FEEDBACK command.
337 //struct CommandProvideFeedback
340 // * Identity of the peer we have a feedback for.
345 // * Over which timeframe does the feedback apply?
347 // struct GNUNET_TIME_Relative scope;
349 // /* FIXME: feedback details! */
354 // * Details for the #CMD_LIST_ADDRESSES command.
356 //struct CommandListAddresses
359 // * Identity of the peer we want a list for.
364 // * All addresses or just active?
369 // * Minimum number of addresses the callback may report.
371 // unsigned int min_calls;
374 // * Maximum number of addresses the callback may report.
376 // unsigned int max_calls;
379 // * Minimum number of active addresses the callback may report.
381 // unsigned int min_active_calls;
384 // * Maximum number of active addresses the callback may report.
386 // unsigned int max_active_calls;
389 // * Number of calls the command invoked the callback with
390 // * an address marked as active. (Set by command).
392 // unsigned int active_calls;
395 // * Number of calls the command invoked the callback with
396 // * any address marked as available to ATS. (Set by command).
398 // unsigned int calls;
401 // * Location where we store the return value from
402 // * #GNUNET_ATS_performance_list_addresses().
404 // struct GNUNET_ATS_AddressListHandle *alh;
410 // * Details for the #CMD_RESERVE_BANDWIDTH command.
412 //struct CommandReserveBandwidth
415 // * For which peer do we reserve bandwidth?
420 // * How much should we try to reserve?
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
430 // int expected_result;
433 // * Location where we store the return value from
434 // * #GNUNET_ATS_reserve_bandwidth().
436 // struct GNUNET_ATS_ReservationContext *rc;
442 // * Details for the #CMD_SLEEP command.
444 //struct CommandSleep
447 // * How long should we wait before running the next command?
449 // struct GNUNET_TIME_Relative delay;
454 // * A command for the test case interpreter.
459 // * Command code to run.
461 // enum CommandCode code;
464 // * Commands can be given a label so we can reference them later.
466 // const char *label;
469 // * Additional arguments to commands, if any.
473 // struct CommandAddAddress add_address;
475 // struct CommandDelAddress del_address;
477 // struct CommandAwaitAddressSuggestion await_address_suggestion;
479 // struct CommandAwaitDisconnectSuggestion await_disconnect_suggestion;
481 // struct CommandRequestConnectionStart request_connection_start;
483 // struct CommandRequestConnectionStop request_connection_stop;
485 // struct CommandAwaitAddressInformation await_address_information;
487 // struct CommandUpdateAddress update_address;
489 // struct CommandAddSession add_session;
491 // struct CommandDelSession del_session;
493 // struct CommandChangePreference change_preference;
495 // struct CommandProvideFeedback provide_feedback;
497 // struct CommandListAddresses list_addresses;
499 // struct CommandReserveBandwidth reserve_bandwidth;
501 // struct CommandSleep sleep;
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
518 TEST_ATS_run (int argc,
520 struct Command *cmds,
521 struct GNUNET_TIME_Relative timeout);