From 80bc743406f55f2d4470ee83364c87cfdce52356 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 29 May 2015 09:45:36 +0200 Subject: Fix tst_qglobalstatic on OS X OS X has an unreasonably low default for the maximum number of open file descriptors (256). The unit test creates about 200 threads and each thread in Qt creates at least two file descriptors (pipe), so the test cannot execute. Change-Id: I656367bca6d0a40fb1edb8c72914304db0f429ac Reviewed-by: Oswald Buddenhagen --- .../global/qglobalstatic/tst_qglobalstatic.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp index e6b2f8a116..68129f9081 100644 --- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp +++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp @@ -41,10 +41,17 @@ #include #include +#if defined(Q_OS_UNIX) +#include +#endif + class tst_QGlobalStatic : public QObject { Q_OBJECT +public Q_SLOTS: + void initTestCase(); + private Q_SLOTS: void beforeInitialization(); void api(); @@ -55,6 +62,20 @@ private Q_SLOTS: void afterDestruction(); }; +void tst_QGlobalStatic::initTestCase() +{ +#if defined(Q_OS_UNIX) + // The tests create a lot of threads, which require file descriptors. On systems like + // OS X low defaults such as 256 as the limit for the number of simultaneously + // open files is not sufficient. + struct rlimit numFiles; + if (getrlimit(RLIMIT_NOFILE, &numFiles) == 0 && numFiles.rlim_cur < 1024) { + numFiles.rlim_cur = qMin(rlim_t(1024), numFiles.rlim_max); + setrlimit(RLIMIT_NOFILE, &numFiles); + } +#endif +} + Q_GLOBAL_STATIC_WITH_ARGS(const int, constInt, (42)) Q_GLOBAL_STATIC_WITH_ARGS(volatile int, volatileInt, (-47)) -- cgit v1.2.3