summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-05-29 09:45:36 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-04 05:56:16 +0000
commit80bc743406f55f2d4470ee83364c87cfdce52356 (patch)
tree96a49bb10da7d18671df167bc578bfd08f680e19 /tests/auto
parentccad00121d0a9d703cf715c54347b32bfc33bbfc (diff)
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 <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp21
1 files changed, 21 insertions, 0 deletions
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 <QtCore/QThread>
#include <QtTest/QtTest>
+#if defined(Q_OS_UNIX)
+#include <sys/resource.h>
+#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))