summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
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))