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 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.
16 * @file ats/test_ats_api.c
18 * @author Christian Grothoff
21 #include "test_ats_lib.h"
24 * Global timeout for the testcase.
26 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3)
29 * Definition of the test as a sequence of commands.
31 static struct Command test_commands[] = {
33 .code = CMD_ADD_ADDRESS,
34 .label = "add-address-0-0",
35 .details.add_address = {
38 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
41 .scope = GNUNET_ATS_NET_LAN
45 /* 1: adding same address again should fail */
47 .code = CMD_ADD_ADDRESS,
48 .label = "add-address-0-0:FAIL",
49 .details.add_address = {
52 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
55 .scope = GNUNET_ATS_NET_LAN
60 /* 2: some solver still require explicit start */
62 .code = CMD_REQUEST_CONNECTION_START,
64 .details.request_connection_start = {
68 /* 3: check we got an address */
70 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
71 .details.await_address_suggestion = {
72 .add_label = "add-address-0-0"
75 /* 4: check monitor also got the address */
77 .code = CMD_AWAIT_ADDRESS_INFORMATION,
78 .details.await_address_information = {
79 .add_label = "add-address-0-0"
82 /* 5: test session API */
84 .code = CMD_ADD_SESSION,
85 .label = "add-session-0-0-1",
86 .details.add_session = {
87 .add_label ="add-address-0-0",
92 .code = CMD_DEL_SESSION,
93 .details.del_session = {
94 .add_session_label = "add-session-0-0-1",
97 /* 7: test preference API */
99 .code = CMD_CHANGE_PREFERENCE,
100 .details.change_preference = {
102 /* FIXME: preference details */
106 .code = CMD_PROVIDE_FEEDBACK,
107 .details.provide_feedback = {
110 /* FIXME: preference details */
113 /* 9: test sanity check address listing */
115 .code = CMD_LIST_ADDRESSES,
116 .details.list_addresses = {
121 .min_active_calls = 1,
122 .max_active_calls = 1
125 /* 10: remove address testing */
127 .code = CMD_DEL_ADDRESS,
128 .details.del_address = {
129 .add_label = "add-address-0-0"
132 /* 11: check we got disconnected */
134 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
135 .details.await_disconnect_suggestion = {
139 /* 12: just for symmetry, also stop asking for the connection */
141 .code = CMD_REQUEST_CONNECTION_STOP,
142 .details.request_connection_stop = {
143 .connect_label = "request-0",
146 /* 13: add address again */
148 .code = CMD_ADD_ADDRESS,
149 .label = "add-address-0-0:1",
150 .details.add_address = {
155 .scope = GNUNET_ATS_NET_LAN
159 /* 14: some solver still require explicit start */
161 .code = CMD_REQUEST_CONNECTION_START,
162 .label = "request-0",
163 .details.request_connection_start = {
167 /* 15: check we got an address */
169 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
170 .details.await_address_suggestion = {
171 .add_label = "add-address-0-0:1"
174 /* 16: add alternative address */
176 .code = CMD_ADD_ADDRESS,
177 .label = "add-address-0-1",
178 .details.add_address = {
181 .addr_flags = GNUNET_HELLO_ADDRESS_INFO_NONE,
184 .scope = GNUNET_ATS_NET_LAN
188 /* 17: remove original address */
190 .code = CMD_DEL_ADDRESS,
191 .details.del_address = {
192 .add_label = "add-address-0-0:1"
195 /* 18: check we switched to alternative address */
197 .code = CMD_AWAIT_ADDRESS_SUGGESTION,
198 .details.await_address_suggestion = {
199 .add_label = "add-address-0-1"
202 /* 19: remove alternative address */
204 .code = CMD_DEL_ADDRESS,
205 .details.del_address = {
206 .add_label = "add-address-0-1"
209 /* 20: check we got disconnected */
211 .code = CMD_AWAIT_DISCONNECT_SUGGESTION,
212 .details.await_disconnect_suggestion = {
216 /* 21: just for symmetry, also stop asking for the connection */
218 .code = CMD_REQUEST_CONNECTION_STOP,
219 .details.request_connection_stop = {
220 .connect_label = "request-0",
223 /* Test ends successfully */
234 return TEST_ATS_run (argc,
241 /* end of file test_ats_api.c */