aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_local_test_finished.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_local_test_finished.c')
-rw-r--r--src/testing/testing_api_cmd_local_test_finished.c67
1 files changed, 18 insertions, 49 deletions
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c
index b50e471e9..0e7e214dc 100644
--- a/src/testing/testing_api_cmd_local_test_finished.c
+++ b/src/testing/testing_api_cmd_local_test_finished.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21/** 21/**
22 * @file testing_api_cmd_block_until_all_peers_started.c 22 * @file testing_api_cmd_local_test_finished.c
23 * @brief cmd to block the interpreter loop until all peers started. 23 * @brief cmd to block the interpreter loop until all peers started.
24 * @author t3sserakt 24 * @author t3sserakt
25 */ 25 */
@@ -40,6 +40,7 @@
40 */ 40 */
41struct LocalFinishedState 41struct LocalFinishedState
42{ 42{
43
43 /** 44 /**
44 * Callback to write messages to the master loop. 45 * Callback to write messages to the master loop.
45 * 46 *
@@ -55,26 +56,11 @@ struct LocalFinishedState
55 56
56 57
57/** 58/**
58 * Trait function of this cmd does nothing.
59 *
60 */
61static int
62local_test_finished_traits (void *cls,
63 const void **ret,
64 const char *trait,
65 unsigned int index)
66{
67 return GNUNET_OK;
68}
69
70
71/**
72 * The cleanup function of this cmd frees resources the cmd allocated. 59 * The cleanup function of this cmd frees resources the cmd allocated.
73 * 60 *
74 */ 61 */
75static void 62static void
76local_test_finished_cleanup (void *cls, 63local_test_finished_cleanup (void *cls)
77 const struct GNUNET_TESTING_Command *cmd)
78{ 64{
79 struct LocalFinishedState *lfs = cls; 65 struct LocalFinishedState *lfs = cls;
80 66
@@ -89,11 +75,9 @@ local_test_finished_cleanup (void *cls,
89 */ 75 */
90static void 76static void
91local_test_finished_run (void *cls, 77local_test_finished_run (void *cls,
92 const struct GNUNET_TESTING_Command *cmd,
93 struct GNUNET_TESTING_Interpreter *is) 78 struct GNUNET_TESTING_Interpreter *is)
94{ 79{
95 struct LocalFinishedState *lfs = cls; 80 struct LocalFinishedState *lfs = cls;
96
97 struct GNUNET_CMDS_LOCAL_FINISHED *reply; 81 struct GNUNET_CMDS_LOCAL_FINISHED *reply;
98 size_t msg_length; 82 size_t msg_length;
99 83
@@ -102,22 +86,8 @@ local_test_finished_run (void *cls,
102 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); 86 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
103 reply->header.size = htons ((uint16_t) msg_length); 87 reply->header.size = htons ((uint16_t) msg_length);
104 lfs->reply = reply; 88 lfs->reply = reply;
105 lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); 89 lfs->write_message ((struct GNUNET_MessageHeader *) reply,
106} 90 msg_length);
107
108
109/**
110 * This finish function will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method.
111 *
112 */
113static int
114local_test_finished_finish (void *cls,
115 GNUNET_SCHEDULER_TaskCallback cont,
116 void *cont_cls)
117{
118 LOG (GNUNET_ERROR_TYPE_ERROR,
119 "Stopping local loop\n");
120 return GNUNET_YES;
121} 91}
122 92
123 93
@@ -129,23 +99,22 @@ local_test_finished_finish (void *cls,
129 * @return command. 99 * @return command.
130 */ 100 */
131struct GNUNET_TESTING_Command 101struct GNUNET_TESTING_Command
132GNUNET_TESTING_cmd_local_test_finished (const char *label, 102GNUNET_TESTING_cmd_local_test_finished (
133 TESTING_CMD_HELPER_write_cb 103 const char *label,
134 write_message) 104 TESTING_CMD_HELPER_write_cb write_message)
135{ 105{
136 struct LocalFinishedState *lfs; 106 struct LocalFinishedState *lfs;
137 107
138 lfs = GNUNET_new (struct LocalFinishedState); 108 lfs = GNUNET_new (struct LocalFinishedState);
139 lfs->write_message = write_message; 109 lfs->write_message = write_message;
140 110 {
141 struct GNUNET_TESTING_Command cmd = { 111 struct GNUNET_TESTING_Command cmd = {
142 .cls = lfs, 112 .cls = lfs,
143 .label = label, 113 .label = label,
144 .run = &local_test_finished_run, 114 .run = &local_test_finished_run,
145 .finish = &local_test_finished_finish, 115 .cleanup = &local_test_finished_cleanup,
146 .cleanup = &local_test_finished_cleanup, 116 };
147 .traits = &local_test_finished_traits 117
148 }; 118 return cmd;
149 119 }
150 return cmd;
151} 120}