aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_service.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-11 09:43:04 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-11 09:43:04 +0000
commitd9d94d0e53d26af75ec8241383d166544ebd79f3 (patch)
tree9080b73624389403a198257fe0547bb4634e64d2 /src/util/test_service.c
parent2d792ee2e9cc0c993b8907e2c8edb0c2b8465343 (diff)
downloadgnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.tar.gz
gnunet-d9d94d0e53d26af75ec8241383d166544ebd79f3.zip
converting to GNUNET_LOG_from*
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r--src/util/test_service.c77
1 files changed, 40 insertions, 37 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c
index 1b78932f8..33d69db10 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
86static void 86static void
87recv_cb (void *cls, struct GNUNET_SERVER_Client *client, 87recv_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
106static void 106static void
107runner (void *cls, struct GNUNET_SERVER_Handle *server, 107runner (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,8 +136,9 @@ 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, &ok)); 140 GNUNET_SERVICE_OPTION_NONE, &runner,
141 &ok));
141 GNUNET_assert (0 == ok); 142 GNUNET_assert (0 == ok);
142 return ok; 143 return ok;
143} 144}
@@ -154,19 +155,19 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
154 GNUNET_assert (client != NULL); 155 GNUNET_assert (client != NULL);
155 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); 156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n");
156 GNUNET_CLIENT_notify_transmit_ready (client, 157 GNUNET_CLIENT_notify_transmit_ready (client,
157 sizeof (struct GNUNET_MessageHeader), 158 sizeof (struct GNUNET_MessageHeader),
158 GNUNET_TIME_UNIT_SECONDS, GNUNET_NO, 159 GNUNET_TIME_UNIT_SECONDS, GNUNET_NO,
159 &build_msg, client); 160 &build_msg, client);
160} 161}
161 162
162static void 163static void
163runner6 (void *cls, struct GNUNET_SERVER_Handle *server, 164runner6 (void *cls, struct GNUNET_SERVER_Handle *server,
164 const struct GNUNET_CONFIGURATION_Handle *cfg) 165 const struct GNUNET_CONFIGURATION_Handle *cfg)
165{ 166{
166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); 167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n");
167 GNUNET_SERVER_add_handlers (server, myhandlers); 168 GNUNET_SERVER_add_handlers (server, myhandlers);
168 GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS, 169 GNUNET_CLIENT_service_test ("test_service6", cfg, GNUNET_TIME_UNIT_SECONDS,
169 &ready6, (void *) cfg); 170 &ready6, (void *) cfg);
170} 171}
171 172
172/** 173/**
@@ -190,9 +191,9 @@ check6 ()
190 }; 191 };
191 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n"); 192 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting v6 service\n");
192 GNUNET_assert (GNUNET_OK == 193 GNUNET_assert (GNUNET_OK ==
193 GNUNET_SERVICE_run (5, argv, "test_service6", 194 GNUNET_SERVICE_run (5, argv, "test_service6",
194 GNUNET_SERVICE_OPTION_NONE, &runner6, 195 GNUNET_SERVICE_OPTION_NONE, &runner6,
195 &ok)); 196 &ok));
196 GNUNET_assert (0 == ok); 197 GNUNET_assert (0 == ok);
197 return ok; 198 return ok;
198} 199}
@@ -201,11 +202,12 @@ check6 ()
201 202
202static void 203static void
203start_stop_main (void *cls, char *const *args, const char *cfgfile, 204start_stop_main (void *cls, char *const *args, const char *cfgfile,
204 const struct GNUNET_CONFIGURATION_Handle *cfg) 205 const struct GNUNET_CONFIGURATION_Handle *cfg)
205{ 206{
206 int *ret = cls; 207 int *ret = cls;
207 208
208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting service using start method\n"); 209 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
210 "Starting service using start method\n");
209 sctx = GNUNET_SERVICE_start ("test_service", cfg); 211 sctx = GNUNET_SERVICE_start ("test_service", cfg);
210 GNUNET_assert (NULL != sctx); 212 GNUNET_assert (NULL != sctx);
211 runner (cls, GNUNET_SERVICE_get_server (sctx), cfg); 213 runner (cls, GNUNET_SERVICE_get_server (sctx), cfg);
@@ -234,8 +236,9 @@ check_start_stop ()
234 int ret = 1; 236 int ret = 1;
235 237
236 GNUNET_assert (GNUNET_OK == 238 GNUNET_assert (GNUNET_OK ==
237 GNUNET_PROGRAM_run (5, argv, "test-service-program", "no help", 239 GNUNET_PROGRAM_run (5, argv, "test-service-program",
238 options, &start_stop_main, &ret)); 240 "no help", options, &start_stop_main,
241 &ret));
239 242
240 GNUNET_break (0 == ret); 243 GNUNET_break (0 == ret);
241 return ret; 244 return ret;
@@ -250,11 +253,11 @@ main (int argc, char *argv[])
250 253
251 GNUNET_log_setup ("test-service", 254 GNUNET_log_setup ("test-service",
252#if VERBOSE 255#if VERBOSE
253 "DEBUG", 256 "DEBUG",
254#else 257#else
255 "WARNING", 258 "WARNING",
256#endif 259#endif
257 NULL); 260 NULL);
258 ret += check (); 261 ret += check ();
259 ret += check (); 262 ret += check ();
260 263
@@ -263,22 +266,22 @@ main (int argc, char *argv[])
263 s = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0); 266 s = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_STREAM, 0);
264#endif 267#endif
265 if (NULL == s) 268 if (NULL == s)
266 {
267 if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) ||
268 (errno == EACCES))
269 { 269 {
270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); 270 if ((errno == ENOBUFS) || (errno == ENOMEM) || (errno == ENFILE) ||
271 return 1; 271 (errno == EACCES))
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));
272 } 279 }
273 fprintf (stderr,
274 "IPv6 support seems to not be available (%s), not testing it!\n",
275 strerror (errno));
276 }
277 else 280 else
278 { 281 {
279 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s)); 282 GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
280 ret += check6 (); 283 ret += check6 ();
281 } 284 }
282 ret += check_start_stop (); 285 ret += check_start_stop ();
283 286
284 return ret; 287 return ret;