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.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/src/testing/testing_api_cmd_local_test_finished.c b/src/testing/testing_api_cmd_local_test_finished.c
index 5b74d4e04..383de4c10 100644
--- a/src/testing/testing_api_cmd_local_test_finished.c
+++ b/src/testing/testing_api_cmd_local_test_finished.c
@@ -33,14 +33,31 @@
33 */ 33 */
34#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) 34#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
35 35
36
37/**
38 * Struct to hold information for callbacks.
39 *
40 */
36struct LocalFinishedState 41struct LocalFinishedState
37{ 42{
43 /**
44 * Callback to write messages to the master loop.
45 *
46 */
38 TESTING_CMD_HELPER_write_cb write_message; 47 TESTING_CMD_HELPER_write_cb write_message;
39 48
49 /**
50 * The message send back to the master loop.
51 *
52 */
40 struct GNUNET_CMDS_LOCAL_FINISHED *reply; 53 struct GNUNET_CMDS_LOCAL_FINISHED *reply;
41}; 54};
42 55
43 56
57/**
58 * Trait function of this cmd does nothing.
59 *
60 */
44static int 61static int
45local_test_finished_traits (void *cls, 62local_test_finished_traits (void *cls,
46 const void **ret, 63 const void **ret,
@@ -51,6 +68,10 @@ local_test_finished_traits (void *cls,
51} 68}
52 69
53 70
71/**
72 * The cleanup function of this cmd frees resources the cmd allocated.
73 *
74 */
54static void 75static void
55local_test_finished_cleanup (void *cls, 76local_test_finished_cleanup (void *cls,
56 const struct GNUNET_TESTING_Command *cmd) 77 const struct GNUNET_TESTING_Command *cmd)
@@ -62,6 +83,10 @@ local_test_finished_cleanup (void *cls,
62} 83}
63 84
64 85
86/**
87 * This function sends a GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED message to the master loop.
88 *
89 */
65static void 90static void
66local_test_finished_run (void *cls, 91local_test_finished_run (void *cls,
67 const struct GNUNET_TESTING_Command *cmd, 92 const struct GNUNET_TESTING_Command *cmd,
@@ -72,28 +97,25 @@ local_test_finished_run (void *cls,
72 struct GNUNET_CMDS_LOCAL_FINISHED *reply; 97 struct GNUNET_CMDS_LOCAL_FINISHED *reply;
73 size_t msg_length; 98 size_t msg_length;
74 99
75 LOG (GNUNET_ERROR_TYPE_ERROR,
76 "We got here 12!\n");
77
78 msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED); 100 msg_length = sizeof(struct GNUNET_CMDS_LOCAL_FINISHED);
79 reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED); 101 reply = GNUNET_new (struct GNUNET_CMDS_LOCAL_FINISHED);
80 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED); 102 reply->header.type = htons (GNUNET_MESSAGE_TYPE_CMDS_HELPER_LOCAL_FINISHED);
81 reply->header.size = htons ((uint16_t) msg_length); 103 reply->header.size = htons ((uint16_t) msg_length);
82 lfs->reply = reply; 104 lfs->reply = reply;
83 lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length); 105 lfs->write_message ((struct GNUNET_MessageHeader *) reply, msg_length);
84
85 LOG (GNUNET_ERROR_TYPE_ERROR,
86 "We got here 13!\n");
87} 106}
88 107
89 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 */
90static int 113static int
91local_test_finished_finish (void *cls, 114local_test_finished_finish (void *cls,
92 GNUNET_SCHEDULER_TaskCallback cont, 115 GNUNET_SCHEDULER_TaskCallback cont,
93 void *cont_cls) 116 void *cont_cls)
94{ 117{
95 // This will stop the local loop without shutting down the scheduler, because we do not call the continuation, which is the interpreter_next method. 118 LOG (GNUNET_ERROR_TYPE_DEBUG,
96 LOG (GNUNET_ERROR_TYPE_ERROR,
97 "Stopping local loop\n"); 119 "Stopping local loop\n");
98 return GNUNET_YES; 120 return GNUNET_YES;
99} 121}
@@ -103,6 +125,7 @@ local_test_finished_finish (void *cls,
103 * Create command. 125 * Create command.
104 * 126 *
105 * @param label name for command. 127 * @param label name for command.
128 * @param write_message Callback to write messages to the master loop.
106 * @return command. 129 * @return command.
107 */ 130 */
108struct GNUNET_TESTING_Command 131struct GNUNET_TESTING_Command
@@ -112,9 +135,6 @@ GNUNET_TESTING_cmd_local_test_finished (const char *label,
112{ 135{
113 struct LocalFinishedState *lfs; 136 struct LocalFinishedState *lfs;
114 137
115 LOG (GNUNET_ERROR_TYPE_ERROR,
116 "We got here 11!\n");
117
118 lfs = GNUNET_new (struct LocalFinishedState); 138 lfs = GNUNET_new (struct LocalFinishedState);
119 lfs->write_message = write_message; 139 lfs->write_message = write_message;
120 140