aboutsummaryrefslogtreecommitdiff
path: root/src/transport/test_transport_api_limited_sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/test_transport_api_limited_sockets.c')
-rw-r--r--src/transport/test_transport_api_limited_sockets.c57
1 files changed, 21 insertions, 36 deletions
diff --git a/src/transport/test_transport_api_limited_sockets.c b/src/transport/test_transport_api_limited_sockets.c
index e3c294a1c..69a510005 100644
--- a/src/transport/test_transport_api_limited_sockets.c
+++ b/src/transport/test_transport_api_limited_sockets.c
@@ -44,6 +44,9 @@
44 44
45#define MAX_FILES 50 45#define MAX_FILES 50
46 46
47
48#if HAVE_SETRLIMIT
49
47static char *test_source; 50static char *test_source;
48 51
49static char *test_plugin; 52static char *test_plugin;
@@ -271,9 +274,6 @@ check ()
271 static char *const argv[] = { "test-transport-api", 274 static char *const argv[] = { "test-transport-api",
272 "-c", 275 "-c",
273 "test_transport_api_data.conf", 276 "test_transport_api_data.conf",
274#if VERBOSE
275 "-L", "DEBUG",
276#endif
277 NULL 277 NULL
278 }; 278 };
279 static struct GNUNET_GETOPT_CommandLineOption options[] = { 279 static struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -292,39 +292,24 @@ check ()
292 return ok; 292 return ok;
293} 293}
294 294
295
295int 296int
296main (int argc, char *argv[]) 297main (int argc, char *argv[])
297{ 298{
299 struct rlimit r_file_old;
300 struct rlimit r_file_new;
301 int res;
298 int ret = 0; 302 int ret = 0;
299 303
300 test_plugin = NULL; 304 test_plugin = NULL;
301
302 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source); 305 GNUNET_TRANSPORT_TESTING_get_test_source_name (__FILE__, &test_source);
303 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source, 306 GNUNET_TRANSPORT_TESTING_get_test_plugin_name (argv[0], test_source,
304 &test_plugin); 307 &test_plugin);
305 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); 308 GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name);
306
307 GNUNET_log_setup (test_name, 309 GNUNET_log_setup (test_name,
308#if VERBOSE
309 "DEBUG",
310#else
311 "WARNING", 310 "WARNING",
312#endif
313 NULL); 311 NULL);
314 312
315#if !HAVE_SETRLIMIT
316 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Cannot run test on this system\n");
317
318 GNUNET_free (test_source);
319 GNUNET_free (test_plugin);
320 GNUNET_free (test_name);
321
322 return 0;
323#else
324 struct rlimit r_file_old;
325 struct rlimit r_file_new;
326 int res;
327
328 res = getrlimit (RLIMIT_NOFILE, &r_file_old); 313 res = getrlimit (RLIMIT_NOFILE, &r_file_old);
329 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
330 "Maximum number of open files was: %u/%u\n", r_file_old.rlim_cur, 315 "Maximum number of open files was: %u/%u\n", r_file_old.rlim_cur,
@@ -347,27 +332,27 @@ main (int argc, char *argv[])
347 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1); 332 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p1, 1);
348 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2); 333 GNUNET_TRANSPORT_TESTING_get_config_name (argv[0], &cfg_file_p2, 2);
349 ret = check (); 334 ret = check ();
350#endif
351
352 335
353 GNUNET_free (cfg_file_p1); 336 GNUNET_free (cfg_file_p1);
354 GNUNET_free (cfg_file_p2); 337 GNUNET_free (cfg_file_p2);
355
356 GNUNET_free (test_source); 338 GNUNET_free (test_source);
357 GNUNET_free (test_plugin); 339 GNUNET_free (test_plugin);
358 GNUNET_free (test_name); 340 GNUNET_free (test_name);
359
360#if HAVE_SETRLIMIT
361 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
362 "Restoring previous value maximum number of open files\n");
363 res = setrlimit (RLIMIT_NOFILE, &r_file_old);
364 if (res != 0)
365 {
366 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Restoring limit failed!\n");
367 return 0;
368 }
369#endif
370 return ret; 341 return ret;
371} 342}
372 343
344#else
345/* cannot setrlimit */
346
347
348int
349main (int argc, char *argv[])
350{
351 fprintf (stderr, "Cannot run test on this system\n");
352 return 0;
353}
354
355#endif
356
373/* end of test_transport_api_limited_sockets.c */ 357/* end of test_transport_api_limited_sockets.c */
358