summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qfile/tst_qfile.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-04-29 10:55:06 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-07 14:27:17 +0200
commit9b4b406142b05eef8ef255561f24951f25567a8e (patch)
tree9e505c1858fb1d72d1eac3a109d183937d0b9e42 /tests/auto/corelib/io/qfile/tst_qfile.cpp
parenta033c23ddffed6b9bff3e7be68d513a7962c3b5e (diff)
Handle disk full situations by skipping QFile::moveToTrash test
If any of the temporary directories and files can't be created, skip the test. Otherwise, the cleanup routine would recursively delete "/". Change-Id: I51f908a468be8fd2ebd523ff7ce27a7c78d1b4e2 Fixes: QTBUG-83863 Pick-to: 5.15 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/corelib/io/qfile/tst_qfile.cpp')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 624ab39188..d2a83757d2 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -3677,11 +3677,14 @@ void tst_QFile::moveToTrash_data()
// success cases
{
QTemporaryFile temp;
- QVERIFY(temp.open());
+ if (!temp.open())
+ QSKIP("Failed to create temporary file!");
QTest::newRow("temporary file") << temp.fileName() << true << true;
}
{
QTemporaryDir tempDir;
+ if (!tempDir.isValid())
+ QSKIP("Failed to create temporary directory!");
tempDir.setAutoRemove(false);
QTest::newRow("temporary dir")
<< tempDir.path() + QLatin1Char('/')
@@ -3689,10 +3692,13 @@ void tst_QFile::moveToTrash_data()
}
{
QTemporaryDir homeDir(QDir::homePath() + QLatin1String("/XXXXXX"));
- homeDir.setAutoRemove(false);
+ if (!homeDir.isValid())
+ QSKIP("Failed to create temporary directory in $HOME!");
QTemporaryFile homeFile(homeDir.path()
+ QLatin1String("/tst_qfile-XXXXXX"));
- homeFile.open();
+ if (!homeFile.open())
+ QSKIP("Failed to create temporary file in $HOME");
+ homeDir.setAutoRemove(false);
QTest::newRow("home file")
<< homeFile.fileName()
<< true << true;