aboutsummaryrefslogtreecommitdiff
path: root/zenstore-test
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2022-04-12 16:48:16 +0200
committerDan Engelbrecht <[email protected]>2022-04-12 17:02:41 +0200
commit69d1f328c7651489919c72f1d5b782b8caf61c20 (patch)
tree0d85f8f0f678670be84c522340d30c83810167e9 /zenstore-test
parentreduce number of chunks in compactcas.threadedinsert (diff)
downloadzen-69d1f328c7651489919c72f1d5b782b8caf61c20.tar.xz
zen-69d1f328c7651489919c72f1d5b782b8caf61c20.zip
set open file limit at startup
Diffstat (limited to 'zenstore-test')
-rw-r--r--zenstore-test/zenstore-test.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/zenstore-test/zenstore-test.cpp b/zenstore-test/zenstore-test.cpp
index e6bd92ab9..a76df6639 100644
--- a/zenstore-test/zenstore-test.cpp
+++ b/zenstore-test/zenstore-test.cpp
@@ -4,6 +4,12 @@
#include <zencore/zencore.h>
#include <zenstore/zenstore.h>
+#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
+# include <sys/time.h>
+# include <sys/resource.h>
+# include <zencore/except.h>
+#endif
+
#if ZEN_WITH_TESTS
# define DOCTEST_CONFIG_IMPLEMENT
# include <zencore/testing.h>
@@ -13,6 +19,25 @@
int
main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[])
{
+#if ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC
+ struct rlimit Limit;
+ int Error = getrlimit(RLIMIT_NOFILE, &Limit);
+ if (Error)
+ {
+ ZEN_WARN("failed getting rlimit RLIMIT_NOFILE, reason '{}'", zen::MakeErrorCode(Error).message());
+ }
+ else
+ {
+ struct rlimit NewLimit = Limit;
+ NewLimit.rlim_cur = 10240;
+ NewLimit.rlim_max = 10240;
+ Error = setrlimit(RLIMIT_NOFILE, &NewLimit);
+ if (Error != 0)
+ {
+ ZEN_WARN("failed to set RLIMIT_NOFILE limits from rlim_cur = {}, rlim_max {} to rlim_cur = {}, rlim_max {}, reason '{}'", Limit.rlim_cur, Limit.rlim_max, NewLimit.rlim_cur, NewLimit.rlim_max, zen::MakeErrorCode(Error).message());
+ }
+ }
+#endif
#if ZEN_WITH_TESTS
zen::zenstore_forcelinktests();