use NULL value in load_path_suffix to NOT load any files
[oweals/gnunet.git] / src / ats / test_ats_api.c
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      SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 /**
21  * @file ats/test_ats_api.c
22  * @brief test ATS
23  * @author Christian Grothoff
24  */
25 #include "platform.h"
26 #include "test_ats_lib.h"
27
28 /**
29  * Global timeout for the testcase.
30  */
31 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
32
33 /**
34  * Definition of the test as a sequence of commands.
35  */
36 static struct Command test_commands[] = {
37   {
38     .code = CMD_ADD_ADDRESS,
39     .label = "add-address-0-0",
40     .details.add_address = {
41       .pid = 0,
42       .addr_num = 0,
43       .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
44       .session = 0,
45       .properties = {
46         .scope = GNUNET_NT_LAN
47       }
48
49
50     }
51
52
53   },
54   /* 1: adding same address again should fail */
55   {
56     .code = CMD_ADD_ADDRESS,
57     .label = "add-address-0-0:FAIL",
58     .details.add_address = {
59       .pid = 0,
60       .addr_num = 0,
61       .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
62       .session = 0,
63       .properties = {
64         .scope = GNUNET_NT_LAN
65       },
66       .expect_fail = 1
67     }
68
69
70   },
71   /* 2: some solver still require explicit start */
72   {
73     .code = CMD_REQUEST_CONNECTION_START,
74     .label = "request-0",
75     .details.request_connection_start = {
76       .pid = 0
77     }
78
79
80   },
81   /* 3: check we got an address */
82   {
83     .code = CMD_AWAIT_ADDRESS_SUGGESTION,
84     .details.await_address_suggestion = {
85       .add_label = "add-address-0-0"
86     }
87
88
89   },
90   /* 4: check monitor also got the address */
91   {
92     .code = CMD_AWAIT_ADDRESS_INFORMATION,
93     .details.await_address_information = {
94       .add_label = "add-address-0-0"
95     }
96
97
98   },
99   /* 5: test session API */
100   {
101     .code = CMD_ADD_SESSION,
102     .label = "add-session-0-0-1",
103     .details.add_session = {
104       .add_label = "add-address-0-0",
105       .session = 1
106     }
107
108
109   },
110   {
111     .code = CMD_DEL_SESSION,
112     .details.del_session = {
113       .add_session_label = "add-session-0-0-1",
114     }
115
116
117   },
118   /* 7: test preference API */
119   {
120     .code = CMD_CHANGE_PREFERENCE,
121     .details.change_preference = {
122       .pid = 0
123              /* FIXME: preference details */
124     }
125
126
127   },
128   {
129     .code = CMD_PROVIDE_FEEDBACK,
130     .details.provide_feedback = {
131       .pid = 0,
132       .scope = { 50LL }
133       /* FIXME: preference details */
134     }
135
136
137   },
138   /* 9: test sanity check address listing */
139   {
140     .code = CMD_LIST_ADDRESSES,
141     .details.list_addresses = {
142       .pid = 0,
143       .all = 1,
144       .min_calls = 2, // ?
145       .max_calls = 2,
146       .min_active_calls = 1,
147       .max_active_calls = 1
148     }
149
150
151   },
152   /* 10: remove address testing */
153   {
154     .code = CMD_DEL_ADDRESS,
155     .details.del_address = {
156       .add_label = "add-address-0-0"
157     }
158
159
160   },
161   /* 11: check we got disconnected */
162   {
163     .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
164     .details.await_disconnect_suggestion = {
165       .pid = 0
166     }
167
168
169   },
170   /* 12: just for symmetry, also stop asking for the connection */
171   {
172     .code = CMD_REQUEST_CONNECTION_STOP,
173     .details.request_connection_stop = {
174       .connect_label = "request-0",
175     }
176
177
178   },
179   /* 13: add address again */
180   {
181     .code = CMD_ADD_ADDRESS,
182     .label = "add-address-0-0:1",
183     .details.add_address = {
184       .pid = 0,
185       .addr_num = 0,
186       .session = 0,
187       .properties = {
188         .scope = GNUNET_NT_LAN
189       }
190
191
192     }
193
194
195   },
196   /* 14: some solver still require explicit start */
197   {
198     .code = CMD_REQUEST_CONNECTION_START,
199     .label = "request-0",
200     .details.request_connection_start = {
201       .pid = 0
202     }
203
204
205   },
206   /* 15: check we got an address */
207   {
208     .code = CMD_AWAIT_ADDRESS_SUGGESTION,
209     .details.await_address_suggestion = {
210       .add_label = "add-address-0-0:1"
211     }
212
213
214   },
215   /* 16: add alternative address */
216   {
217     .code = CMD_ADD_ADDRESS,
218     .label = "add-address-0-1",
219     .details.add_address = {
220       .pid = 0,
221       .addr_num = 1,
222       .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
223       .session = 0,
224       .properties = {
225         .scope = GNUNET_NT_LAN
226       }
227
228
229     }
230
231
232   },
233   /* 17: remove original address */
234   {
235     .code = CMD_DEL_ADDRESS,
236     .details.del_address = {
237       .add_label = "add-address-0-0:1"
238     }
239
240
241   },
242   /* 18: check we switched to alternative address */
243   {
244     .code = CMD_AWAIT_ADDRESS_SUGGESTION,
245     .details.await_address_suggestion = {
246       .add_label = "add-address-0-1"
247     }
248
249
250   },
251   /* 19: remove alternative address */
252   {
253     .code = CMD_DEL_ADDRESS,
254     .details.del_address = {
255       .add_label = "add-address-0-1"
256     }
257
258
259   },
260   /* 20: check we got disconnected */
261   {
262     .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
263     .details.await_disconnect_suggestion = {
264       .pid = 0
265     }
266
267
268   },
269   /* 21: just for symmetry, also stop asking for the connection */
270   {
271     .code = CMD_REQUEST_CONNECTION_STOP,
272     .details.request_connection_stop = {
273       .connect_label = "request-0",
274     }
275
276
277   },
278   /* Test ends successfully */
279   {
280     .code = CMD_END_PASS
281   }
282 };
283
284
285 int
286 main (int argc,
287       char *argv[])
288 {
289   return TEST_ATS_run (argc,
290                        argv,
291                        test_commands,
292                        TIMEOUT);
293 }
294
295
296 /* end of file test_ats_api.c */