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>
This commit is contained in:
parent
ccad00121d
commit
80bc743406
@ -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))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user