aboutsummaryrefslogtreecommitdiff
path: root/src/ats/test_ats_api_performance.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2012-11-22 12:12:41 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2012-11-22 12:12:41 +0000
commit1b82d30656e0415f48bdb358d52f29d28a01e0a3 (patch)
tree094e0b9e4aaf9280396dcf5205cfbad54681d487 /src/ats/test_ats_api_performance.c
parent96789dd016757f879c78388db81781038e679a4e (diff)
downloadgnunet-1b82d30656e0415f48bdb358d52f29d28a01e0a3.tar.gz
gnunet-1b82d30656e0415f48bdb358d52f29d28a01e0a3.zip
- next stage
Diffstat (limited to 'src/ats/test_ats_api_performance.c')
-rw-r--r--src/ats/test_ats_api_performance.c79
1 files changed, 73 insertions, 6 deletions
diff --git a/src/ats/test_ats_api_performance.c b/src/ats/test_ats_api_performance.c
index 31ecc56d5..4d736cec5 100644
--- a/src/ats/test_ats_api_performance.c
+++ b/src/ats/test_ats_api_performance.c
@@ -125,9 +125,9 @@ end ()
125} 125}
126 126
127static void 127static void
128test_performance_api (void); 128test_performance_api (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
129 129
130void all_addresses_cb (void *cls, 130void all_addresses_peer_cb (void *cls,
131 const struct 131 const struct
132 GNUNET_HELLO_Address * 132 GNUNET_HELLO_Address *
133 address, 133 address,
@@ -148,6 +148,59 @@ void all_addresses_cb (void *cls,
148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' address `%s'\n", 148 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' address `%s'\n",
149 GNUNET_i2s (&address->peer), address->address); 149 GNUNET_i2s (&address->peer), address->address);
150 150
151 if (0 != memcmp (&address->peer, &p[1].id,
152 sizeof (struct GNUNET_PeerIdentity)))
153 {
154 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %i: Received address for wrong peer\n", stage);
155 GNUNET_ATS_performance_list_addresses_cancel (phal);
156 phal = NULL;
157 GNUNET_SCHEDULER_add_now (&end, NULL);
158 ret = 4;
159 return;
160 }
161 cb ++;
162 }
163 else
164 {
165 phal = NULL;
166 if (2 == cb)
167 {
168 /* Received all addresses + terminator cb, next stage */
169 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %i: SUCCESS\n", stage);
170 GNUNET_SCHEDULER_add_now (&test_performance_api, NULL);
171 return;
172 }
173 else
174 {
175 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %i: FAIL\n", stage);
176 GNUNET_SCHEDULER_add_now (&end, NULL);
177 ret = 5;
178 return;
179 }
180 }
181}
182
183void all_addresses_cb (void *cls,
184 const struct
185 GNUNET_HELLO_Address *
186 address,
187 struct
188 GNUNET_BANDWIDTH_Value32NBO
189 bandwidth_out,
190 struct
191 GNUNET_BANDWIDTH_Value32NBO
192 bandwidth_in,
193 const struct
194 GNUNET_ATS_Information *
195 ats, uint32_t ats_count)
196{
197 static int cb = 0;
198
199 if (address != NULL)
200 {
201 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' address `%s'\n",
202 GNUNET_i2s (&address->peer), address->address);
203
151 if (0 == memcmp (&address->peer, &p[0].id, 204 if (0 == memcmp (&address->peer, &p[0].id,
152 sizeof (struct GNUNET_PeerIdentity))) 205 sizeof (struct GNUNET_PeerIdentity)))
153 { 206 {
@@ -186,7 +239,7 @@ void all_addresses_cb (void *cls,
186 { 239 {
187 /* Received all addresses + terminator cb, next stage */ 240 /* Received all addresses + terminator cb, next stage */
188 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %i: SUCCESS\n", stage); 241 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %i: SUCCESS\n", stage);
189 test_performance_api (); 242 GNUNET_SCHEDULER_add_now (&test_performance_api, NULL);
190 return; 243 return;
191 } 244 }
192 else 245 else
@@ -197,11 +250,10 @@ void all_addresses_cb (void *cls,
197 return; 250 return;
198 } 251 }
199 } 252 }
200
201} 253}
202 254
203static void 255static void
204test_performance_api (void) 256test_performance_api (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
205{ 257{
206 if (NULL == ph) 258 if (NULL == ph)
207 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL); 259 ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
@@ -218,6 +270,15 @@ test_performance_api (void)
218 NULL, 270 NULL,
219 GNUNET_YES, 271 GNUNET_YES,
220 &all_addresses_cb, NULL); 272 &all_addresses_cb, NULL);
273 GNUNET_assert (NULL != phal);
274 break;
275 case 2:
276 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage 2: \n");
277 phal = GNUNET_ATS_performance_list_addresses (ph,
278 &p[1].id,
279 GNUNET_YES,
280 &all_addresses_peer_cb, NULL);
281 GNUNET_assert (NULL != phal);
221 break; 282 break;
222 default: 283 default:
223 /* done */ 284 /* done */
@@ -249,7 +310,8 @@ address_suggest_cb (void *cls, const struct GNUNET_HELLO_Address *address,
249 if ((GNUNET_YES >= suggest_p0) && (GNUNET_YES >= suggest_p1)) 310 if ((GNUNET_YES >= suggest_p0) && (GNUNET_YES >= suggest_p1))
250 { 311 {
251 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have address suggestion for both peers\n"); 312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have address suggestion for both peers\n");
252 test_performance_api (); 313 test_performance_api(NULL, NULL);
314 //GNUNET_SCHEDULER_add_now (&test_performance_api, NULL);
253 } 315 }
254} 316}
255 317
@@ -329,8 +391,13 @@ run (void *cls,
329 } 391 }
330 392
331 GNUNET_ATS_address_add (ats, &p0_ha[0], NULL, NULL, 0); 393 GNUNET_ATS_address_add (ats, &p0_ha[0], NULL, NULL, 0);
394
332 GNUNET_ATS_address_add (ats, &p0_ha[1], NULL, NULL, 0); 395 GNUNET_ATS_address_add (ats, &p0_ha[1], NULL, NULL, 0);
396 GNUNET_ATS_address_in_use (ats, &p0_ha[1], NULL, GNUNET_YES);
397
333 GNUNET_ATS_address_add (ats, &p1_ha[0], NULL, NULL, 0); 398 GNUNET_ATS_address_add (ats, &p1_ha[0], NULL, NULL, 0);
399 GNUNET_ATS_address_in_use (ats, &p1_ha[0], NULL, GNUNET_YES);
400
334 GNUNET_ATS_address_add (ats, &p1_ha[1], NULL, NULL, 0); 401 GNUNET_ATS_address_add (ats, &p1_ha[1], NULL, NULL, 0);
335 402
336 GNUNET_ATS_suggest_address (ats, &p[0].id); 403 GNUNET_ATS_suggest_address (ats, &p[0].id);