aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2022-12-13 13:08:17 +0100
committert3sserakt <t3ss@posteo.de>2022-12-13 13:08:17 +0100
commitba4d141be09651b452270fc21f062d50bd3f738a (patch)
tree309c149fc8989fc83a893703e4f86194fb9a2f36 /src/testing
parent52d0d09146c1d13bded8195cb91845acac1b355d (diff)
downloadgnunet-ba4d141be09651b452270fc21f062d50bd3f738a.tar.gz
gnunet-ba4d141be09651b452270fc21f062d50bd3f738a.zip
- refactored barrier header, fixed messages for barrier signaling
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/gnunet-cmds-helper.c8
-rw-r--r--src/testing/testing.h185
-rw-r--r--src/testing/testing_api_cmd_barrier.c20
-rw-r--r--src/testing/testing_api_cmd_barrier_reached.c6
-rw-r--r--src/testing/testing_api_cmd_netjail_start_testsystem.c25
-rw-r--r--src/testing/testing_api_loop.c52
6 files changed, 244 insertions, 52 deletions
diff --git a/src/testing/gnunet-cmds-helper.c b/src/testing/gnunet-cmds-helper.c
index 9c16038f0..22cf5a428 100644
--- a/src/testing/gnunet-cmds-helper.c
+++ b/src/testing/gnunet-cmds-helper.c
@@ -67,6 +67,8 @@
67 67
68struct GNUNET_SCHEDULER_Task *finished_task; 68struct GNUNET_SCHEDULER_Task *finished_task;
69 69
70struct GNUNET_TESTING_Interpreter *is;
71
70/** 72/**
71 * Struct with information about a specific node and the whole network namespace setup. 73 * Struct with information about a specific node and the whole network namespace setup.
72 * 74 *
@@ -392,7 +394,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
392 } 394 }
393 strcat (node_ip, plugin->m); 395 strcat (node_ip, plugin->m);
394 396
395 plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m, 397 is = plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m,
396 398
397 plugin->n, plugin->local_m, ni->topology_data, 399 plugin->n, plugin->local_m, ni->topology_data,
398 ni->read_file, &finished_cb); 400 ni->read_file, &finished_cb);
@@ -413,9 +415,11 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
413 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED == ntohs ( 415 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED == ntohs (
414 message->type)) 416 message->type))
415 { 417 {
418 const char *barrier_name;
416 struct GNUNET_TESTING_CommandBarrierAdvanced *adm = (struct GNUNET_TESTING_CommandBarrierAdvanced *) message; 419 struct GNUNET_TESTING_CommandBarrierAdvanced *adm = (struct GNUNET_TESTING_CommandBarrierAdvanced *) message;
417 420
418 plugin->api->barrier_advanced (adm->barrier_name); 421 barrier_name = (const char *) &adm[1];
422 GNUNET_TESTING_finish_attached_cmds (is, barrier_name);
419 return GNUNET_OK; 423 return GNUNET_OK;
420 } 424 }
421 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs ( 425 else if (GNUNET_MESSAGE_TYPE_CMDS_HELPER_ALL_PEERS_STARTED == ntohs (
diff --git a/src/testing/testing.h b/src/testing/testing.h
index 848533251..382879706 100644
--- a/src/testing/testing.h
+++ b/src/testing/testing.h
@@ -24,7 +24,70 @@
24#ifndef TESTING_H 24#ifndef TESTING_H
25#define TESTING_H 25#define TESTING_H
26#include "gnunet_util_lib.h" 26#include "gnunet_util_lib.h"
27#include "gnunet_testing_plugin.h"
27 28
29GNUNET_NETWORK_STRUCT_BEGIN
30
31/**
32 * Message send to a child loop to inform the child loop about a barrier being advanced.
33 * FIXME: This is not packed and contains a char*... no payload documentation.
34 */
35struct GNUNET_TESTING_CommandBarrierAdvanced
36{
37 /**
38 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED
39 */
40 struct GNUNET_MessageHeader header;
41
42 /* followed by 0-terminated barrier name */
43};
44
45/**
46 * Message send by a child loop to inform the master loop how much
47 * GNUNET_CMDS_BARRIER_REACHED messages the child will send.
48 * FIXME: Not packed and contains char*; int in NBO? bitlength undefined.
49 */
50struct GNUNET_TESTING_CommandBarrierAttached
51{
52 /**
53 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED
54 */
55 struct GNUNET_MessageHeader header;
56
57 /**
58 * How often the child loop will reach the barrier.
59 */
60 uint32_t expected_reaches GNUNET_PACKED;
61
62 /**
63 * The number of the node the barrier is running on.
64 */
65 uint32_t node_number GNUNET_PACKED;
66
67 /* followed by 0-terminated barrier name */
68};
69
70struct GNUNET_TESTING_CommandBarrierReached
71{
72 /**
73 * Type is GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED
74 */
75 struct GNUNET_MessageHeader header;
76
77 /**
78 * The number of the node the barrier is reached.
79 */
80 uint32_t node_number GNUNET_PACKED;
81
82 /**
83 * The number of reach messages which most likely will send.
84 */
85 uint32_t expected_number_of_reached_messages GNUNET_PACKED;
86
87 /* followed by 0-terminated barrier name */
88};
89
90GNUNET_NETWORK_STRUCT_END
28 91
29/** 92/**
30 * Handle for a plugin. 93 * Handle for a plugin.
@@ -153,6 +216,7 @@ struct GNUNET_TESTING_Barrier
153 unsigned int shadow; 216 unsigned int shadow;
154}; 217};
155 218
219
156/** 220/**
157 * Advance internal pointer to next command. 221 * Advance internal pointer to next command.
158 * 222 *
@@ -196,6 +260,127 @@ GNUNET_TESTING_cmd_batch_set_current_ (const struct GNUNET_TESTING_Command *cmd,
196 unsigned int new_ip); 260 unsigned int new_ip);
197 261
198 262
263// Wait for barrier to be reached by all;
264// async version implies reached but does not
265// wait on other peers to reach it.
266/**
267 * FIXME: Documentation
268 * Create command.
269 *
270 * @param label name for command.
271 * @param barrier_label The name of the barrier we wait for and which will be reached.
272 * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL.
273 * @param asynchronous_finish If GNUNET_YES this command will not block. Can be NULL.
274 * @param node_number The global numer of the node the cmd runs on.
275 * @param running_on_master Is this cmd running on the master loop.
276 * @param write_message Callback to write messages to the master loop.
277 * @return command.
278 */
279struct GNUNET_TESTING_Command
280GNUNET_TESTING_cmd_barrier_reached (
281 const char *label,
282 const char *barrier_label,
283 unsigned int asynchronous_finish,
284 unsigned int node_number,
285 unsigned int running_on_master,
286 GNUNET_TESTING_cmd_helper_write_cb write_message);
287
288
289/**
290 * FIXME: Return type
291 * FIXME: Documentation
292 * Can we advance the barrier?
293 *
294 * @param barrier The barrier in question.
295 * @return GNUNET_YES if we can advance the barrier, GNUNET_NO if not.
296 */
297unsigned int
298GNUNET_TESTING_can_barrier_advance (struct GNUNET_TESTING_Barrier *barrier);
299
300
301/**
302 * FIXME: Naming
303 * Send Message to netjail nodes that a barrier can be advanced.
304 *
305 * @param is The interpreter loop.
306 * @param barrier_name The name of the barrier to advance.
307 * @param global_node_number The global number of the node to inform.
308 */
309void
310GNUNET_TESTING_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
311 const char *barrier_name,
312 unsigned int global_node_number);
313
314
315/**
316 * Finish all "barrier reached" comands attached to this barrier.
317 *
318 * @param barrier The barrier in question.
319 */
320void
321GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
322 const char *barrier_name);
323
324
325/**
326 * Send Message to master loop that cmds being attached to a barrier.
327 *
328 * @param is The interpreter loop.
329 * @param barrier_name The name of the barrier to advance.
330 * @param subnet_number The number of the subnet.
331 * @param node_number The node to inform.
332 * @param write_message Callback to write messages to the master loop.
333 */
334void
335GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
336 char *barrier_name,
337 unsigned int global_node_number,
338 unsigned int expected_reaches,
339 GNUNET_TESTING_cmd_helper_write_cb write_message);
340
341
342/**
343 * Getting a node from a map by global node number.
344 *
345 * @param nodes The map.
346 * @param node_number The global node number.
347 * @return The node.
348 */
349struct GNUNET_TESTING_NetjailNode *
350GNUNET_TESTING_barrier_get_node (struct GNUNET_CONTAINER_MultiShortmap *nodes,
351 unsigned int node_number);
352
353
354/**
355 * Deleting all barriers create in the context of this interpreter.
356 *
357 * @param is The interpreter.
358 */
359void
360GNUNET_TESTING_delete_barriers (struct GNUNET_TESTING_Interpreter *is);
361
362
363/**
364 * Getting a barrier from the interpreter.
365 *
366 * @param is The interpreter.
367 * @param barrier_name The name of the barrier.
368 * @return The barrier.
369 */
370struct GNUNET_TESTING_Barrier *
371GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
372 const char *barrier_name);
373
374
375/**
376 * Add a barrier to the loop.
377 *
378 * @param is The interpreter.
379 * @param barrier The barrier to add.
380 */
381void
382GNUNET_TESTING_interpreter_add_barrier (struct GNUNET_TESTING_Interpreter *is,
383 struct GNUNET_TESTING_Barrier *barrier);
199 384
200 385
201#endif 386#endif
diff --git a/src/testing/testing_api_cmd_barrier.c b/src/testing/testing_api_cmd_barrier.c
index 64cefd235..d27ce9d94 100644
--- a/src/testing/testing_api_cmd_barrier.c
+++ b/src/testing/testing_api_cmd_barrier.c
@@ -62,12 +62,14 @@ GNUNET_TESTING_send_barrier_attach (struct GNUNET_TESTING_Interpreter *is,
62{ 62{
63 struct GNUNET_TESTING_CommandBarrierAttached *atm = GNUNET_new (struct GNUNET_TESTING_CommandBarrierAttached); 63 struct GNUNET_TESTING_CommandBarrierAttached *atm = GNUNET_new (struct GNUNET_TESTING_CommandBarrierAttached);
64 size_t msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierAttached); 64 size_t msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierAttached);
65 size_t name_len;
65 66
67 name_len = strlen (barrier_name) + 1;
66 atm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED); 68 atm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ATTACHED);
67 atm->header.size = htons ((uint16_t) msg_length); 69 atm->header.size = htons ((uint16_t) msg_length);
68 atm->barrier_name = barrier_name;
69 atm->expected_reaches = expected_reaches; 70 atm->expected_reaches = expected_reaches;
70 atm->node_number = global_node_number; 71 atm->node_number = global_node_number;
72 memcpy (&atm[1], barrier_name, name_len);
71 write_message ((struct GNUNET_MessageHeader *) atm, msg_length); 73 write_message ((struct GNUNET_MessageHeader *) atm, msg_length);
72 74
73 GNUNET_free (atm); 75 GNUNET_free (atm);
@@ -88,10 +90,12 @@ GNUNET_TESTING_send_barrier_advance (struct GNUNET_TESTING_Interpreter *is,
88{ 90{
89 struct GNUNET_TESTING_CommandBarrierAdvanced *adm = GNUNET_new (struct GNUNET_TESTING_CommandBarrierAdvanced); 91 struct GNUNET_TESTING_CommandBarrierAdvanced *adm = GNUNET_new (struct GNUNET_TESTING_CommandBarrierAdvanced);
90 size_t msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierAdvanced); 92 size_t msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierAdvanced);
93 size_t name_len;
91 94
95 name_len = strlen (barrier_name) + 1;
92 adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED); 96 adm->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_ADVANCED);
93 adm->header.size = htons ((uint16_t) msg_length); 97 adm->header.size = htons ((uint16_t) msg_length);
94 adm->barrier_name = barrier_name; 98 memcpy (&adm[1], barrier_name, name_len);
95 GNUNET_TESTING_send_message_to_netjail (is, 99 GNUNET_TESTING_send_message_to_netjail (is,
96 global_node_number, 100 global_node_number,
97 &adm->header); 101 &adm->header);
@@ -225,15 +229,3 @@ GNUNET_TESTING_cmd_barrier_create (const char *label,
225 &barrier_traits, 229 &barrier_traits,
226 NULL); 230 NULL);
227} 231}
228
229/**
230 * FIXME: Not sure if this is correct here
231 */
232struct GNUNET_TESTING_Barrier*
233GNUNET_TESTING_barrier_new (const char* testcase_name)
234{
235 struct GNUNET_TESTING_Barrier *barr;
236 barr = GNUNET_new (struct GNUNET_TESTING_Barrier);
237 barr->name = GNUNET_strdup (testcase_name);
238 return barr;
239}
diff --git a/src/testing/testing_api_cmd_barrier_reached.c b/src/testing/testing_api_cmd_barrier_reached.c
index 58f420214..eca422b1d 100644
--- a/src/testing/testing_api_cmd_barrier_reached.c
+++ b/src/testing/testing_api_cmd_barrier_reached.c
@@ -91,6 +91,7 @@ barrier_reached_run (void *cls,
91 struct CommandListEntry *cle; 91 struct CommandListEntry *cle;
92 size_t msg_length; 92 size_t msg_length;
93 struct GNUNET_TESTING_CommandBarrierReached *msg; 93 struct GNUNET_TESTING_CommandBarrierReached *msg;
94 size_t name_len;
94 95
95 barrier = GNUNET_TESTING_get_barrier (is, brs->barrier_name); 96 barrier = GNUNET_TESTING_get_barrier (is, brs->barrier_name);
96 if (NULL == barrier) 97 if (NULL == barrier)
@@ -106,7 +107,7 @@ barrier_reached_run (void *cls,
106 //FIXME cmd uninitialized 107 //FIXME cmd uninitialized
107 GNUNET_assert (NULL != cmd); 108 GNUNET_assert (NULL != cmd);
108 cmd->asynchronous_finish = GNUNET_YES; 109 cmd->asynchronous_finish = GNUNET_YES;
109 GNUNET_TESTING_finish_attached_cmds (is, barrier); 110 GNUNET_TESTING_finish_attached_cmds (is, barrier->name);
110 } 111 }
111 else if (GNUNET_NO == brs->asynchronous_finish) 112 else if (GNUNET_NO == brs->asynchronous_finish)
112 { 113 {
@@ -126,11 +127,12 @@ barrier_reached_run (void *cls,
126 } 127 }
127 if (GNUNET_NO == brs->running_on_master) 128 if (GNUNET_NO == brs->running_on_master)
128 { 129 {
130 name_len = strlen (barrier->name) + 1;
129 msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached); 131 msg_length = sizeof(struct GNUNET_TESTING_CommandBarrierReached);
130 msg = GNUNET_new (struct GNUNET_TESTING_CommandBarrierReached); 132 msg = GNUNET_new (struct GNUNET_TESTING_CommandBarrierReached);
131 msg->header.size = htons ((uint16_t) msg_length); 133 msg->header.size = htons ((uint16_t) msg_length);
132 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED); 134 msg->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_BARRIER_REACHED);
133 msg->barrier_name = barrier->name; 135 memcpy (&msg[1], barrier->name, name_len);
134 msg->node_number = brs->node_number; 136 msg->node_number = brs->node_number;
135 brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length); 137 brs->write_message ((struct GNUNET_MessageHeader *) msg, msg_length);
136 } 138 }
diff --git a/src/testing/testing_api_cmd_netjail_start_testsystem.c b/src/testing/testing_api_cmd_netjail_start_testsystem.c
index a1712c7b5..09f767b7a 100644
--- a/src/testing/testing_api_cmd_netjail_start_testsystem.c
+++ b/src/testing/testing_api_cmd_netjail_start_testsystem.c
@@ -350,9 +350,11 @@ barrier_attached (struct NetJailState *ns, const struct
350 struct GNUNET_TESTING_Barrier *barrier; 350 struct GNUNET_TESTING_Barrier *barrier;
351 struct GNUNET_ShortHashCode key; 351 struct GNUNET_ShortHashCode key;
352 struct GNUNET_HashCode hc; 352 struct GNUNET_HashCode hc;
353 const char *barrier_name;
353 354
354 am = (struct GNUNET_TESTING_CommandBarrierAttached *) message; 355 am = (struct GNUNET_TESTING_CommandBarrierAttached *) message;
355 barrier = GNUNET_TESTING_get_barrier (ns->is, am->barrier_name); 356 barrier_name = (const char *) &am[1];
357 barrier = GNUNET_TESTING_get_barrier (ns->is, barrier_name);
356 GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow); 358 GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow);
357 node = GNUNET_TESTING_barrier_get_node (barrier->nodes, am->node_number); 359 node = GNUNET_TESTING_barrier_get_node (barrier->nodes, am->node_number);
358 if (NULL == node) 360 if (NULL == node)
@@ -376,18 +378,19 @@ void
376barrier_reached (struct NetJailState *ns, const struct 378barrier_reached (struct NetJailState *ns, const struct
377 GNUNET_MessageHeader *message) 379 GNUNET_MessageHeader *message)
378{ 380{
381 struct GNUNET_TESTING_Barrier *barrier;
382 const char *barrier_name;
379 struct GNUNET_TESTING_CommandBarrierReached *rm = (struct 383 struct GNUNET_TESTING_CommandBarrierReached *rm = (struct
380 GNUNET_TESTING_CommandBarrierReached 384 GNUNET_TESTING_CommandBarrierReached
381 *) message; 385 *) message;
382 struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (ns->is,
383 rm->
384 barrier_name);
385 386
387 barrier_name = (const char *) &rm[1];
388 barrier = GNUNET_TESTING_get_barrier (ns->is, barrier_name);
386 GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow); 389 GNUNET_assert (NULL != barrier && GNUNET_NO == barrier->shadow);
387 barrier->reached++; 390 barrier->reached++;
388 if (GNUNET_TESTING_can_barrier_advance (barrier)) 391 if (GNUNET_TESTING_can_barrier_advance (barrier))
389 { 392 {
390 GNUNET_TESTING_finish_attached_cmds (ns->is, barrier); 393 GNUNET_TESTING_finish_attached_cmds (ns->is, barrier->name);
391 } 394 }
392} 395}
393 396
@@ -699,19 +702,21 @@ start_helper (struct NetJailState *ns,
699 702
700 for (pos = barriers->head; NULL != pos; pos = pos->next) 703 for (pos = barriers->head; NULL != pos; pos = pos->next)
701 { 704 {
702 barrier = GNUNET_TESTING_get_barrier (ns->is, pos->barrier->name); 705 barrier = GNUNET_TESTING_get_barrier (ns->is, pos->barrier_name);
703 if (NULL == barrier || GNUNET_YES == barrier->shadow) 706 if (NULL == barrier || GNUNET_YES == barrier->shadow)
704 { 707 {
705 GNUNET_TESTING_interpreter_add_barrier (ns->is, pos->barrier); 708 barrier = GNUNET_new (struct GNUNET_TESTING_Barrier);
706 barrier = pos->barrier; 709 barrier->name = pos->barrier_name;
710 GNUNET_TESTING_interpreter_add_barrier (ns->is, barrier);
711
707 barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO); 712 barrier->nodes = GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
708 } 713 }
709 GNUNET_assert (NULL != node); 714 GNUNET_assert (NULL != node);
710 barrier_node = GNUNET_new (struct GNUNET_TESTING_NetjailNode); 715 barrier_node = GNUNET_new (struct GNUNET_TESTING_NetjailNode);
711 barrier_node->node_number = node->node_number; 716 barrier_node->node_number = node->node_number;
712 barrier_node->expected_reaches = pos->barrier->expected_reaches; 717 barrier_node->expected_reaches = pos->expected_reaches;
713 barrier->expected_reaches = barrier->expected_reaches 718 barrier->expected_reaches = barrier->expected_reaches
714 + pos->barrier->expected_reaches; 719 + pos->expected_reaches;
715 GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc); 720 GNUNET_CRYPTO_hash (&(node->node_number), sizeof(node->node_number), &hc);
716 memcpy (&key, &hc, sizeof (key)); 721 memcpy (&key, &hc, sizeof (key));
717 GNUNET_CONTAINER_multishortmap_put (barrier->nodes, 722 GNUNET_CONTAINER_multishortmap_put (barrier->nodes,
diff --git a/src/testing/testing_api_loop.c b/src/testing/testing_api_loop.c
index e8680fc13..d7456b91f 100644
--- a/src/testing/testing_api_loop.c
+++ b/src/testing/testing_api_loop.c
@@ -688,16 +688,43 @@ free_barrier_node_cb (void *cls,
688 688
689 689
690/** 690/**
691 * Getting a barrier from the interpreter.
692 *
693 * @param is The interpreter.
694 * @param barrier_name The name of the barrier.
695 * @return The barrier.
696 */
697struct GNUNET_TESTING_Barrier *
698GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
699 const char *barrier_name)
700{
701 struct GNUNET_HashCode hc;
702 struct GNUNET_ShortHashCode create_key;
703 struct GNUNET_TESTING_Barrier *barrier;
704
705 GNUNET_CRYPTO_hash (barrier_name, strlen (barrier_name), &hc);
706 memcpy (&create_key,
707 &hc,
708 sizeof (create_key));
709 barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key);
710 // GNUNET_free (create_key);
711 return barrier;
712}
713
714
715/**
691 * Finish all "barrier reached" comands attached to this barrier. 716 * Finish all "barrier reached" comands attached to this barrier.
692 * 717 *
693 * @param barrier The barrier in question. 718 * @param barrier The barrier in question.
694 */ 719 */
695void 720void
696GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, 721GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is,
697 struct GNUNET_TESTING_Barrier *barrier) 722 const char *barrier_name)
698{ 723{
699 struct CommandListEntry *pos; 724 struct CommandListEntry *pos;
700 struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls; 725 struct FreeBarrierNodeCbCls *free_barrier_node_cb_cls;
726 struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is,
727 barrier_name);
701 728
702 while (NULL != (pos = barrier->cmds_head)) 729 while (NULL != (pos = barrier->cmds_head))
703 { 730 {
@@ -771,29 +798,6 @@ GNUNET_TESTING_delete_barriers (struct GNUNET_TESTING_Interpreter *is)
771 GNUNET_CONTAINER_multishortmap_destroy (is->barriers); 798 GNUNET_CONTAINER_multishortmap_destroy (is->barriers);
772} 799}
773 800
774/**
775 * Getting a barrier from the interpreter.
776 *
777 * @param is The interpreter.
778 * @param barrier_name The name of the barrier.
779 * @return The barrier.
780 */
781struct GNUNET_TESTING_Barrier *
782GNUNET_TESTING_get_barrier (struct GNUNET_TESTING_Interpreter *is,
783 const char *barrier_name)
784{
785 struct GNUNET_HashCode hc;
786 struct GNUNET_ShortHashCode create_key;
787 struct GNUNET_TESTING_Barrier *barrier;
788
789 GNUNET_CRYPTO_hash (barrier_name, strlen (barrier_name), &hc);
790 memcpy (&create_key,
791 &hc,
792 sizeof (create_key));
793 barrier = GNUNET_CONTAINER_multishortmap_get (is->barriers, &create_key);
794 // GNUNET_free (create_key);
795 return barrier;
796}
797 801
798/** 802/**
799 * Add a barrier to the loop. 803 * Add a barrier to the loop.