aboutsummaryrefslogtreecommitdiff
path: root/src/ats/test_ats2_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/test_ats2_lib.c')
-rw-r--r--src/ats/test_ats2_lib.c140
1 files changed, 70 insertions, 70 deletions
diff --git a/src/ats/test_ats2_lib.c b/src/ats/test_ats2_lib.c
index 2c6dafa1a..1b9f0e234 100644
--- a/src/ats/test_ats2_lib.c
+++ b/src/ats/test_ats2_lib.c
@@ -14,7 +14,7 @@
14 14
15 You should have received a copy of the GNU Affero General Public License 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/>. 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/ 17 */
18/** 18/**
19 * @file ats/test_ats2_lib.c 19 * @file ats/test_ats2_lib.c
20 * @brief test ATS library with a generic interpreter for running ATS tests 20 * @brief test ATS library with a generic interpreter for running ATS tests
@@ -76,13 +76,13 @@ static struct GNUNET_ATS_SessionRecord *sr;
76 * @return 76 * @return
77 */ 77 */
78static void 78static void
79allocation_cb (void *cls, 79allocation_cb(void *cls,
80 struct GNUNET_ATS_Session *session, 80 struct GNUNET_ATS_Session *session,
81 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, 81 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
82 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in) 82 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
83{ 83{
84 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 84 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
85 "allocation_cb() called\n"); 85 "allocation_cb() called\n");
86} 86}
87 87
88 88
@@ -96,12 +96,12 @@ allocation_cb (void *cls,
96 * @param address 96 * @param address
97 */ 97 */
98static void 98static void
99suggestion_cb (void *cls, 99suggestion_cb(void *cls,
100 const struct GNUNET_PeerIdentity *pid, 100 const struct GNUNET_PeerIdentity *pid,
101 const char *address) 101 const char *address)
102{ 102{
103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 103 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
104 "suggestion_cb() called\n"); 104 "suggestion_cb() called\n");
105 ret = 0; 105 ret = 0;
106} 106}
107 107
@@ -112,16 +112,16 @@ suggestion_cb (void *cls,
112 * Initialises the application and transportation side of ATS. 112 * Initialises the application and transportation side of ATS.
113 */ 113 */
114static void 114static void
115init_both (const struct GNUNET_CONFIGURATION_Handle *cfg) 115init_both(const struct GNUNET_CONFIGURATION_Handle *cfg)
116{ 116{
117 ah = GNUNET_ATS_application_init (cfg); 117 ah = GNUNET_ATS_application_init(cfg);
118 GNUNET_assert (NULL != ah); 118 GNUNET_assert(NULL != ah);
119 th = GNUNET_ATS_transport_init (cfg, 119 th = GNUNET_ATS_transport_init(cfg,
120 &allocation_cb, 120 &allocation_cb,
121 NULL, 121 NULL,
122 &suggestion_cb, 122 &suggestion_cb,
123 NULL); 123 NULL);
124 GNUNET_assert (NULL != ah); 124 GNUNET_assert(NULL != ah);
125} 125}
126 126
127 127
@@ -129,11 +129,11 @@ init_both (const struct GNUNET_CONFIGURATION_Handle *cfg)
129 * @brief Disconnect both 'sides' of ATS 129 * @brief Disconnect both 'sides' of ATS
130 */ 130 */
131static void 131static void
132finish_both (void) 132finish_both(void)
133{ 133{
134 GNUNET_ATS_application_done (ah); 134 GNUNET_ATS_application_done(ah);
135 ah = NULL; 135 ah = NULL;
136 GNUNET_ATS_transport_done (th); 136 GNUNET_ATS_transport_done(th);
137 th = NULL; 137 th = NULL;
138} 138}
139 139
@@ -142,7 +142,7 @@ finish_both (void)
142 * @brief Provide information about the start of an imaginary connection 142 * @brief Provide information about the start of an imaginary connection
143 */ 143 */
144static void 144static void
145provide_info_start (void) 145provide_info_start(void)
146{ 146{
147 struct GNUNET_ATS_Properties prop = 147 struct GNUNET_ATS_Properties prop =
148 { 148 {
@@ -157,12 +157,12 @@ provide_info_start (void)
157 .cc = GNUNET_TRANSPORT_CC_UNKNOWN, 157 .cc = GNUNET_TRANSPORT_CC_UNKNOWN,
158 }; 158 };
159 159
160 sr = GNUNET_ATS_session_add (th, 160 sr = GNUNET_ATS_session_add(th,
161 &other_peer, 161 &other_peer,
162 "test-address", 162 "test-address",
163 NULL, 163 NULL,
164 &prop); 164 &prop);
165 GNUNET_assert (NULL != sr); 165 GNUNET_assert(NULL != sr);
166} 166}
167 167
168 168
@@ -170,9 +170,9 @@ provide_info_start (void)
170 * @brief Provide information about the end of an imaginary connection 170 * @brief Provide information about the end of an imaginary connection
171 */ 171 */
172static void 172static void
173provide_info_end (void) 173provide_info_end(void)
174{ 174{
175 GNUNET_ATS_session_del (sr); 175 GNUNET_ATS_session_del(sr);
176} 176}
177 177
178 178
@@ -180,24 +180,24 @@ provide_info_end (void)
180 * @brief Inform ATS about the need of a connection towards a peer 180 * @brief Inform ATS about the need of a connection towards a peer
181 */ 181 */
182static void 182static void
183get_suggestion (void) 183get_suggestion(void)
184{ 184{
185 struct GNUNET_ATS_ApplicationSuggestHandle *ash; 185 struct GNUNET_ATS_ApplicationSuggestHandle *ash;
186 186
187 ash = GNUNET_ATS_application_suggest (ah, 187 ash = GNUNET_ATS_application_suggest(ah,
188 &other_peer, 188 &other_peer,
189 GNUNET_MQ_PREFERENCE_NONE, 189 GNUNET_MQ_PREFERENCE_NONE,
190 GNUNET_BANDWIDTH_VALUE_MAX); 190 GNUNET_BANDWIDTH_VALUE_MAX);
191 GNUNET_assert (NULL != ash); 191 GNUNET_assert(NULL != ash);
192} 192}
193 193
194 194
195static void 195static void
196on_shutdown (void *cls) 196on_shutdown(void *cls)
197{ 197{
198 provide_info_end (); 198 provide_info_end();
199 finish_both (); 199 finish_both();
200 GNUNET_SCHEDULER_shutdown (); 200 GNUNET_SCHEDULER_shutdown();
201} 201}
202 202
203 203
@@ -209,16 +209,16 @@ on_shutdown (void *cls)
209 * @param peer handle to the peer 209 * @param peer handle to the peer
210 */ 210 */
211static void 211static void
212run (void *cls, 212run(void *cls,
213 const struct GNUNET_CONFIGURATION_Handle *cfg, 213 const struct GNUNET_CONFIGURATION_Handle *cfg,
214 struct GNUNET_TESTING_Peer *peer) 214 struct GNUNET_TESTING_Peer *peer)
215{ 215{
216 init_both (cfg); 216 init_both(cfg);
217 provide_info_start (); 217 provide_info_start();
218 get_suggestion (); 218 get_suggestion();
219 (void) GNUNET_SCHEDULER_add_delayed (timeout, 219 (void)GNUNET_SCHEDULER_add_delayed(timeout,
220 &on_shutdown, 220 &on_shutdown,
221 NULL); 221 NULL);
222} 222}
223 223
224 224
@@ -231,27 +231,27 @@ run (void *cls,
231 * @return 231 * @return
232 */ 232 */
233int 233int
234main (int argc, 234main(int argc,
235 char *argv[]) 235 char *argv[])
236{ 236{
237 ret = 1; 237 ret = 1;
238 memset (&other_peer, 0, sizeof (struct GNUNET_PeerIdentity)); 238 memset(&other_peer, 0, sizeof(struct GNUNET_PeerIdentity));
239 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 239 timeout = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
240 2); 240 2);
241 if (0 != GNUNET_TESTING_peer_run ("test-ats2-lib", 241 if (0 != GNUNET_TESTING_peer_run("test-ats2-lib",
242 "test_ats2_lib.conf", 242 "test_ats2_lib.conf",
243 &run, NULL)) 243 &run, NULL))
244 { 244 {
245 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 245 GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
246 "Running the testing peer failed.\n"); 246 "Running the testing peer failed.\n");
247 return 1; 247 return 1;
248 } 248 }
249 if (0 != ret) 249 if (0 != ret)
250 { 250 {
251 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 251 GNUNET_log(GNUNET_ERROR_TYPE_WARNING,
252 "Global status indicates unsuccessful testrun - probably allocation_cb was not called.\n"); 252 "Global status indicates unsuccessful testrun - probably allocation_cb was not called.\n");
253 ret = 77; // SKIP test, test not yet right! 253 ret = 77; // SKIP test, test not yet right!
254 } 254 }
255 return ret; 255 return ret;
256} 256}
257 257