From 9b4b406142b05eef8ef255561f24951f25567a8e Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 29 Apr 2020 10:55:06 +0200 Subject: Handle disk full situations by skipping QFile::moveToTrash test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'tests/auto/corelib/io') 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; -- cgit v1.2.3