diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-22 14:05:29 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2012-11-22 14:05:29 +0000 |
commit | 1be69987cc9f395d3a162fd976288b7ef144435e (patch) | |
tree | 312432a6214c0c5db2c008a8ec4bfd80f0ccf7dc | |
parent | 460dd88280de1904b27077aee1aafb27df68fc47 (diff) | |
download | gnunet-1be69987cc9f395d3a162fd976288b7ef144435e.tar.gz gnunet-1be69987cc9f395d3a162fd976288b7ef144435e.zip |
test done
-rw-r--r-- | src/ats/test_ats_api_performance.c | 87 |
1 files changed, 76 insertions, 11 deletions
diff --git a/src/ats/test_ats_api_performance.c b/src/ats/test_ats_api_performance.c index 84aad42ab..7ecf42b90 100644 --- a/src/ats/test_ats_api_performance.c +++ b/src/ats/test_ats_api_performance.c | |||
@@ -142,7 +142,59 @@ void all_active_addresses_peer_cb (void *cls, | |||
142 | GNUNET_ATS_Information * | 142 | GNUNET_ATS_Information * |
143 | ats, uint32_t ats_count) | 143 | ats, uint32_t ats_count) |
144 | { | 144 | { |
145 | static int cb = 0; | ||
146 | int fail = GNUNET_NO; | ||
145 | 147 | ||
148 | if (address != NULL) | ||
149 | { | ||
150 | if (0 == memcmp (&address->peer, &p[0].id, | ||
151 | sizeof (struct GNUNET_PeerIdentity))) | ||
152 | { | ||
153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
154 | "Did not expected callback for peer 0 address `%s', got address `%s'!\n", | ||
155 | s_ha[0]->address, address->address); | ||
156 | GNUNET_ATS_performance_list_addresses_cancel (phal); | ||
157 | fail = GNUNET_YES; | ||
158 | } | ||
159 | |||
160 | if (0 == memcmp (&address->peer, &p[1].id, | ||
161 | sizeof (struct GNUNET_PeerIdentity))) | ||
162 | { | ||
163 | if (0 == strcmp(address->address, s_ha[1]->address)) | ||
164 | { | ||
165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
166 | "Callback for peer 1 suggested address %s\n", | ||
167 | s_ha[1]->address); | ||
168 | cb ++; | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
173 | "Expected callback for peer 1 address `%s', got address `%s'!\n", | ||
174 | s_ha[1]->address, address->address); | ||
175 | GNUNET_ATS_performance_list_addresses_cancel (phal); | ||
176 | fail = GNUNET_YES; | ||
177 | } | ||
178 | } | ||
179 | } | ||
180 | if ((address == NULL) || (GNUNET_YES == fail)) | ||
181 | { | ||
182 | phal = NULL; | ||
183 | if ((1 == cb) && (GNUNET_NO == fail)) | ||
184 | { | ||
185 | /* Received all addresses + terminator cb, next stage */ | ||
186 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %i: SUCCESS\n", stage); | ||
187 | GNUNET_SCHEDULER_add_now (&test_performance_api, NULL); | ||
188 | return; | ||
189 | } | ||
190 | else | ||
191 | { | ||
192 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %i: FAIL\n", stage); | ||
193 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
194 | ret = 5; | ||
195 | return; | ||
196 | } | ||
197 | } | ||
146 | } | 198 | } |
147 | 199 | ||
148 | void all_active_addresses_cb (void *cls, | 200 | void all_active_addresses_cb (void *cls, |
@@ -169,12 +221,16 @@ void all_active_addresses_cb (void *cls, | |||
169 | { | 221 | { |
170 | if (0 == strcmp(address->address, s_ha[0]->address)) | 222 | if (0 == strcmp(address->address, s_ha[0]->address)) |
171 | { | 223 | { |
172 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 0 suggested address %s\n", s_ha[0]->address); | 224 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
225 | "Callback for peer 0 suggested address %s\n", | ||
226 | s_ha[0]->address); | ||
173 | cb ++; | 227 | cb ++; |
174 | } | 228 | } |
175 | else | 229 | else |
176 | { | 230 | { |
177 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected callback for peer 0 address `%s', got address `%s'!\n", s_ha[0]->address, address->address); | 231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
232 | "Expected callback for peer 0 address `%s', got address `%s'!\n", | ||
233 | s_ha[0]->address, address->address); | ||
178 | GNUNET_ATS_performance_list_addresses_cancel (phal); | 234 | GNUNET_ATS_performance_list_addresses_cancel (phal); |
179 | fail = GNUNET_YES; | 235 | fail = GNUNET_YES; |
180 | } | 236 | } |
@@ -185,12 +241,16 @@ void all_active_addresses_cb (void *cls, | |||
185 | { | 241 | { |
186 | if (0 == strcmp(address->address, s_ha[1]->address)) | 242 | if (0 == strcmp(address->address, s_ha[1]->address)) |
187 | { | 243 | { |
188 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 1 suggested address %s\n", s_ha[1]->address); | 244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
245 | "Callback for peer 1 suggested address %s\n", | ||
246 | s_ha[1]->address); | ||
189 | cb ++; | 247 | cb ++; |
190 | } | 248 | } |
191 | else | 249 | else |
192 | { | 250 | { |
193 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Expected callback for peer 1 address `%s', got address `%s'!\n", s_ha[1]->address, address->address); | 251 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
252 | "Expected callback for peer 1 address `%s', got address `%s'!\n", | ||
253 | s_ha[1]->address, address->address); | ||
194 | GNUNET_ATS_performance_list_addresses_cancel (phal); | 254 | GNUNET_ATS_performance_list_addresses_cancel (phal); |
195 | fail = GNUNET_YES; | 255 | fail = GNUNET_YES; |
196 | } | 256 | } |
@@ -237,13 +297,15 @@ void all_addresses_peer_cb (void *cls, | |||
237 | 297 | ||
238 | if (address != NULL) | 298 | if (address != NULL) |
239 | { | 299 | { |
240 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' address `%s'\n", | 300 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
301 | "Callback for peer `%s' address `%s'\n", | ||
241 | GNUNET_i2s (&address->peer), address->address); | 302 | GNUNET_i2s (&address->peer), address->address); |
242 | 303 | ||
243 | if (0 != memcmp (&address->peer, &p[1].id, | 304 | if (0 != memcmp (&address->peer, &p[1].id, |
244 | sizeof (struct GNUNET_PeerIdentity))) | 305 | sizeof (struct GNUNET_PeerIdentity))) |
245 | { | 306 | { |
246 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %i: Received address for wrong peer\n", stage); | 307 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
308 | "Stage %i: Received address for wrong peer\n", stage); | ||
247 | GNUNET_ATS_performance_list_addresses_cancel (phal); | 309 | GNUNET_ATS_performance_list_addresses_cancel (phal); |
248 | fail = GNUNET_YES; | 310 | fail = GNUNET_YES; |
249 | ret = 4; | 311 | ret = 4; |
@@ -289,13 +351,9 @@ void all_addresses_cb (void *cls, | |||
289 | 351 | ||
290 | if (address != NULL) | 352 | if (address != NULL) |
291 | { | 353 | { |
292 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' address `%s'\n", | ||
293 | GNUNET_i2s (&address->peer), address->address); | ||
294 | |||
295 | if (0 == memcmp (&address->peer, &p[0].id, | 354 | if (0 == memcmp (&address->peer, &p[0].id, |
296 | sizeof (struct GNUNET_PeerIdentity))) | 355 | sizeof (struct GNUNET_PeerIdentity))) |
297 | { | 356 | { |
298 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 0 `%s'\n", GNUNET_i2s (&address->peer)); | ||
299 | if (0 == strcmp(address->address, p0_addresses[0].addr)) | 357 | if (0 == strcmp(address->address, p0_addresses[0].addr)) |
300 | { | 358 | { |
301 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 0 address 0\n"); | 359 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 0 address 0\n"); |
@@ -310,7 +368,6 @@ void all_addresses_cb (void *cls, | |||
310 | if (0 == memcmp (&address->peer, &p[1].id, | 368 | if (0 == memcmp (&address->peer, &p[1].id, |
311 | sizeof (struct GNUNET_PeerIdentity))); | 369 | sizeof (struct GNUNET_PeerIdentity))); |
312 | { | 370 | { |
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 1 `%s'\n", GNUNET_i2s (&address->peer)); | ||
314 | if (0 == strcmp(address->address, p1_addresses[0].addr)) | 371 | if (0 == strcmp(address->address, p1_addresses[0].addr)) |
315 | { | 372 | { |
316 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 1 address 0\n"); | 373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer 1 address 0\n"); |
@@ -379,6 +436,14 @@ test_performance_api (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
379 | &all_active_addresses_cb, NULL); | 436 | &all_active_addresses_cb, NULL); |
380 | GNUNET_assert (NULL != phal); | 437 | GNUNET_assert (NULL != phal); |
381 | break; | 438 | break; |
439 | case 4: /* Get specific peers, active addresses */ | ||
440 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Run stage 4: \n"); | ||
441 | phal = GNUNET_ATS_performance_list_addresses (ph, | ||
442 | &p[1].id, | ||
443 | GNUNET_NO, | ||
444 | &all_active_addresses_peer_cb, NULL); | ||
445 | GNUNET_assert (NULL != phal); | ||
446 | break; | ||
382 | default: | 447 | default: |
383 | /* done */ | 448 | /* done */ |
384 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All tests successful, shutdown... \n"); | 449 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All tests successful, shutdown... \n"); |