[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25096 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25096 - gnunet/src/ats |
Date: |
Thu, 22 Nov 2012 13:12:41 +0100 |
Author: wachs
Date: 2012-11-22 13:12:41 +0100 (Thu, 22 Nov 2012)
New Revision: 25096
Modified:
gnunet/src/ats/test_ats_api_performance.c
Log:
- next stage
Modified: gnunet/src/ats/test_ats_api_performance.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance.c 2012-11-22 12:03:41 UTC (rev
25095)
+++ gnunet/src/ats/test_ats_api_performance.c 2012-11-22 12:12:41 UTC (rev
25096)
@@ -125,9 +125,9 @@
}
static void
-test_performance_api (void);
+test_performance_api (void *cls, const struct GNUNET_SCHEDULER_TaskContext
*tc);
-void all_addresses_cb (void *cls,
+void all_addresses_peer_cb (void *cls,
const struct
GNUNET_HELLO_Address *
address,
@@ -148,6 +148,59 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' address
`%s'\n",
GNUNET_i2s (&address->peer), address->address);
+ if (0 != memcmp (&address->peer, &p[1].id,
+ sizeof (struct GNUNET_PeerIdentity)))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %i: Received address for
wrong peer\n", stage);
+ GNUNET_ATS_performance_list_addresses_cancel (phal);
+ phal = NULL;
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+ ret = 4;
+ return;
+ }
+ cb ++;
+ }
+ else
+ {
+ phal = NULL;
+ if (2 == cb)
+ {
+ /* Received all addresses + terminator cb, next stage */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %i: SUCCESS\n", stage);
+ GNUNET_SCHEDULER_add_now (&test_performance_api, NULL);
+ return;
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stage %i: FAIL\n", stage);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+ ret = 5;
+ return;
+ }
+ }
+}
+
+void all_addresses_cb (void *cls,
+ const struct
+ GNUNET_HELLO_Address *
+ address,
+ struct
+ GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_out,
+ struct
+ GNUNET_BANDWIDTH_Value32NBO
+ bandwidth_in,
+ const struct
+ GNUNET_ATS_Information *
+ ats, uint32_t ats_count)
+{
+ static int cb = 0;
+
+ if (address != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Callback for peer `%s' address
`%s'\n",
+ GNUNET_i2s (&address->peer), address->address);
+
if (0 == memcmp (&address->peer, &p[0].id,
sizeof (struct GNUNET_PeerIdentity)))
{
@@ -186,7 +239,7 @@
{
/* Received all addresses + terminator cb, next stage */
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage %i: SUCCESS\n", stage);
- test_performance_api ();
+ GNUNET_SCHEDULER_add_now (&test_performance_api, NULL);
return;
}
else
@@ -197,11 +250,10 @@
return;
}
}
-
}
static void
-test_performance_api (void)
+test_performance_api (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
if (NULL == ph)
ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
@@ -218,7 +270,16 @@
NULL,
GNUNET_YES,
&all_addresses_cb, NULL);
+ GNUNET_assert (NULL != phal);
break;
+ case 2:
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stage 2: \n");
+ phal = GNUNET_ATS_performance_list_addresses (ph,
+ &p[1].id,
+ GNUNET_YES,
+ &all_addresses_peer_cb, NULL);
+ GNUNET_assert (NULL != phal);
+ break;
default:
/* done */
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "All tests successful, shutdown...
\n");
@@ -249,7 +310,8 @@
if ((GNUNET_YES >= suggest_p0) && (GNUNET_YES >= suggest_p1))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have address suggestion for both
peers\n");
- test_performance_api ();
+ test_performance_api(NULL, NULL);
+ //GNUNET_SCHEDULER_add_now (&test_performance_api, NULL);
}
}
@@ -329,8 +391,13 @@
}
GNUNET_ATS_address_add (ats, &p0_ha[0], NULL, NULL, 0);
+
GNUNET_ATS_address_add (ats, &p0_ha[1], NULL, NULL, 0);
+ GNUNET_ATS_address_in_use (ats, &p0_ha[1], NULL, GNUNET_YES);
+
GNUNET_ATS_address_add (ats, &p1_ha[0], NULL, NULL, 0);
+ GNUNET_ATS_address_in_use (ats, &p1_ha[0], NULL, GNUNET_YES);
+
GNUNET_ATS_address_add (ats, &p1_ha[1], NULL, NULL, 0);
GNUNET_ATS_suggest_address (ats, &p[0].id);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25096 - gnunet/src/ats,
gnunet <=