summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp')
-rw-r--r--tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
index 5ad798ae1f..74220d7f97 100644
--- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
+++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -251,6 +251,11 @@ void tst_QTemporaryFile::autoRemove()
QTemporaryFile file("tempXXXXXX");
QVERIFY(file.open());
fileName = file.fileName();
+ // QTBUG-39976, file mappings should be cleared as well.
+ QVERIFY(file.write("test"));
+ QVERIFY(file.flush());
+ uchar *mapped = file.map(0, file.size());
+ QVERIFY(mapped);
file.close();
}
QVERIFY(!QFile::exists(fileName));
@@ -441,13 +446,15 @@ void tst_QTemporaryFile::rename()
void tst_QTemporaryFile::renameFdLeak()
{
#ifdef Q_OS_UNIX
+ const QByteArray sourceFile = QFile::encodeName(QFINDTESTDATA(__FILE__));
+ QVERIFY(!sourceFile.isEmpty());
// Test this on Unix only
// Open a bunch of files to force the fd count to go up
static const int count = 10;
int bunch_of_files[count];
for (int i = 0; i < count; ++i) {
- bunch_of_files[i] = ::open(qPrintable(QFINDTESTDATA("tst_qtemporaryfile.cpp")), O_RDONLY);
+ bunch_of_files[i] = ::open(sourceFile.constData(), O_RDONLY);
QVERIFY(bunch_of_files[i] != -1);
}
@@ -642,8 +649,10 @@ void tst_QTemporaryFile::createNativeFile_data()
QTest::addColumn<bool>("valid");
QTest::addColumn<QByteArray>("content");
- QTest::newRow("nativeFile") << QFINDTESTDATA("resources/test.txt") << (qint64)-1 << false << QByteArray();
- QTest::newRow("nativeFileWithPos") << QFINDTESTDATA("resources/test.txt") << (qint64)5 << false << QByteArray();
+ const QString nativeFilePath = QFINDTESTDATA("resources/test.txt");
+
+ QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray();
+ QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray();
QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test");
QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test");
}