From 5f1a0cb42a5aa509e0660fc892f2291593fb08ef Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 5 Aug 2015 08:49:16 -0700 Subject: [PATCH] Seed the random number generator before using QTemporaryDir Otherwise, on some systems (Windows), we'll always create the same dirs. Change-Id: Id3d5c7bf4d4c45069621ffff13f79ba91e0f974b Reviewed-by: Christopher Adams --- tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp | 8 +++++++- .../corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 2b01cfd7a9..96ad78a666 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -144,12 +144,18 @@ inline bool qIsLikelyToBeNfs(int /* handle */) #endif #endif +static QString seedAndTemplate() +{ + qsrand(QDateTime::currentDateTimeUtc().toTime_t()); + return QDir::tempPath() + "/tst_qfileinfo-XXXXXX"; +} class tst_QFileInfo : public QObject { Q_OBJECT public: - tst_QFileInfo() : m_currentDir(QDir::currentPath()) {} + tst_QFileInfo() : m_currentDir(QDir::currentPath()), m_dir(seedAndTemplate()) + {} private slots: void initTestCase(); diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 1c9add86f7..99ebf77a3d 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -103,7 +103,14 @@ static bool copyResourceFile(const QString &sourceFileName, const QString &targe // Set LANG before QCoreApplication is created Q_CONSTRUCTOR_FUNCTION(initializeLang) +static QString seedAndTemplate() +{ + qsrand(QDateTime::currentDateTimeUtc().toTime_t()); + return QDir::tempPath() + "/tst_qmimedatabase-XXXXXX"; +} + tst_QMimeDatabase::tst_QMimeDatabase() + : m_temporaryDir(seedAndTemplate()) { }