aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/test_mesh_path_api.c
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2011-09-22 18:12:27 +0000
committerBart Polot <bart@net.in.tum.de>2011-09-22 18:12:27 +0000
commit17e4c95ee4c555db7ab3ab9c57412b7866ee5411 (patch)
tree25a8e79563ba3a6890cba8de7015cae8f3a0d9ba /src/mesh/test_mesh_path_api.c
parent1e018e4e2e1d57cee223aa84f2ebd7e6c8160480 (diff)
downloadgnunet-17e4c95ee4c555db7ab3ab9c57412b7866ee5411.tar.gz
gnunet-17e4c95ee4c555db7ab3ab9c57412b7866ee5411.zip
Changed tree children magement from array to DLL, fixed bugs, extended testcase.
Diffstat (limited to 'src/mesh/test_mesh_path_api.c')
-rw-r--r--src/mesh/test_mesh_path_api.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/mesh/test_mesh_path_api.c b/src/mesh/test_mesh_path_api.c
index 3d6a06857..a397752e9 100644
--- a/src/mesh/test_mesh_path_api.c
+++ b/src/mesh/test_mesh_path_api.c
@@ -42,10 +42,10 @@ struct MeshTunnelTree *tree;
42void 42void
43cb (const struct MeshTunnelTreeNode *n) 43cb (const struct MeshTunnelTreeNode *n)
44{ 44{
45 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Disconnected %u\n", n->peer); 45 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: CB: Disconnected %u\n", n->peer);
46 if(0 == cb_call) 46 if(0 == cb_call)
47 { 47 {
48 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: and it shouldn't!\n"); 48 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: and it shouldn't!\n");
49 failed++; 49 failed++;
50 } 50 }
51 cb_call--; 51 cb_call--;
@@ -120,6 +120,7 @@ main (int argc, char *argv[])
120 120
121 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding first path: 0 1 2 3\n"); 121 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding first path: 0 1 2 3\n");
122 tree_add_path(tree, path, &cb); 122 tree_add_path(tree, path, &cb);
123 tree_debug(tree);
123 path1 = tree_get_path_to_peer(tree, 3); 124 path1 = tree_get_path_to_peer(tree, 3);
124 if (path->length != path1->length || 125 if (path->length != path1->length ||
125 memcmp(path->peers, path1->peers, path->length) != 0) 126 memcmp(path->peers, path1->peers, path->length) != 0)
@@ -156,7 +157,7 @@ main (int argc, char *argv[])
156 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 157 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
157 failed++; 158 failed++;
158 } 159 }
159 if (node->nchildren != 1) 160 if (node->children_head != node->children_tail)
160 { 161 {
161 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 162 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
162 failed++; 163 failed++;
@@ -178,7 +179,7 @@ main (int argc, char *argv[])
178 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 179 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
179 failed++; 180 failed++;
180 } 181 }
181 if (node->nchildren != 1) 182 if (node->children_head != node->children_tail)
182 { 183 {
183 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 184 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
184 failed++; 185 failed++;
@@ -187,7 +188,8 @@ main (int argc, char *argv[])
187 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding second path: 0 1 2\n"); 188 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding second path: 0 1 2\n");
188 path->length--; 189 path->length--;
189 tree_add_path(tree, path, &cb); 190 tree_add_path(tree, path, &cb);
190 191 tree_debug(tree);
192
191 node = tree_find_peer(tree->root, 2); 193 node = tree_find_peer(tree->root, 2);
192 if (node->peer != 2) 194 if (node->peer != 2)
193 { 195 {
@@ -199,7 +201,7 @@ main (int argc, char *argv[])
199 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 201 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
200 failed++; 202 failed++;
201 } 203 }
202 if (node->nchildren != 1) 204 if (node->children_head != node->children_tail)
203 { 205 {
204 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 206 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
205 failed++; 207 failed++;
@@ -228,7 +230,7 @@ main (int argc, char *argv[])
228 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 230 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
229 failed++; 231 failed++;
230 } 232 }
231 if (node->nchildren != 1) 233 if (node->children_head != node->children_tail)
232 { 234 {
233 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 235 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
234 failed++; 236 failed++;
@@ -238,10 +240,7 @@ main (int argc, char *argv[])
238 path->length++; 240 path->length++;
239 path->peers[3] = 4; 241 path->peers[3] = 4;
240 tree_add_path(tree, path, &cb); 242 tree_add_path(tree, path, &cb);
241
242 path_destroy(path);
243 tree_debug(tree); 243 tree_debug(tree);
244 finish();
245 244
246 node = tree_find_peer(tree->root, 2); 245 node = tree_find_peer(tree->root, 2);
247 if (node->peer != 2) 246 if (node->peer != 2)
@@ -254,7 +253,7 @@ main (int argc, char *argv[])
254 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 253 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
255 failed++; 254 failed++;
256 } 255 }
257 if (node->nchildren != 2) 256 if (node->children_head->next != node->children_tail)
258 { 257 {
259 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 258 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
260 failed++; 259 failed++;
@@ -281,7 +280,7 @@ main (int argc, char *argv[])
281 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 280 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
282 failed++; 281 failed++;
283 } 282 }
284 if (node->nchildren != 1) 283 if (node->children_head != node->children_tail)
285 { 284 {
286 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 285 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
287 failed++; 286 failed++;
@@ -293,11 +292,12 @@ main (int argc, char *argv[])
293 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n"); 292 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer != original\n");
294 failed++; 293 failed++;
295 } 294 }
296 295
297 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Deleting third path...\n"); 296 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Deleting third path...\n");
298 node->status = MESH_PEER_READY; 297 node->status = MESH_PEER_READY;
299 cb_call = 1; 298 cb_call = 1;
300 node2 = tree_del_path(tree, 4, &cb); 299 node2 = tree_del_path(tree, 4, &cb);
300 tree_debug(tree);
301 if (cb_call != 0) 301 if (cb_call != 0)
302 { 302 {
303 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call); 303 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call);
@@ -320,25 +320,31 @@ main (int argc, char *argv[])
320 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 320 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
321 failed++; 321 failed++;
322 } 322 }
323 if (node->nchildren != 1) 323 if (node->children_head != node->children_tail)
324 { 324 {
325 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 325 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
326 failed++; 326 failed++;
327 } 327 }
328 328
329 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Destroying node copy...\n"); 329 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Destroying node copy...\n");
330 tree_node_destroy(node2); 330 GNUNET_free (node2);
331 331
332 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding new shorter first path...\n"); 332 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "test: Adding new shorter first path...\n");
333 path->length = 2; 333 path->length = 2;
334 path->peers[1] = 3; 334 path->peers[1] = 3;
335 cb_call = 1; 335 cb_call = 1;
336 tree_find_peer(tree->root, 3)->status = MESH_PEER_READY;
336 tree_add_path(tree, path, cb); 337 tree_add_path(tree, path, cb);
338 tree_debug(tree);
337 if (cb_call != 0) 339 if (cb_call != 0)
338 { 340 {
339 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call); 341 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%u callbacks missed!\n", cb_call);
340 failed++; 342 failed++;
341 } 343 }
344
345 path_destroy(path);
346 finish();
347
342 node = tree_find_peer(tree->root, 2); 348 node = tree_find_peer(tree->root, 2);
343 if (node->peer != 2) 349 if (node->peer != 2)
344 { 350 {
@@ -350,7 +356,7 @@ main (int argc, char *argv[])
350 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 356 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
351 failed++; 357 failed++;
352 } 358 }
353 if (node->nchildren != 0) 359 if (node->children_head != NULL)
354 { 360 {
355 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 361 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
356 failed++; 362 failed++;
@@ -366,7 +372,7 @@ main (int argc, char *argv[])
366 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n"); 372 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong status!\n");
367 failed++; 373 failed++;
368 } 374 }
369 if (node->nchildren != 0) 375 if (node->children_head != NULL)
370 { 376 {
371 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n"); 377 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Retrieved peer wrong nchildren!\n");
372 failed++; 378 failed++;