diff options
Diffstat (limited to 'src/testing/testing_api_loop.c')
-rw-r--r-- | src/testing/testing_api_loop.c | 52 |
1 files changed, 28 insertions, 24 deletions
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 | */ | ||
697 | struct GNUNET_TESTING_Barrier * | ||
698 | GNUNET_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 | */ |
695 | void | 720 | void |
696 | GNUNET_TESTING_finish_attached_cmds (struct GNUNET_TESTING_Interpreter *is, | 721 | GNUNET_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 | */ | ||
781 | struct GNUNET_TESTING_Barrier * | ||
782 | GNUNET_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. |