Fix autotest not to open too many files on a Unix
tst_QSharedPointer can't create a pipe as the OS has too many files open. Systems like macOS have a lower limit to these simultaneous files open. Task-number: QTBUG-60410 Change-Id: I21e89f992ada2a7d09b706522a05b5952f00ec33 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
4c346b6e2b
commit
315f634180
@ -43,6 +43,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#ifdef Q_OS_UNIX
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace QtSharedPointer {
|
namespace QtSharedPointer {
|
||||||
Q_CORE_EXPORT void internalSafetyCheckCleanCheck();
|
Q_CORE_EXPORT void internalSafetyCheckCleanCheck();
|
||||||
@ -54,6 +58,7 @@ class tst_QSharedPointer: public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void initTestCase();
|
||||||
void basics_data();
|
void basics_data();
|
||||||
void basics();
|
void basics();
|
||||||
void operators();
|
void operators();
|
||||||
@ -118,6 +123,20 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void tst_QSharedPointer::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
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> static inline
|
template<typename T> static inline
|
||||||
QtSharedPointer::ExternalRefCountData *refCountData(const QSharedPointer<T> &b)
|
QtSharedPointer::ExternalRefCountData *refCountData(const QSharedPointer<T> &b)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user