[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r26513 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r26513 - gnunet/src/ats |
Date: |
Wed, 20 Mar 2013 13:37:31 +0100 |
Author: wachs
Date: 2013-03-20 13:37:31 +0100 (Wed, 20 Mar 2013)
New Revision: 26513
Modified:
gnunet/src/ats/ats_api_performance.c
gnunet/src/ats/gnunet-service-ats_performance.c
gnunet/src/ats/test_ats_api_performance_monitor.c
Log:
test
Modified: gnunet/src/ats/ats_api_performance.c
===================================================================
--- gnunet/src/ats/ats_api_performance.c 2013-03-20 11:11:16 UTC (rev
26512)
+++ gnunet/src/ats/ats_api_performance.c 2013-03-20 12:37:31 UTC (rev
26513)
@@ -607,12 +607,13 @@
if (id == cur->id)
break;
}
-
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ _("Received %s message for id %u\n"), "ATS_MONITOR_RESPONSE", id);
if (NULL == cur)
- {
- GNUNET_break (0);
- return GNUNET_SYSERR;
- }
+ {
+ GNUNET_break (0);
+ return GNUNET_SYSERR;
+ }
ats = (struct GNUNET_ATS_Information *) &mrm[1];
cur->moncb (cur->moncb_cls, &mrm->peer, ats, ats_count);
Modified: gnunet/src/ats/gnunet-service-ats_performance.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_performance.c 2013-03-20 11:11:16 UTC
(rev 26512)
+++ gnunet/src/ats/gnunet-service-ats_performance.c 2013-03-20 12:37:31 UTC
(rev 26513)
@@ -542,13 +542,13 @@
mrm->header.size = htons (msglen);
mrm->ats_count = htonl (ats_count);
mrm->peer = *peer;
- memcpy (&mrm[1], ats, sizeof (struct GNUNET_ATS_Information));
+ memcpy (&mrm[1], ats, ats_count * sizeof (struct
GNUNET_ATS_Information));
for (cur = pc_head; NULL != cur; cur = cur->next)
for (curm = cur->pm_head; NULL != curm; curm = curm->next)
{
/* Notify client about update */
- mrm->id = curm->id;
+ mrm->id = htonl (curm->id);
GNUNET_SERVER_notification_context_unicast (nc,
cur->client,
(struct GNUNET_MessageHeader *) mrm,
@@ -586,7 +586,7 @@
mrm->id = htonl(pmc->id);
mrm->ats_count = htonl (atsi_count);
mrm->peer = *id;
- memcpy (&mrm[1], atsi, sizeof (struct GNUNET_ATS_Information));
+ memcpy (&mrm[1], atsi, atsi_count * sizeof (struct
GNUNET_ATS_Information));
/* Send initial information about peers to client */
Modified: gnunet/src/ats/test_ats_api_performance_monitor.c
===================================================================
--- gnunet/src/ats/test_ats_api_performance_monitor.c 2013-03-20 11:11:16 UTC
(rev 26512)
+++ gnunet/src/ats/test_ats_api_performance_monitor.c 2013-03-20 12:37:31 UTC
(rev 26513)
@@ -31,6 +31,8 @@
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20)
#define SHUTDOWN_CORRECT GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 5)
+#define ATS_COUNT 3
+
static GNUNET_SCHEDULER_TaskIdentifier die_task;
static GNUNET_SCHEDULER_TaskIdentifier stage_task;
@@ -44,7 +46,7 @@
static struct GNUNET_HELLO_Address addr;
-static struct GNUNET_ATS_Information atsi[3];
+static struct GNUNET_ATS_Information atsi[ATS_COUNT];
static int ret;
@@ -68,7 +70,7 @@
atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
atsi[2].value = htonl(5);
- GNUNET_ATS_address_add (sh, &addr, NULL, atsi, 3);
+ GNUNET_ATS_address_add (sh, &addr, NULL, atsi, ATS_COUNT);
}
@@ -125,7 +127,7 @@
stage_task = GNUNET_SCHEDULER_NO_TASK;
if (0 == stage_counter)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Stop performance
monitoring\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stop performance
monitoring\n");
GNUNET_ATS_performance_monitor_stop (phm);
phm = NULL;
@@ -140,9 +142,13 @@
}
}
+static void end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Success\n");
+ end_now (1);
+}
-
static void
perf_mon_cb (void *cls,
struct GNUNET_PeerIdentity
*peer,
@@ -150,14 +156,106 @@
uint32_t ats_count)
{
static int stage_counter = 0;
+ int c1;
+ int c2;
+ int c3;
+
if (0 == stage_counter)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Received initial
callback\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received initial callback
for peer `%s' with %u information\n",
+ GNUNET_i2s (&addr.peer), ats_count);
+ if ((0 != memcmp (peer, &addr.peer, sizeof (addr.peer))) ||
+ (ats_count < ATS_COUNT))
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ return;
+ }
+ c3 = 0;
+ for (c1 = 0; c1 < ats_count; c1++)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "ATS
information [%u] %u : %u \n", c1, ntohl (ats[c1].type), ntohl (ats[c1].value));
+ for (c2 = 0; c2 < ATS_COUNT; c2++)
+ {
+ if (ats[c1].type == atsi[c2].type)
+ {
+ if (ats[c1].value ==
atsi[c2].value)
+ {
+ c3++;
+ }
+ else
+ {
+ GNUNET_break
(0);
+ }
+ }
+ }
+ }
+
+ if (ATS_COUNT != c3)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received only %u
correct ATS information \n", c3);
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ return;
+ }
stage_counter ++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u correct ATS
information \n", c3);
+
+ atsi[0].type = htonl(GNUNET_ATS_NETWORK_TYPE);
+ atsi[0].value = htonl(GNUNET_ATS_NET_WAN);
+
+ atsi[1].type = htonl(GNUNET_ATS_QUALITY_NET_DELAY);
+ atsi[1].value = htonl(1000);
+
+ atsi[2].type = htonl(GNUNET_ATS_QUALITY_NET_DISTANCE);
+ atsi[2].value = htonl(50);
+
+ GNUNET_ATS_address_update (sh, &addr, NULL, atsi, ATS_COUNT);
}
+ else if (1 == stage_counter)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received updated
callback for peer `%s' with %u information\n",
+ GNUNET_i2s (&addr.peer), ats_count);
+ if ((0 != memcmp (peer, &addr.peer, sizeof
(addr.peer))) ||
+ (ats_count < ATS_COUNT))
+ {
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_add_now (&end_badly,
NULL);
+ return;
+ }
+ c3 = 0;
+ for (c1 = 0; c1 < ats_count; c1++)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ATS information [%u] %u : %u \n", c1, ntohl (ats[c1].type), ntohl
(ats[c1].value));
+ for (c2 = 0; c2 < ATS_COUNT; c2++)
+ {
+ if (ats[c1].type ==
atsi[c2].type)
+ {
+ if (ats[c1].value ==
atsi[c2].value)
+ {
+ c3++;
+ }
+ else
+ {
+
GNUNET_break (0);
+ }
+ }
+ }
+ }
-
+ if (ATS_COUNT != c3)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received only
%u correct ATS information \n", c3);
+ GNUNET_break (0);
+ GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+ return;
+ }
+ stage_counter ++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %u
correct ATS information, shutdown... \n", c3);
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+ return;
+ }
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r26513 - gnunet/src/ats,
gnunet <=