From b0329f85606ed18036c8e49f9097dd8565c0b8ea Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 25 Sep 2023 14:42:10 -0700 Subject: [PATCH] tst_QFile::moveToTrash: add tests for /var/tmp These must pass, but they're highly unlikely to be trashable because /var/tmp is usually not its own filesystem (it might be a subvolume of its own, but usually isn't). Instead, it's usually part of / or /var. On my machine: openat(AT_FDCWD, "/var/.Trash", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory) openat(AT_FDCWD, "/var/.Trash-1000", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory) mkdirat(AT_FDCWD, "/var/.Trash-1000", 0700) = -1 EACCES (Permission denied) Change-Id: Ifeb6206a9fa04424964bfffd17884246a4d27443 Reviewed-by: Ahmad Samir Reviewed-by: Volker Hilsheimer --- tests/auto/corelib/io/qfile/tst_qfile.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 80ff73e298..391471b15f 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -3949,6 +3949,10 @@ void tst_QFile::moveToTrash_data() if (!temp.open()) QSKIP("Failed to create temporary file!"); QTest::newRow("temporary file") << temp.fileName() << true << true; +#ifdef Q_OS_UNIX + if (QDir::tempPath() == "/tmp") + QTest::newRow("var-temporary file") << "/var" + temp.fileName() << true << true; +#endif } { QTemporaryDir tempDir(QDir::tempPath() + "/tst_qfile-moveToTrash-XXXXXX"); @@ -3958,6 +3962,10 @@ void tst_QFile::moveToTrash_data() QTest::newRow("temporary dir") << tempDir.path() + QLatin1Char('/') << true << true; +#ifdef Q_OS_UNIX + if (QDir::tempPath() == "/tmp") + QTest::newRow("var-temporary dir") << "/var" + tempDir.path() << true << true; +#endif } { QTemporaryDir homeDir(QDir::homePath() + QLatin1String("/tst_qfile.moveToTrash-XXXXXX"));