summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qtemporaryfile
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-04-13 23:12:46 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-06-12 06:14:43 +0000
commit5483b30868e44bc0799d7a1998f1907775f50fec (patch)
treee003cbc415a72501ba7f163aab9ed580a08ab327 /tests/auto/corelib/io/qtemporaryfile
parent769722778120623e2a873a14e3db2e5e53098fce (diff)
QTemporaryFile: fix the generation of names from templates
First and most importantly, let's not use more than half of the template for the application's PID. With over 71% of all PIDs on a typical Linux system and 90% of those on a Darwin system having 5 decimal digits, using them all in a template that is usually 6 characters long is wasteful. That leaves only 1 character for the random part, thereby reducing the number of temporary files possible to only 52. So limit the PID to half the characters of the template. Second, let's use QRandomGenerator::bounded to create the the random part, instead of qrand (which is often unseeded at this point). Change-Id: Icd0e0d4b27cb4e5eb892fffd14b52eda5e467395 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib/io/qtemporaryfile')
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp4
1 files changed, 0 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index 59cd3a8411..17bcde4992 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -866,8 +866,6 @@ void tst_QTemporaryFile::guaranteeUnique()
// First pass. See which filename QTemporaryFile will try first.
{
- // Fix the random seed.
- qsrand(1135);
QTemporaryFile tmpFile("testFile1.XXXXXX");
tmpFile.open();
takenFileName = tmpFile.fileName();
@@ -881,8 +879,6 @@ void tst_QTemporaryFile::guaranteeUnique()
// Second pass, now we have blocked its first attempt with a directory.
{
- // Fix the random seed.
- qsrand(1135);
QTemporaryFile tmpFile("testFile1.XXXXXX");
QVERIFY(tmpFile.open());
QString uniqueFileName = tmpFile.fileName();