aboutsummaryrefslogtreecommitdiff
path: root/src/ats/test_ats_api.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-11 16:17:20 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-11 16:17:20 +0000
commit8af9412585b17289e8fa5ca905eaa33415927dc3 (patch)
treef4cc0ed3a8b745a04832157a173a9eefc8f28e89 /src/ats/test_ats_api.c
parent567ca9a20a7afe3573cb1c11ad89c116a0650fe7 (diff)
downloadgnunet-8af9412585b17289e8fa5ca905eaa33415927dc3.tar.gz
gnunet-8af9412585b17289e8fa5ca905eaa33415927dc3.zip
new testsuite, obsoleting (most of) the old one
Diffstat (limited to 'src/ats/test_ats_api.c')
-rw-r--r--src/ats/test_ats_api.c243
1 files changed, 243 insertions, 0 deletions
diff --git a/src/ats/test_ats_api.c b/src/ats/test_ats_api.c
new file mode 100644
index 000000000..97fdd65c1
--- /dev/null
+++ b/src/ats/test_ats_api.c
@@ -0,0 +1,243 @@
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_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 */
36static 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 .session = 0,
44 .properties = {
45 .scope = GNUNET_ATS_NET_LAN
46 }
47 }
48 },
49 /* adding same address again should fail */
50 {
51 .code = CMD_ADD_ADDRESS,
52 .label = "add-address-0-0:FAIL",
53 .details.add_address = {
54 .pid = 0,
55 .addr_num = 0,
56 .session = 0,
57 .properties = {
58 .scope = GNUNET_ATS_NET_LAN
59 },
60 .expect_fail = 1
61 }
62 },
63 /* some solver still require explicit start */
64 {
65 .code = CMD_REQUEST_CONNECTION_START,
66 .label = "request-0",
67 .details.request_connection_start = {
68 .pid = 0
69 }
70 },
71 /* check we got an address */
72 {
73 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
74 .details.await_address_suggestion = {
75 .add_label = "add-address-0-0"
76 }
77 },
78 /* check monitor also got the address */
79 {
80 .code = CMD_AWAIT_ADDRESS_INFORMATION,
81 .details.await_address_information = {
82 .add_label = "add-address-0-0"
83 }
84 },
85 /* test session API */
86 {
87 .code = CMD_ADD_SESSION,
88 .label = "add-session-0-0-1",
89 .details.add_session = {
90 .add_label ="add-address-0-0",
91 .session = 1
92 }
93 },
94 {
95 .code = CMD_DEL_SESSION,
96 .details.del_session = {
97 .add_session_label = "add-session-0-0-1",
98 }
99 },
100 /* test preference API */
101 {
102 .code = CMD_CHANGE_PREFERENCE,
103 .details.change_preference = {
104 .pid = 0
105 /* FIXME: preference details */
106 }
107 },
108 {
109 .code = CMD_PROVIDE_FEEDBACK,
110 .details.provide_feedback = {
111 .pid = 0,
112 .scope = { 50LL }
113 /* FIXME: preference details */
114 }
115 },
116 /* test sanity check address listing */
117 {
118 .code = CMD_LIST_ADDRESSES,
119 .details.list_addresses = {
120 .pid = 0,
121 .all = 1,
122 .min_calls = 2, // ?
123 .max_calls = 2,
124 .min_active_calls = 1,
125 .max_active_calls = 1
126 }
127 },
128 /* remove address testing */
129 {
130 .code = CMD_DEL_ADDRESS,
131 .details.del_address = {
132 .add_label = "add-address-0-0"
133 }
134 },
135 /* check we got disconnected */
136 {
137 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
138 .details.await_disconnect_suggestion = {
139 .pid = 0
140 }
141 },
142 /* just for symmetry, also stop asking for the connection */
143 {
144 .code = CMD_REQUEST_CONNECTION_STOP,
145 .details.request_connection_stop = {
146 .connect_label = "request-0",
147 }
148 },
149 /* add address again */
150 {
151 .code = CMD_ADD_ADDRESS,
152 .label = "add-address-0-0:1",
153 .details.add_address = {
154 .pid = 0,
155 .addr_num = 0,
156 .session = 0,
157 .properties = {
158 .scope = GNUNET_ATS_NET_LAN
159 }
160 }
161 },
162 /* some solver still require explicit start */
163 {
164 .code = CMD_REQUEST_CONNECTION_START,
165 .label = "request-0",
166 .details.request_connection_start = {
167 .pid = 0
168 }
169 },
170 /* check we got an address */
171 {
172 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
173 .details.await_address_suggestion = {
174 .add_label = "add-address-0-0:1"
175 }
176 },
177 /* add alternative address */
178 {
179 .code = CMD_ADD_ADDRESS,
180 .label = "add-address-0-1",
181 .details.add_address = {
182 .pid = 0,
183 .addr_num = 1,
184 .session = 0,
185 .properties = {
186 .scope = GNUNET_ATS_NET_LAN
187 }
188 }
189 },
190 /* remove original address */
191 {
192 .code = CMD_DEL_ADDRESS,
193 .details.del_address = {
194 .add_label = "add-address-0-0:1"
195 }
196 },
197 /* check we switched to alternative address */
198 {
199 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
200 .details.await_address_suggestion = {
201 .add_label = "add-address-0-1"
202 }
203 },
204 /* remove alternative address */
205 {
206 .code = CMD_DEL_ADDRESS,
207 .details.del_address = {
208 .add_label = "add-address-0-1"
209 }
210 },
211 /* check we got disconnected */
212 {
213 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
214 .details.await_disconnect_suggestion = {
215 .pid = 0
216 }
217 },
218 /* just for symmetry, also stop asking for the connection */
219 {
220 .code = CMD_REQUEST_CONNECTION_STOP,
221 .details.request_connection_stop = {
222 .connect_label = "request-0",
223 }
224 },
225 /* Test ends successfully */
226 {
227 .code = CMD_END_PASS
228 }
229};
230
231
232int
233main (int argc,
234 char *argv[])
235{
236 return TEST_ATS_run (argc,
237 argv,
238 test_commands,
239 TIMEOUT);
240}
241
242
243/* end of file test_ats_api.c */