diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-03-28 09:32:38 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-03-28 09:32:38 +0000 |
commit | d03ca6000941d0cee31fff6469f4f1aa00b8efb3 (patch) | |
tree | 8eb9df346fb08c3059bb941a5911ba3fa1b2135b /src | |
parent | 4050bda2c2f530ba392bd5473c66298602072008 (diff) | |
download | gnunet-d03ca6000941d0cee31fff6469f4f1aa00b8efb3.tar.gz gnunet-d03ca6000941d0cee31fff6469f4f1aa00b8efb3.zip |
-test cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/test_arm_api.c | 65 | ||||
-rw-r--r-- | src/arm/test_exponential_backoff.c | 45 | ||||
-rw-r--r-- | src/arm/test_gnunet_service_arm.c | 35 |
3 files changed, 82 insertions, 63 deletions
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 65e8b7797..271746e6b 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include "gnunet_program_lib.h" | 30 | #include "gnunet_program_lib.h" |
31 | #include "gnunet_resolver_service.h" | 31 | #include "gnunet_resolver_service.h" |
32 | 32 | ||
33 | #define LOG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | ||
34 | |||
33 | #define START_ARM GNUNET_YES | 35 | #define START_ARM GNUNET_YES |
34 | 36 | ||
35 | #define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1500) | 37 | #define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 1500) |
@@ -53,7 +55,7 @@ arm_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStat | |||
53 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPING); | 55 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPING); |
54 | GNUNET_break (phase == 6); | 56 | GNUNET_break (phase == 6); |
55 | phase++; | 57 | phase++; |
56 | FPRINTF (stderr, "Sent 'STOP' request for arm to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); | 58 | LOG ("Sent 'STOP' request for arm to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); |
57 | } | 59 | } |
58 | 60 | ||
59 | static void | 61 | static void |
@@ -65,7 +67,7 @@ resolver_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_Reques | |||
65 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 67 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
66 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); | 68 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); |
67 | GNUNET_break (phase == 5); | 69 | GNUNET_break (phase == 5); |
68 | FPRINTF (stderr, "Sent 'STOP' request for resolver to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); | 70 | LOG ("Sent 'STOP' request for resolver to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); |
69 | phase++; | 71 | phase++; |
70 | #if START_ARM | 72 | #if START_ARM |
71 | GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, arm_stop_cb, NULL); | 73 | GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, arm_stop_cb, NULL); |
@@ -83,7 +85,7 @@ dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen) | |||
83 | /* (4), resolver should finish resolving localhost */ | 85 | /* (4), resolver should finish resolving localhost */ |
84 | GNUNET_break (phase == 4); | 86 | GNUNET_break (phase == 4); |
85 | phase++; | 87 | phase++; |
86 | FPRINTF (stderr, "%s", "Finished resolving localhost\n"); | 88 | LOG ("Finished resolving localhost\n"); |
87 | if (ok != 0) | 89 | if (ok != 0) |
88 | ok = 2; | 90 | ok = 2; |
89 | GNUNET_ARM_request_service_stop (arm, "resolver", TIMEOUT, resolver_stop_cb, NULL); | 91 | GNUNET_ARM_request_service_stop (arm, "resolver", TIMEOUT, resolver_stop_cb, NULL); |
@@ -91,7 +93,7 @@ dns_notify (void *cls, const struct sockaddr *addr, socklen_t addrlen) | |||
91 | } | 93 | } |
92 | /* (3), resolver should resolve localhost */ | 94 | /* (3), resolver should resolve localhost */ |
93 | GNUNET_break (phase == 3); | 95 | GNUNET_break (phase == 3); |
94 | FPRINTF (stderr, "%s", "Resolved localhost\n"); | 96 | LOG ("Resolved localhost\n"); |
95 | phase++; | 97 | phase++; |
96 | GNUNET_break (addr != NULL); | 98 | GNUNET_break (addr != NULL); |
97 | ok = 0; | 99 | ok = 0; |
@@ -106,7 +108,7 @@ resolver_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_Reque | |||
106 | GNUNET_assert (status == GNUNET_ARM_REQUEST_SENT_OK); | 108 | GNUNET_assert (status == GNUNET_ARM_REQUEST_SENT_OK); |
107 | GNUNET_break (phase == 2); | 109 | GNUNET_break (phase == 2); |
108 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); | 110 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); |
109 | FPRINTF (stderr, "Sent 'START' request for resolver to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); | 111 | LOG ("Sent 'START' request for resolver to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); |
110 | phase++; | 112 | phase++; |
111 | GNUNET_RESOLVER_ip_get ("localhost", AF_INET, TIMEOUT, &dns_notify, NULL); | 113 | GNUNET_RESOLVER_ip_get ("localhost", AF_INET, TIMEOUT, &dns_notify, NULL); |
112 | } | 114 | } |
@@ -118,8 +120,10 @@ trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
118 | } | 120 | } |
119 | 121 | ||
120 | 122 | ||
121 | void | 123 | static void |
122 | arm_conn (void *cls, struct GNUNET_ARM_Handle *arm, char connected) | 124 | arm_conn (void *cls, |
125 | struct GNUNET_ARM_Handle *arm, | ||
126 | int connected) | ||
123 | { | 127 | { |
124 | if (GNUNET_SYSERR == connected) | 128 | if (GNUNET_SYSERR == connected) |
125 | { | 129 | { |
@@ -132,7 +136,7 @@ arm_conn (void *cls, struct GNUNET_ARM_Handle *arm, char connected) | |||
132 | if (GNUNET_YES == connected) | 136 | if (GNUNET_YES == connected) |
133 | { | 137 | { |
134 | /* (1), arm connection should be established */ | 138 | /* (1), arm connection should be established */ |
135 | FPRINTF (stderr, "%s", "Connected to ARM\n"); | 139 | LOG ("Connected to ARM\n"); |
136 | GNUNET_break (phase == 1); | 140 | GNUNET_break (phase == 1); |
137 | phase++; | 141 | phase++; |
138 | GNUNET_ARM_request_service_start (arm, "resolver", GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, resolver_start_cb, NULL); | 142 | GNUNET_ARM_request_service_start (arm, "resolver", GNUNET_OS_INHERIT_STD_OUT_AND_ERR, START_TIMEOUT, resolver_start_cb, NULL); |
@@ -140,7 +144,7 @@ arm_conn (void *cls, struct GNUNET_ARM_Handle *arm, char connected) | |||
140 | else | 144 | else |
141 | { | 145 | { |
142 | /* (7), ARM should stop (we disconnect from it) */ | 146 | /* (7), ARM should stop (we disconnect from it) */ |
143 | FPRINTF (stderr, "%s", "Disconnected from ARM\n"); | 147 | LOG ("Disconnected from ARM\n"); |
144 | GNUNET_break (phase == 7); | 148 | GNUNET_break (phase == 7); |
145 | if (phase != 7) | 149 | if (phase != 7) |
146 | ok = 3; | 150 | ok = 3; |
@@ -150,15 +154,16 @@ arm_conn (void *cls, struct GNUNET_ARM_Handle *arm, char connected) | |||
150 | } | 154 | } |
151 | } | 155 | } |
152 | 156 | ||
153 | void | 157 | |
158 | static void | ||
154 | srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status) | 159 | srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status) |
155 | { | 160 | { |
156 | FPRINTF (stderr, "Service %s is %u\n", service, status); | 161 | LOG ("Service %s is %u\n", service, status); |
157 | switch (phase) | 162 | switch (phase) |
158 | { | 163 | { |
159 | default: | 164 | default: |
160 | FPRINTF (stderr, "Unexpectedly got status %u for service %s\n", status, | 165 | LOG ("Unexpectedly got status %u for service %s\n", status, |
161 | service); | 166 | service); |
162 | GNUNET_break (0); | 167 | GNUNET_break (0); |
163 | ok = 2; | 168 | ok = 2; |
164 | #if START_ARM | 169 | #if START_ARM |
@@ -167,8 +172,13 @@ srv_status (void *cls, const char *service, enum GNUNET_ARM_ServiceStatus status | |||
167 | } | 172 | } |
168 | } | 173 | } |
169 | 174 | ||
175 | |||
170 | static void | 176 | static void |
171 | arm_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result) | 177 | arm_start_cb (void *cls, |
178 | struct GNUNET_ARM_Handle *h, | ||
179 | enum GNUNET_ARM_RequestStatus status, | ||
180 | const char *servicename, | ||
181 | enum GNUNET_ARM_Result result) | ||
172 | { | 182 | { |
173 | /* (0) The request should be "sent" successfully | 183 | /* (0) The request should be "sent" successfully |
174 | * ("sent", because it isn't going anywhere, ARM API starts ARM service | 184 | * ("sent", because it isn't going anywhere, ARM API starts ARM service |
@@ -177,11 +187,12 @@ arm_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestSta | |||
177 | */ | 187 | */ |
178 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 188 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
179 | GNUNET_break (phase == 0); | 189 | GNUNET_break (phase == 0); |
180 | FPRINTF (stderr, "Sent 'START' request for arm to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); | 190 | LOG ("Sent 'START' request for arm to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); |
181 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); | 191 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); |
182 | phase++; | 192 | phase++; |
183 | } | 193 | } |
184 | 194 | ||
195 | |||
185 | static void | 196 | static void |
186 | task (void *cls, char *const *args, const char *cfgfile, | 197 | task (void *cls, char *const *args, const char *cfgfile, |
187 | const struct GNUNET_CONFIGURATION_Handle *c) | 198 | const struct GNUNET_CONFIGURATION_Handle *c) |
@@ -201,7 +212,7 @@ task (void *cls, char *const *args, const char *cfgfile, | |||
201 | else | 212 | else |
202 | GNUNET_free (armconfig); | 213 | GNUNET_free (armconfig); |
203 | } | 214 | } |
204 | arm = GNUNET_ARM_connect (cfg, arm_conn, NULL); | 215 | arm = GNUNET_ARM_connect (cfg, &arm_conn, NULL); |
205 | if (NULL == arm) | 216 | if (NULL == arm) |
206 | return; | 217 | return; |
207 | #if START_ARM | 218 | #if START_ARM |
@@ -213,9 +224,8 @@ task (void *cls, char *const *args, const char *cfgfile, | |||
213 | } | 224 | } |
214 | 225 | ||
215 | 226 | ||
216 | 227 | int | |
217 | static int | 228 | main (int argc, char *argvx[]) |
218 | check () | ||
219 | { | 229 | { |
220 | char *const argv[] = { | 230 | char *const argv[] = { |
221 | "test-arm-api", | 231 | "test-arm-api", |
@@ -225,6 +235,9 @@ check () | |||
225 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 235 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
226 | GNUNET_GETOPT_OPTION_END | 236 | GNUNET_GETOPT_OPTION_END |
227 | }; | 237 | }; |
238 | GNUNET_log_setup ("test-arm-api", | ||
239 | "WARNING", | ||
240 | NULL); | ||
228 | GNUNET_assert (GNUNET_OK == | 241 | GNUNET_assert (GNUNET_OK == |
229 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 242 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
230 | argv, "test-arm-api", "nohelp", options, | 243 | argv, "test-arm-api", "nohelp", options, |
@@ -232,18 +245,4 @@ check () | |||
232 | return ok; | 245 | return ok; |
233 | } | 246 | } |
234 | 247 | ||
235 | int | ||
236 | main (int argc, char *argv[]) | ||
237 | { | ||
238 | int ret; | ||
239 | |||
240 | |||
241 | GNUNET_log_setup ("test-arm-api", | ||
242 | "WARNING", | ||
243 | NULL); | ||
244 | ret = check (); | ||
245 | |||
246 | return ret; | ||
247 | } | ||
248 | |||
249 | /* end of test_arm_api.c */ | 248 | /* end of test_arm_api.c */ |
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 30d614c2f..00402b29f 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c | |||
@@ -23,11 +23,11 @@ | |||
23 | */ | 23 | */ |
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_arm_service.h" | 25 | #include "gnunet_arm_service.h" |
26 | #include "gnunet_client_lib.h" | 26 | #include "gnunet_util_lib.h" |
27 | #include "gnunet_configuration_lib.h" | ||
28 | #include "gnunet_program_lib.h" | ||
29 | #include "gnunet_protocols.h" | 27 | #include "gnunet_protocols.h" |
30 | 28 | ||
29 | #define LOG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | ||
30 | |||
31 | #define START_ARM GNUNET_YES | 31 | #define START_ARM GNUNET_YES |
32 | 32 | ||
33 | #define LOG_BACKOFF GNUNET_NO | 33 | #define LOG_BACKOFF GNUNET_NO |
@@ -165,9 +165,7 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
165 | 165 | ||
166 | if (size < sizeof (struct GNUNET_MessageHeader)) | 166 | if (size < sizeof (struct GNUNET_MessageHeader)) |
167 | { | 167 | { |
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 168 | LOG ("Failed to send a shutdown request\n"); |
169 | _("Failed to transmit shutdown request to client.\n")); | ||
170 | FPRINTF (stderr, "%s", "Failed to send a shutdown request\n"); | ||
171 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); | 169 | shutdown_ctx->cont (shutdown_ctx->cont_cls, GNUNET_SYSERR); |
172 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock); | 170 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock); |
173 | GNUNET_free (shutdown_ctx); | 171 | GNUNET_free (shutdown_ctx); |
@@ -183,7 +181,7 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
183 | msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_STOP); | 181 | msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_STOP); |
184 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | 182 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); |
185 | strcpy ((char *) &msg[1], "do-nothing"); | 183 | strcpy ((char *) &msg[1], "do-nothing"); |
186 | FPRINTF (stderr, "%s", "Sent a shutdown request\n"); | 184 | LOG ("Sent a shutdown request\n"); |
187 | return sizeof (struct GNUNET_MessageHeader) + strlen ("do-nothing") + 1; | 185 | return sizeof (struct GNUNET_MessageHeader) + strlen ("do-nothing") + 1; |
188 | } | 186 | } |
189 | 187 | ||
@@ -219,23 +217,26 @@ do_nothing_service_shutdown (struct GNUNET_CLIENT_Connection *sock, | |||
219 | shutdown_ctx); | 217 | shutdown_ctx); |
220 | } | 218 | } |
221 | 219 | ||
220 | |||
222 | static void | 221 | static void |
223 | kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc); | 222 | kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc); |
224 | 223 | ||
224 | |||
225 | static void | 225 | static void |
226 | shutdown_cont (void *cls, int reason) | 226 | shutdown_cont (void *cls, int reason) |
227 | { | 227 | { |
228 | if (GNUNET_NO != reason) | 228 | if (GNUNET_NO != reason) |
229 | { | 229 | { |
230 | /* Re-try shutdown */ | 230 | /* Re-try shutdown */ |
231 | FPRINTF (stderr, "%s", "do-nothing didn't die, trying again\n"); | 231 | LOG ("do-nothing didn't die, trying again\n"); |
232 | GNUNET_SCHEDULER_add_now (kill_task, NULL); | 232 | GNUNET_SCHEDULER_add_now (kill_task, NULL); |
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | startedWaitingAt = GNUNET_TIME_absolute_get (); | 235 | startedWaitingAt = GNUNET_TIME_absolute_get (); |
236 | FPRINTF (stderr, "%s", "do-nothing is dead, starting the countdown\n"); | 236 | LOG ("do-nothing is dead, starting the countdown\n"); |
237 | } | 237 | } |
238 | 238 | ||
239 | |||
239 | static void | 240 | static void |
240 | kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) | 241 | kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) |
241 | { | 242 | { |
@@ -244,11 +245,8 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
244 | if (NULL != cbData) | 245 | if (NULL != cbData) |
245 | { | 246 | { |
246 | waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); | 247 | waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); |
247 | FPRINTF (stderr, "Waited for: %llu ms\n", waitedFor.rel_value); | 248 | LOG ("Waited for: %s\n", |
248 | #if LOG_BACKOFF | 249 | GNUNET_STRINGS_relative_time_to_string (waitedFor, GNUNET_YES)); |
249 | FPRINTF (killLogFilePtr, "Waited for: %llu ms\n", | ||
250 | (unsigned long long) waitedFor.rel_value); | ||
251 | #endif | ||
252 | } | 250 | } |
253 | else | 251 | else |
254 | { | 252 | { |
@@ -276,6 +274,7 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
276 | TIMEOUT, &shutdown_cont, NULL); | 274 | TIMEOUT, &shutdown_cont, NULL); |
277 | } | 275 | } |
278 | 276 | ||
277 | |||
279 | static void | 278 | static void |
280 | trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 279 | trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
281 | { | 280 | { |
@@ -289,14 +288,15 @@ arm_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStat | |||
289 | { | 288 | { |
290 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 289 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
291 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPING); | 290 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPING); |
292 | FPRINTF (stderr, "%s", "ARM service stopped\n"); | 291 | LOG ("ARM service stopped\n"); |
293 | GNUNET_SCHEDULER_add_now (trigger_disconnect, NULL); | 292 | GNUNET_SCHEDULER_add_now (trigger_disconnect, NULL); |
294 | } | 293 | } |
295 | 294 | ||
296 | void | 295 | |
296 | static void | ||
297 | srv_status (void *cls, struct GNUNET_ARM_MonitorHandle *mon, const char *service, enum GNUNET_ARM_ServiceStatus status) | 297 | srv_status (void *cls, struct GNUNET_ARM_MonitorHandle *mon, const char *service, enum GNUNET_ARM_ServiceStatus status) |
298 | { | 298 | { |
299 | FPRINTF (stderr, "Service %s is %u, phase %u\n", service, status, phase); | 299 | LOG ("Service %s is %u, phase %u\n", service, status, phase); |
300 | if (status == GNUNET_ARM_SERVICE_MONITORING_STARTED) | 300 | if (status == GNUNET_ARM_SERVICE_MONITORING_STARTED) |
301 | { | 301 | { |
302 | phase++; | 302 | phase++; |
@@ -309,7 +309,7 @@ srv_status (void *cls, struct GNUNET_ARM_MonitorHandle *mon, const char *service | |||
309 | GNUNET_break (status == GNUNET_ARM_SERVICE_STARTING); | 309 | GNUNET_break (status == GNUNET_ARM_SERVICE_STARTING); |
310 | GNUNET_break (0 == strcasecmp (service, "do-nothing")); | 310 | GNUNET_break (0 == strcasecmp (service, "do-nothing")); |
311 | GNUNET_break (phase == 1); | 311 | GNUNET_break (phase == 1); |
312 | FPRINTF (stderr, "%s", "do-nothing is starting\n"); | 312 | LOG ("do-nothing is starting\n"); |
313 | phase++; | 313 | phase++; |
314 | ok = 1; | 314 | ok = 1; |
315 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &kill_task, NULL); | 315 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &kill_task, NULL); |
@@ -321,7 +321,7 @@ srv_status (void *cls, struct GNUNET_ARM_MonitorHandle *mon, const char *service | |||
321 | */ | 321 | */ |
322 | if (status == GNUNET_ARM_SERVICE_STARTING) | 322 | if (status == GNUNET_ARM_SERVICE_STARTING) |
323 | { | 323 | { |
324 | FPRINTF (stderr, "%s", "do-nothing is starting\n"); | 324 | LOG ("do-nothing is starting\n"); |
325 | GNUNET_SCHEDULER_add_now (kill_task, &ok); | 325 | GNUNET_SCHEDULER_add_now (kill_task, &ok); |
326 | } | 326 | } |
327 | else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14)) | 327 | else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14)) |
@@ -332,15 +332,18 @@ srv_status (void *cls, struct GNUNET_ARM_MonitorHandle *mon, const char *service | |||
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | |||
335 | static void | 336 | static void |
336 | arm_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result) | 337 | arm_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result) |
337 | { | 338 | { |
338 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 339 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
339 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); | 340 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); |
340 | GNUNET_break (phase == 0); | 341 | GNUNET_break (phase == 0); |
341 | FPRINTF (stderr, "Sent 'START' request for arm to ARM %s\n", (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); | 342 | LOG ("Sent 'START' request for arm to ARM %s\n", |
343 | (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); | ||
342 | } | 344 | } |
343 | 345 | ||
346 | |||
344 | static void | 347 | static void |
345 | task (void *cls, char *const *args, const char *cfgfile, | 348 | task (void *cls, char *const *args, const char *cfgfile, |
346 | const struct GNUNET_CONFIGURATION_Handle *c) | 349 | const struct GNUNET_CONFIGURATION_Handle *c) |
@@ -381,6 +384,7 @@ task (void *cls, char *const *args, const char *cfgfile, | |||
381 | } | 384 | } |
382 | } | 385 | } |
383 | 386 | ||
387 | |||
384 | static int | 388 | static int |
385 | check () | 389 | check () |
386 | { | 390 | { |
@@ -403,6 +407,7 @@ check () | |||
403 | return ok; | 407 | return ok; |
404 | } | 408 | } |
405 | 409 | ||
410 | |||
406 | static int | 411 | static int |
407 | init () | 412 | init () |
408 | { | 413 | { |
diff --git a/src/arm/test_gnunet_service_arm.c b/src/arm/test_gnunet_service_arm.c index 9cdda77df..816bf4cfb 100644 --- a/src/arm/test_gnunet_service_arm.c +++ b/src/arm/test_gnunet_service_arm.c | |||
@@ -53,8 +53,13 @@ trigger_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
53 | arm = NULL; | 53 | arm = NULL; |
54 | } | 54 | } |
55 | 55 | ||
56 | |||
56 | static void | 57 | static void |
57 | arm_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result) | 58 | arm_stop_cb (void *cls, |
59 | struct GNUNET_ARM_Handle *h, | ||
60 | enum GNUNET_ARM_RequestStatus status, | ||
61 | const char *servicename, | ||
62 | enum GNUNET_ARM_Result result) | ||
58 | { | 63 | { |
59 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 64 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
60 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPING); | 65 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPING); |
@@ -63,19 +68,23 @@ arm_stop_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStat | |||
63 | GNUNET_SCHEDULER_add_now (trigger_disconnect, NULL); | 68 | GNUNET_SCHEDULER_add_now (trigger_disconnect, NULL); |
64 | } | 69 | } |
65 | 70 | ||
71 | |||
66 | static void | 72 | static void |
67 | service_list (void *cls, struct GNUNET_ARM_Handle *arm, | 73 | service_list (void *cls, struct GNUNET_ARM_Handle *arm, |
68 | enum GNUNET_ARM_RequestStatus rs, | 74 | enum GNUNET_ARM_RequestStatus rs, |
69 | unsigned int count, const char *const*list) | 75 | unsigned int count, const char *const*list) |
70 | { | 76 | { |
71 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%u services are are currently running\n", count); | 77 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
72 | GNUNET_assert (count == 1); | 78 | "%u services are are currently running\n", |
79 | count); | ||
80 | GNUNET_break (count == 1); | ||
73 | GNUNET_break (0 == strcasecmp (list[0], "resolver (gnunet-service-resolver)")); | 81 | GNUNET_break (0 == strcasecmp (list[0], "resolver (gnunet-service-resolver)")); |
74 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got service list, now stopping arm\n"); | 82 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got service list, now stopping arm\n"); |
75 | ret = 0; | 83 | ret = 0; |
76 | GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, arm_stop_cb, NULL); | 84 | GNUNET_ARM_request_service_stop (arm, "arm", TIMEOUT, arm_stop_cb, NULL); |
77 | } | 85 | } |
78 | 86 | ||
87 | |||
79 | static void | 88 | static void |
80 | hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) | 89 | hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
81 | { | 90 | { |
@@ -97,8 +106,13 @@ hostNameResolveCB (void *cls, const struct sockaddr *addr, socklen_t addrlen) | |||
97 | } | 106 | } |
98 | } | 107 | } |
99 | 108 | ||
109 | |||
100 | static void | 110 | static void |
101 | arm_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestStatus status, const char *servicename, enum GNUNET_ARM_Result result) | 111 | arm_start_cb (void *cls, |
112 | struct GNUNET_ARM_Handle *h, | ||
113 | enum GNUNET_ARM_RequestStatus status, | ||
114 | const char *servicename, | ||
115 | enum GNUNET_ARM_Result result) | ||
102 | { | 116 | { |
103 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 117 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); |
104 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); | 118 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); |
@@ -115,6 +129,7 @@ arm_start_cb (void *cls, struct GNUNET_ARM_Handle *h, enum GNUNET_ARM_RequestSta | |||
115 | } | 129 | } |
116 | } | 130 | } |
117 | 131 | ||
132 | |||
118 | static void | 133 | static void |
119 | run (void *cls, char *const *args, const char *cfgfile, | 134 | run (void *cls, char *const *args, const char *cfgfile, |
120 | const struct GNUNET_CONFIGURATION_Handle *c) | 135 | const struct GNUNET_CONFIGURATION_Handle *c) |
@@ -171,10 +186,10 @@ main (int argc, char *av[]) | |||
171 | GNUNET_log_setup ("test-gnunet-service-arm", | 186 | GNUNET_log_setup ("test-gnunet-service-arm", |
172 | "WARNING", | 187 | "WARNING", |
173 | NULL); | 188 | NULL); |
174 | GNUNET_assert (GNUNET_OK == | 189 | GNUNET_break (GNUNET_OK == |
175 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 190 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
176 | argv, "test-gnunet-service-arm", | 191 | argv, "test-gnunet-service-arm", |
177 | "nohelp", options, &run, NULL)); | 192 | "nohelp", options, &run, NULL)); |
178 | return ret; | 193 | return ret; |
179 | } | 194 | } |
180 | 195 | ||