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
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.
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.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
21 * @file ats/test_ats_api.c
23 * @author Christian Grothoff
26 #include "test_ats_lib.h"
29 * Global timeout for the testcase.
31 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
34 * Definition of the test as a sequence of commands.
36 static struct Command test_commands[] = {
38 .code = CMD_ADD_ADDRESS,
39 .label = "add-address-0-0",
40 .details.add_address = {
43 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
46 .scope = GNUNET_ATS_NET_LAN
50 /* 1: adding same address again should fail */
52 .code = CMD_ADD_ADDRESS,
53 .label = "add-address-0-0:FAIL",
54 .details.add_address = {
57 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
60 .scope = GNUNET_ATS_NET_LAN
65 /* 2: some solver still require explicit start */
67 .code = CMD_REQUEST_CONNECTION_START,
69 .details.request_connection_start = {
73 /* 3: check we got an address */
75 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
76 .details.await_address_suggestion = {
77 .add_label = "add-address-0-0"
80 /* 4: check monitor also got the address */
82 .code = CMD_AWAIT_ADDRESS_INFORMATION,
83 .details.await_address_information = {
84 .add_label = "add-address-0-0"
87 /* 5: test session API */
89 .code = CMD_ADD_SESSION,
90 .label = "add-session-0-0-1",
91 .details.add_session = {
92 .add_label ="add-address-0-0",
97 .code = CMD_DEL_SESSION,
98 .details.del_session = {
99 .add_session_label = "add-session-0-0-1",
102 /* 7: test preference API */
104 .code = CMD_CHANGE_PREFERENCE,
105 .details.change_preference = {
107 /* FIXME: preference details */
111 .code = CMD_PROVIDE_FEEDBACK,
112 .details.provide_feedback = {
115 /* FIXME: preference details */
118 /* 9: test sanity check address listing */
120 .code = CMD_LIST_ADDRESSES,
121 .details.list_addresses = {
126 .min_active_calls = 1,
127 .max_active_calls = 1
130 /* 10: remove address testing */
132 .code = CMD_DEL_ADDRESS,
133 .details.del_address = {
134 .add_label = "add-address-0-0"
137 /* 11: check we got disconnected */
139 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
140 .details.await_disconnect_suggestion = {
144 /* 12: just for symmetry, also stop asking for the connection */
146 .code = CMD_REQUEST_CONNECTION_STOP,
147 .details.request_connection_stop = {
148 .connect_label = "request-0",
151 /* 13: add address again */
153 .code = CMD_ADD_ADDRESS,
154 .label = "add-address-0-0:1",
155 .details.add_address = {
160 .scope = GNUNET_ATS_NET_LAN
164 /* 14: some solver still require explicit start */
166 .code = CMD_REQUEST_CONNECTION_START,
167 .label = "request-0",
168 .details.request_connection_start = {
172 /* 15: check we got an address */
174 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
175 .details.await_address_suggestion = {
176 .add_label = "add-address-0-0:1"
179 /* 16: add alternative address */
181 .code = CMD_ADD_ADDRESS,
182 .label = "add-address-0-1",
183 .details.add_address = {
186 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
189 .scope = GNUNET_ATS_NET_LAN
193 /* 17: remove original address */
195 .code = CMD_DEL_ADDRESS,
196 .details.del_address = {
197 .add_label = "add-address-0-0:1"
200 /* 18: check we switched to alternative address */
202 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
203 .details.await_address_suggestion = {
204 .add_label = "add-address-0-1"
207 /* 19: remove alternative address */
209 .code = CMD_DEL_ADDRESS,
210 .details.del_address = {
211 .add_label = "add-address-0-1"
214 /* 20: check we got disconnected */
216 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
217 .details.await_disconnect_suggestion = {
221 /* 21: just for symmetry, also stop asking for the connection */
223 .code = CMD_REQUEST_CONNECTION_STOP,
224 .details.request_connection_stop = {
225 .connect_label = "request-0",
228 /* Test ends successfully */
239 return TEST_ATS_run (argc,
246 /* end of file test_ats_api.c */