diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-04 14:00:32 +0000 |
commit | 83b19539f4d322b43683f5838b72e9ec2c8e6073 (patch) | |
tree | d0ab9329fcbefe360d9d14e2ace21a6b3396dfe9 /src/util/test_service.c | |
parent | 28a2eb43281a1f08a67954f07beb9af3a9bc9a35 (diff) | |
download | gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.tar.gz gnunet-83b19539f4d322b43683f5838b72e9ec2c8e6073.zip |
curly wars / auto-indentation
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r-- | src/util/test_service.c | 77 |
1 files changed, 37 insertions, 40 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c index 33d69db10..1b78932f8 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -68,11 +68,11 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
68 | client = GNUNET_CLIENT_connect ("test_service", cfg); | 68 | client = GNUNET_CLIENT_connect ("test_service", cfg); |
69 | GNUNET_assert (client != NULL); | 69 | GNUNET_assert (client != NULL); |
70 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 70 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
71 | "Client connecting, waiting to transmit\n"); | 71 | "Client connecting, waiting to transmit\n"); |
72 | GNUNET_CLIENT_notify_transmit_ready (client, | 72 | GNUNET_CLIENT_notify_transmit_ready (client, |
73 | sizeof (struct GNUNET_MessageHeader), | 73 | sizeof (struct GNUNET_MessageHeader), |
74 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, | 74 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, |
75 | &build_msg, client); | 75 | &build_msg, client); |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
@@ -85,7 +85,7 @@ do_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
85 | 85 | ||
86 | static void | 86 | static void |
87 | recv_cb (void *cls, struct GNUNET_SERVER_Client *client, | 87 | recv_cb (void *cls, struct GNUNET_SERVER_Client *client, |
88 | const struct GNUNET_MessageHeader *message) | 88 | const struct GNUNET_MessageHeader *message) |
89 | { | 89 | { |
90 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); | 90 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); |
91 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 91 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -105,12 +105,12 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = { | |||
105 | 105 | ||
106 | static void | 106 | static void |
107 | runner (void *cls, struct GNUNET_SERVER_Handle *server, | 107 | runner (void *cls, struct GNUNET_SERVER_Handle *server, |
108 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 108 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
109 | { | 109 | { |
110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); | 110 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); |
111 | GNUNET_SERVER_add_handlers (server, myhandlers); | 111 | GNUNET_SERVER_add_handlers (server, myhandlers); |
112 | GNUNET_CLIENT_service_test ("test_service", cfg, GNUNET_TIME_UNIT_SECONDS, | 112 | GNUNET_CLIENT_service_test ("test_service", cfg, GNUNET_TIME_UNIT_SECONDS, |
113 | &ready, (void *) cfg); | 113 | &ready, (void *) cfg); |
114 | } | 114 | } |
115 | 115 | ||
116 | 116 | ||
@@ -136,9 +136,8 @@ check () | |||
136 | }; | 136 | }; |
137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n"); | 137 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service\n"); |
138 | GNUNET_assert (GNUNET_OK == | 138 | GNUNET_assert (GNUNET_OK == |
139 | GNUNET_SERVICE_run (5, argv, "test_service", | 139 | GNUNET_SERVICE_run (5, argv, "test_service", |
140 | GNUNET_SERVICE_OPTION_NONE, &runner, | 140 | GNUNET_SERVICE_OPTION_NONE, &runner, &ok)); |
141 | &ok)); | ||
142 | GNUNET_assert (0 == ok); | 141 | GNUNET_assert (0 == ok); |
143 | return ok; | 142 | return ok; |
144 | } | 143 | } |
@@ -155,19 +154,19 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
155 | GNUNET_assert (client != NULL); | 154 | GNUNET_assert (client != NULL); |
156 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); | 155 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); |
157 | GNUNET_CLIENT_notify_transmit_ready (client, | 156 | GNUNET_CLIENT_notify_transmit_ready (client, |
158 | sizeof (struct GNUNET_MessageHeader), | 157 | sizeof (struct GNUNET_MessageHeader), |
159 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, | 158 | GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, |
160 | &build_msg, client); | 159 | &build_msg, client); |
161 | } | 160 | } |
162 | 161 | ||
163 | static void | 162 | static void |
164 | runner6 (void *cls, struct GNUNET_SERVER_Handle *server, | 163 | runner6 (void *cls, struct GNUNET_SERVER_Handle *server, |
165 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 164 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
166 | { | 165 | { |
167 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); | 166 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); |
168 | GNUNET_SERVER_add_handlers (server, myhandlers); | 167 | GNUNET_SERVER_add_handlers (server, myhandlers); |
169 | GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS, | 168 | GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS, |
170 | &ready6, (void *) cfg); | 169 | &ready6, (void *) cfg); |
171 | } | 170 | } |
172 | 171 | ||
173 | /** | 172 | /** |
@@ -191,9 +190,9 @@ check6 () | |||
191 | }; | 190 | }; |
192 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); | 191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); |
193 | GNUNET_assert (GNUNET_OK == | 192 | GNUNET_assert (GNUNET_OK == |
194 | GNUNET_SERVICE_run (5, argv, "test_service6", | 193 | GNUNET_SERVICE_run (5, argv, "test_service6", |
195 | GNUNET_SERVICE_OPTION_NONE, &runner6, | 194 | GNUNET_SERVICE_OPTION_NONE, &runner6, |
196 | &ok)); | 195 | &ok)); |
197 | GNUNET_assert (0 == ok); | 196 | GNUNET_assert (0 == ok); |
198 | return ok; | 197 | return ok; |
199 | } | 198 | } |
@@ -202,12 +201,11 @@ check6 () | |||
202 | 201 | ||
203 | static void | 202 | static void |
204 | start_stop_main (void *cls, char *const *args, const char *cfgfile, | 203 | start_stop_main (void *cls, char *const *args, const char *cfgfile, |
205 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 204 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
206 | { | 205 | { |
207 | int *ret = cls; | 206 | int *ret = cls; |
208 | 207 | ||
209 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service using start method\n"); |
210 | "Starting service using start method\n"); | ||
211 | sctx = GNUNET_SERVICE_start ("test_service", cfg); | 209 | sctx = GNUNET_SERVICE_start ("test_service", cfg); |
212 | GNUNET_assert (NULL != sctx); | 210 | GNUNET_assert (NULL != sctx); |
213 | runner (cls, GNUNET_SERVICE_get_server (sctx), cfg); | 211 | runner (cls, GNUNET_SERVICE_get_server (sctx), cfg); |
@@ -236,9 +234,8 @@ check_start_stop () | |||
236 | int ret = 1; | 234 | int ret = 1; |
237 | 235 | ||
238 | GNUNET_assert (GNUNET_OK == | 236 | GNUNET_assert (GNUNET_OK == |
239 | GNUNET_PROGRAM_run (5, argv, "test-service-program", | 237 | GNUNET_PROGRAM_run (5, argv, "test-service-program", "no help", |
240 | "no help", options, &start_stop_main, | 238 | options, &start_stop_main, &ret)); |
241 | &ret)); | ||
242 | 239 | ||
243 | GNUNET_break (0 == ret); | 240 | GNUNET_break (0 == ret); |
244 | return ret; | 241 | return ret; |
@@ -253,11 +250,11 @@ main (int argc, char *argv[]) | |||
253 | 250 | ||
254 | GNUNET_log_setup ("test-service", | 251 | GNUNET_log_setup ("test-service", |
255 | #if VERBOSE | 252 | #if VERBOSE |
256 | "DEBUG", | 253 | "DEBUG", |
257 | #else | 254 | #else |
258 | "WARNING", | 255 | "WARNING", |
259 | #endif | 256 | #endif |
260 | NULL); | 257 | NULL); |
261 | ret += check (); | 258 | ret += check (); |
262 | ret += check (); | 259 | ret += check (); |
263 | 260 | ||
@@ -266,22 +263,22 @@ main (int argc, char *argv[]) | |||
266 | s = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); | 263 | s = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); |
267 | #endif | 264 | #endif |
268 | if (NULL == s) | 265 | if (NULL == s) |
266 | { | ||
267 | if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || | ||
268 | (errno == EACCES)) | ||
269 | { | 269 | { |
270 | if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) || | 270 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
271 | (errno == EACCES)) | 271 | return 1; |
272 | { | ||
273 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | ||
274 | return 1; | ||
275 | } | ||
276 | fprintf (stderr, | ||
277 | "IPv6 support seems to not be available (%s), not testing it!\n", | ||
278 | strerror (errno)); | ||
279 | } | 272 | } |
273 | fprintf (stderr, | ||
274 | "IPv6 support seems to not be available (%s), not testing it!\n", | ||
275 | strerror (errno)); | ||
276 | } | ||
280 | else | 277 | else |
281 | { | 278 | { |
282 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); | 279 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); |
283 | ret += check6 (); | 280 | ret += check6 (); |
284 | } | 281 | } |
285 | ret += check_start_stop (); | 282 | ret += check_start_stop (); |
286 | 283 | ||
287 | return ret; | 284 | return ret; |