aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_block_until_all_peers_started.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_block_until_all_peers_started.c')
-rw-r--r--src/testing/testing_api_cmd_block_until_all_peers_started.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/testing/testing_api_cmd_block_until_all_peers_started.c b/src/testing/testing_api_cmd_block_until_all_peers_started.c
index 8659fbb46..e9d3f0ed3 100644
--- a/src/testing/testing_api_cmd_block_until_all_peers_started.c
+++ b/src/testing/testing_api_cmd_block_until_all_peers_started.c
@@ -32,12 +32,24 @@
32 */ 32 */
33#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) 33#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
34 34
35/**
36 * Struct with information for callbacks.
37 *
38 */
35struct BlockState 39struct BlockState
36{ 40{
41 /**
42 * Flag to indicate if all peers have started.
43 *
44 */
37 unsigned int *all_peers_started; 45 unsigned int *all_peers_started;
38}; 46};
39 47
40 48
49/**
50 * Trait function of this cmd does nothing.
51 *
52 */
41static int 53static int
42block_until_all_peers_started_traits (void *cls, 54block_until_all_peers_started_traits (void *cls,
43 const void **ret, 55 const void **ret,
@@ -48,6 +60,10 @@ block_until_all_peers_started_traits (void *cls,
48} 60}
49 61
50 62
63/**
64 * The cleanup function of this cmd frees resources the cmd allocated.
65 *
66 */
51static void 67static void
52block_until_all_peers_started_cleanup (void *cls, 68block_until_all_peers_started_cleanup (void *cls,
53 const struct GNUNET_TESTING_Command *cmd) 69 const struct GNUNET_TESTING_Command *cmd)
@@ -58,16 +74,24 @@ block_until_all_peers_started_cleanup (void *cls,
58} 74}
59 75
60 76
77/**
78 * This function does nothing but to start the cmd.
79 *
80 */
61static void 81static void
62block_until_all_peers_started_run (void *cls, 82block_until_all_peers_started_run (void *cls,
63 const struct GNUNET_TESTING_Command *cmd, 83 const struct GNUNET_TESTING_Command *cmd,
64 struct GNUNET_TESTING_Interpreter *is) 84 struct GNUNET_TESTING_Interpreter *is)
65{ 85{
66 LOG (GNUNET_ERROR_TYPE_ERROR, 86 LOG (GNUNET_ERROR_TYPE_DEBUG,
67 "block_until_all_peers_started_run!\n"); 87 "block_until_all_peers_started_run!\n");
68} 88}
69 89
70 90
91/**
92 * Function to check if BlockState#all_peers_started is GNUNET_YES. In that case interpreter_next will be called.
93 *
94 */
71static int 95static int
72block_until_all_peers_started_finish (void *cls, 96block_until_all_peers_started_finish (void *cls,
73 GNUNET_SCHEDULER_TaskCallback cont, 97 GNUNET_SCHEDULER_TaskCallback cont,
@@ -76,20 +100,10 @@ block_until_all_peers_started_finish (void *cls,
76 struct BlockState *bs = cls; 100 struct BlockState *bs = cls;
77 unsigned int *ret = bs->all_peers_started; 101 unsigned int *ret = bs->all_peers_started;
78 102
79 LOG (GNUNET_ERROR_TYPE_ERROR,
80 "We got here 10\n");
81
82 if (GNUNET_YES == *ret) 103 if (GNUNET_YES == *ret)
83 { 104 {
84 LOG (GNUNET_ERROR_TYPE_ERROR,
85 "We do not need to block anymore!\n");
86 cont (cont_cls); 105 cont (cont_cls);
87 } 106 }
88 else
89 {
90 LOG (GNUNET_ERROR_TYPE_ERROR,
91 "You shall not pass!\n");
92 }
93 107
94 return *ret; 108 return *ret;
95} 109}
@@ -99,6 +113,7 @@ block_until_all_peers_started_finish (void *cls,
99 * Create command. 113 * Create command.
100 * 114 *
101 * @param label name for command. 115 * @param label name for command.
116 * @param all_peers_started Flag which will be set from outside.
102 * @return command. 117 * @return command.
103 */ 118 */
104struct GNUNET_TESTING_Command 119struct GNUNET_TESTING_Command
@@ -108,10 +123,6 @@ GNUNET_TESTING_cmd_block_until_all_peers_started (const char *label,
108{ 123{
109 struct BlockState *bs; 124 struct BlockState *bs;
110 125
111 LOG (GNUNET_ERROR_TYPE_ERROR,
112 "we have all_peers_started: %u\n",
113 *all_peers_started);
114
115 bs = GNUNET_new (struct BlockState); 126 bs = GNUNET_new (struct BlockState);
116 bs->all_peers_started = all_peers_started; 127 bs->all_peers_started = all_peers_started;
117 128