gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r16987 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r16987 - gnunet/src/mesh
Date: Wed, 21 Sep 2011 13:39:40 +0200

Author: bartpolot
Date: 2011-09-21 13:39:40 +0200 (Wed, 21 Sep 2011)
New Revision: 16987

Modified:
   gnunet/src/mesh/test_mesh_path_api.c
Log:
Updated testcase


Modified: gnunet/src/mesh/test_mesh_path_api.c
===================================================================
--- gnunet/src/mesh/test_mesh_path_api.c        2011-09-21 09:57:36 UTC (rev 
16986)
+++ gnunet/src/mesh/test_mesh_path_api.c        2011-09-21 11:39:40 UTC (rev 
16987)
@@ -36,6 +36,8 @@
 
 int failed;
 int cb_call;
+struct GNUNET_PeerIdentity* pi[10];
+struct MeshTunnelTree *tree;
 
 void
 cb (const struct MeshTunnelTreeNode *n)
@@ -49,6 +51,23 @@
   cb_call--;
 }
 
+
+void
+finish(void)
+{
+  unsigned int i;
+
+  for (i = 0; i < 10; i++)
+  {
+    GNUNET_free(pi[i]);
+  }
+  if (tree->root->nchildren > 0)
+    GNUNET_free(tree->root->children);
+  GNUNET_free(tree->root);
+  GNUNET_free(tree);
+  exit(0);
+}
+
 /**
  * Convert an integer int to a peer identity
  */
@@ -66,10 +85,8 @@
 int
 main (int argc, char *argv[])
 {
-  struct GNUNET_PeerIdentity* pi[10];
   struct MeshTunnelTreeNode *node;
   struct MeshTunnelTreeNode *node2;
-  struct MeshTunnelTree *tree;
   struct MeshPeerPath *path[10];
   unsigned int i;
 
@@ -102,6 +119,7 @@
   path[0]->peers[3] = 3;
   path[0]->length = 4;
 
+  finish();
   tunnel_add_path(tree, path[0], &cb);
   path[1] = tunnel_get_path_to_peer(tree, 3);
   if (path[0]->length != path[1]->length ||
@@ -122,6 +140,13 @@
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
     failed++;
   }
+  node->status = MESH_PEER_READY;
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
+  return 0;
 
   node = tunnel_find_peer(tree->root, 2);
   if (node->peer != 2)
@@ -139,7 +164,29 @@
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
     failed++;
   }
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
 
+  node = tunnel_find_peer(tree->root, 1);
+  if (node->peer != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
+    failed++;
+  }
+  if (node->status != MESH_PEER_RELAY)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
+    failed++;
+  }
+  if (node->nchildren != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
+    failed++;
+  }
+
   path[0]->length--;
   tunnel_add_path(tree, path[0], &cb);
 
@@ -159,8 +206,35 @@
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
     failed++;
   }
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 2)) != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
 
-  path[0]->length = 4;
+  node = tunnel_find_peer(tree->root, 1);
+  if (node->peer != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
+    failed++;
+  }
+  if (node->status != MESH_PEER_RELAY)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
+    failed++;
+  }
+  if (node->nchildren != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
+    failed++;
+  }
+
+  path[0]->length++;
   path[0]->peers[3] = 4;
   tunnel_add_path(tree, path[0], &cb);
 
@@ -180,7 +254,34 @@
     GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
     failed++;
   }
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 4)) != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
 
+  node = tunnel_find_peer(tree->root, 1);
+  if (node->peer != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
+    failed++;
+  }
+  if (node->status != MESH_PEER_RELAY)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
+    failed++;
+  }
+  if (node->nchildren != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
+    failed++;
+  }
+
   node = tunnel_find_peer(tree->root, 4);
   if (node->peer != 4)
   {
@@ -218,6 +319,59 @@
     failed++;
   }
 
+  path[0]->length = 2;
+  path[0]->peers[1] = 3;
+  cb_call = 1;
+  tunnel_add_path(tree, path[0], cb);
+  if (cb_call != 0)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call);
+    failed++;
+  }
+  node = tunnel_find_peer(tree->root, 2);
+  if (node->peer != 2)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
+    failed++;
+  }
+  if (node->status != MESH_PEER_SEARCHING)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
+    failed++;
+  }
+  if (node->nchildren != 0)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
+    failed++;
+  }
+  node = tunnel_find_peer(tree->root, 3);
+  if (node->peer != 3)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
+    failed++;
+  }
+  if (node->status != MESH_PEER_SEARCHING)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
+    failed++;
+  }
+  if (node->nchildren != 0)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
+    failed++;
+  }
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 2)) != 1)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
+  if (GNUNET_PEER_search(path_get_first_hop(tree, 3)) != 3)
+  {
+    GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Wrong first hop!\n");
+    failed++;
+  }
+
+
   if (failed > 0)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%u tests failed\n", failed);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]